Training Custom YOLO Models
MIRA uses the Ultralytics YOLO framework for object detection. While MIRA comes with default weights, you may need to train a custom model to detect specific spore species or adapt to unique lighting conditions.
The workflow consists of four main phases:
—
Phase 1: Image Acquisition
The quality of your model depends entirely on the quality of your dataset.
Diversity: Capture images with varying spore densities.
Focus: Include slightly out-of-focus images to make the model robust.
Backgrounds: Take pictures of “empty” chambers to reduce false positives (Background images).
Resolution: Use the resolution you intend to use in production (e.g., ArduCam 20MP native resolution).
Use MIRA’s Batch Capture feature to quickly gather hundreds of images.
Set a 2-second delay and move the microscope stage slightly between captures to vary the field of view.
—
Phase 2: Annotation
Once you have your images, you must draw boxes around the spores to teach the AI what to look for.
Roboflow is a web-based platform that simplifies the whole process.
Upload: Import your raw images.
Annotate: Use the “Auto-Label” or manual box tools.
Augment: Apply rotations, blur, or noise to artificially increase your dataset size.
Export: Choose the YOLOv11 PyTorch format.
If you prefer to keep your data offline:
CVAT: Powerful, professional open-source annotation tool.
Label Studio: Versatile and supports many data types.
LabelImg: Simple, lightweight tool specifically for bounding boxes.
—
Phase 3: Model Training
We recommend using the latest YOLO models (YOLOv8, YOLOv10, or YOLOv11) from Ultralytics.
Google Colab: Free GPU access. Perfect if you don’t have a powerful NVIDIA card.
Local PC: Fastest if you have a local NVIDIA GPU (RTX 30 series or better).
# Example: Training with the Ultralytics CLI
pip install ultralytics
yolo task=detect mode=train model=yolov11n.pt data=your_data.yaml epochs=100 imgsz=640
For detailed instructions, refer to the Ultralytics Training Documentation.
—
Phase 4: Using your Model in MIRA
After training, you will find a file named best.pt in your training output folder (usually runs/detect/train/weights/).
Copy the
best.ptfile to your computer.In MIRA, click the Load Models button.
Select the folder containing your
.ptfile. MIRA will list all available models in the dropdown.
Thresholds: Adjust the Confidence slider in MIRA based on your model’s performance.
Classes: MIRA will automatically detect the class names defined during your training (e.g., “spore”, “pollen”, “debris”).
—
You can find pre-trained weights and example datasets on our repository or check the Ultralytics HUB for an all-in-one training experience.