A Walkthrough of Object Detection Tasks with Brain Builder for AITRIOS
Detecting Fruits with Brain Builder for AITRIOS: Apples, Bananas, and Oranges
Imagine a world where AI helps streamline fruit sorting, quality control, and inventory management. With Brain Builder for AITRIOS, you can create a detector model that identifies fruits like apples, bananas, and oranges in real-time. This technology has applications in agriculture, logistics, and retail, where automating fruit detection can save time and reduce costs.
In this blog post, we’ll explore how a fruit detector AI model works, discuss its potential use cases, and guide you through building one using apples, bananas, and oranges as examples.

What is a Detector Model?
A detector model goes beyond classification by identifying objects in an image and locating them with bounding boxes. In the context of fruit detection, this means recognizing multiple fruits in a single image and marking their positions.
For example:
- Identify Fruits: Detect apples, bananas, and oranges in images for sorting or inventory purposes.
- Harvest Monitoring: Count and track fruit yield in orchards or farms.
Use Cases for Fruit Detection
Automated Sorting
A detector model can identify fruits as they move along a conveyor belt, classifying them by type for packaging or processing.
Retail Applications
Automate inventory checks in supermarkets, identifying the types and quantities of fruits on display.
Agricultural Monitoring
Use drones or cameras to monitor fruit growth and detect ripe fruits ready for harvest.
How to Use the Detector Model for Fruit Detection
Follow these steps to build and train your fruit detector model:
1. Create a New Project
- Log in to Brain Builder for AITRIOS and click New Project.
- Select the Detector model type.
- Name your project (e.g., “Fruit Detector”) and add a description.

2. Prepare Your Dataset

Capture images:
- Use your captured dataset with images containing apples, bananas, and oranges.
- Ensure the images represent real-world scenarios, such as fruits on conveyor belts, in baskets, or on store shelves.

Annotate the images
You can annotate your images using Brain Builder or use pre-annotated images in KITTI format
- Annotate the Images using Brain Builder:
- Draw bounding boxes around each fruit and label them according to your specific case. In our example, we will use the following annotations: “Apple,” “Banana,” and “Orange.”


- Use annotated images in KITTI format:

- Make sure you have a ZIP in the proper format and upload


3. Train the model
- Navigate to the Training tab and configure the duration settings:
- Quick: For testing the setup quickly.
- Balanced: For good results without excessive time.
- Thorough: For maximum accuracy when time allows.
- Start training the model. Brain Builder will evaluate multiple AI models and optimize the best one for your dataset.

4. Evaluate the Results
- After training, review the metrics:
- Precision: Check how accurately the model identifies apples, bananas, and oranges without false detections.
- Recall: Ensure the model detects all the fruits in the images.

- The Precision Metric tries to answer the question: "Of all the objects I detected, how many were correcty detected?"
- The Recall Metric tries to answer the question: “Of all the objects that exist, how many did I detect?”
5. Adjust Thresholds
After evaluating our results, Brain Builder for AITRIOS gives us the option to adjust our thresholds and see it reflected in real-time. You can click on an image and see in real-time how the adjustments will affect it. All adjustments affect the entire AI model.
- The options to set are:
- The Confidence Threshold
- What It Does: Determines the minimum confidence level for detections to be considered valid (range: 0.1 to 1).
- How to Adjust:
- Lower threshold → Accepts more uncertain cases → Increases Recall (fewer missed detections).
- Higher threshold → Rejects uncertain cases → Increases Precision (fewer false detections).
- Default Value: 0.5, but should be adjusted based on your dataset and goals.
- The IoU (Intersection over Union) Threshold
- What It Does: Measures the overlap between the AI's detection box and the ground truth. Determines whether a detection is a True Positive.
- How to Adjust:
- Higher threshold → Requires more overlap → Ensures stricter accuracy.
- Lower threshold → Allows less overlap → Captures more detections, even if less precise.
- The Confidence Threshold

6. Export the AI model
Once everything looks good you are ready to export your AI model. Brain Builder for AITRIOS will produce a ZIP file named after your project.

7. Deploying to the Raspberry Pi AI Camera
Deploying a model to the Raspberry Pi AI camera is simple with Brain Builder for AITRIOS. Using the IMX build tools package, you can convert the Brain Builder exported AI model into a format that the Raspberry Pi AI Camera can use.
1. Be sure that you have installed all the dependencies:
sudo apt install imx500-tools
sudo apt install python3-opencv python3-munkres python3-picamera2
git clone https://github.com/SonySemiconductorSolutions/aitrios-rpi-model-zoo.git
2. Copy your exported AI model (Brain) to the Raspberry Pi and unzip the top-level file and the dataset named file.

3. Open a terminal at your extracted dataset. That would be {Unzipped brainBuilderExport}/{Unzipped dataSetName} and run the command below. This will create your network.rpk file.
imx500-package -i packerOut.zip -o .
4. Switch to the correct Model Zoo directory:
aitrios-rpi-model-zoo/models/object-detection/brainbuilder/

5. Push the model to the Raspberry Pi AI camera.
- Run the command below which will open a window displaying the camera feed:
python app.py --model network.rpk --labels labels.txt --fps 15
6. See it in action
- Watch as your Raspberry Pi AI camera runs your model in real-time, performing tasks from object detection to classification all completely on the camera freeing up your Raspberry Pi.

- Balanced data: Ensure your dataset has a similar number of apples, bananas, and oranges to prevent bias.
- Augmentation: Add variations to your dataset, such as different angles and lighting, to improve robustness.
- Iterate: Use test results to refine your model by adding more labeled data or adjusting training settings.
Ready to Build?
With Brain Builder for AITRIOS, creating and deploying an Object Detection AI model is simple and efficient.
Start today and bring AI-powered quality control to your production line!

Share this post: