Available from Breeze v2026.2
On a Windows machine, you need to install Python version 3 or higher and the py Python launcher, or specify a custom python interpreter
First select Descriptor as node type and then select Python script as the method. Select the python script file using the Browse button or type the path to the script file directly.
The type value must be 1-based as 0 is reserved in Breeze for NO_CLASS
Parameters
Python file
Select the python file.
Python interpreter optional
Use the file selector to specify a custom Python executable. If left empty, the system will attempt to use:
-
The global system command (
pyon Windows,python3on Linux). -
The bundled Breeze Python environment (used as a fallback if the global command is not found).
Apply to
-
Object
-
Applies the python file content on the objects.
-
-
Pixels
-
Applies the python file content on the pixels.
-
Names file
Newline separated classes/labels file
Almonds
Shell
Hazelnut
Pecan
Walnut
Example for nuts.names
If no names file is supplied the type will only be a numerical value.
Pretreatments
See Pretreatments
Output
-
Value
-
A
float32value from the script -
Could be a confidence value from the classification
-
-
Type
-
A
int32value, corresponding to the same row in the Names file.
-
Example
Below is a high-performance classification script utilizing a custom Neural Network forward pass via NumPy. It expects an uncompressed .npz file containing the weights and biases alongside the script. Based on the Classification of nuts step 3 data.
Training
import pandas as pd
import numpy as np
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import classification_report
df_train = pd.read_csv("nuts_train.csv", sep=";")
X_train = df_train.iloc[:, 1:].values
y_train = df_train.iloc[:, 0].values
df_test = pd.read_csv("nuts_test.csv", sep=";")
X_test = df_test.iloc[:, 1:].values
y_test = df_test.iloc[:, 0].values
model = MLPClassifier(hidden_layer_sizes=(64,), activation='relu', max_iter=1000, random_state=42)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
print(classification_report(y_test, y_pred))
np.savez("nn_weights.npz",
W1=model.coefs_[0].astype(np.float32),
b1=model.intercepts_[0].astype(np.float32),
W2=model.coefs_[1].astype(np.float32),
b2=model.intercepts_[1].astype(np.float32))
Classifier
import os
import numpy as np
W1, b1, W2, b2 = None, None, None, None
def setup():
global W1, b1, W2, b2
script_dir = os.path.dirname(os.path.abspath(__file__))
weights_path = os.path.join(script_dir, "nn_weights.npz")
data = np.load(weights_path)
W1 = data['W1'].astype(np.float32)
b1 = data['b1'].astype(np.float32)
W2 = data['W2'].astype(np.float32)
b2 = data['b2'].astype(np.float32)
def perform(frame_data, num_bands):
pixel_count = len(frame_data) // num_bands
if pixel_count == 0:
return []
x = np.array(frame_data, dtype=np.float32).reshape((pixel_count, num_bands))
z1 = np.dot(x, W1) + b1
a1 = np.maximum(0, z1)
z2 = np.dot(a1, W2) + b2
results = np.empty((pixel_count, 2), dtype=np.float32)
results[:, 0] = np.max(z2, axis=1)
results[:, 1] = np.argmax(z2, axis=1) + 1
return results