Custom CNN Model
This function block lets you load a TensorFlow-based image classification model and run predictions on incoming images. It is intended for users who want to apply a custom trained convolutional neural network to classify images in a visual workflow.
π₯ Inputs
Image Any The image that will be classified by the loaded model.
π€ Outputs
Class Index (Detected) The numeric index of the predicted class.
Class Name (Detected) The human-readable class name (if the model provides class labels).
Detection Result (Raw Output) The raw model output or scores produced by the classifier.
πΉοΈ Controls
Load Model Opens a file dialog to select and load a model file. Supported model types include standard TensorFlow models and TFLite models.
Classes A text area that displays the class list found inside the loaded model (if available).
π¨ Features
Simple model import: Load a trained TensorFlow or TFLite model using a single control.
Class label preview: The block shows class names extracted from the model so you can verify labels before running.
Immediate inference: When a model is loaded, incoming images are classified and the results are output for downstream use.
Outputs for automation: Both numeric index and human-readable class name are available, plus raw model outputs for advanced handling.
βοΈ How it runs
Use the
Load Modelcontrol to import a model file from disk.Once a model is loaded and verified, the block accepts images via the
Image Anyinput.For each incoming image, the block performs inference and provides the predicted class index, optional class name, and the raw prediction values on the outputs.
π Usage Instructions
Click the
Load Modelbutton and choose your model file. Confirm that the class list appears in theClassesdisplay to ensure the model is correctly loaded.Connect any image source to the
Image Anyinput (for exampleCamera USB,Load Image, orStream Reader).Use the block outputs to route classification results to visualization, logging, or decision logic blocks.
π‘ Tips and Tricks
Preprocess images to match your model's expected input size with
Image ResizerorImage Resizebefore feeding them to this block. This improves prediction consistency.For visual verification, connect this block's image source to
Show Imageso you can preview what the model sees.Overlay classification results onto images using
Write Text On ImageorDraw Result On Imageto create easy-to-understand visual outputs for operators.Save classification events with
Image Loggeror export numeric results to files usingCSV Exportfor later analysis.Use
Image ROI SelectorImage ROIto crop to relevant areas before classification if your model expects objects at a fixed position.Combine with
Is NoneorData Memoryto handle missing frames or freeze outputs when needed.
π οΈ Troubleshooting
No classes shown after loading: Ensure the model contains class label metadata. If the class list is empty, the block will still output numeric indices but no human-readable names.
Model not loading: Verify you selected a supported model file and that the file path is accessible. If a TFLite or TensorFlow file is available, choose the appropriate file.
Unexpected predictions: Confirm input image size, color channels, and preprocessing match what the model was trained on. Use
Image Resize, color conversion blocks, or preprocessing steps upstream to match training conditions.Slow inference: Consider resizing images smaller with
Image Resizeror using a lighter model variant before real-time deployment.
Last updated
Was this helpful?