Strawberry Picker
Files from a five-servo strawberry-picking arm built as a BINUS course project: a MobileNetV2 ripeness classifier checkpoint, one YOLOv8n training log, and a December 2025 snapshot of the project's code and notes.
Table of contents
About this repository
This Hugging Face repository is an older snapshot of the project. The project's main home is the GitHub repository theonegareth/strawberryPicker, and a write-up with photos is on the project page.
The arm was built by Group 2 (Kelompok 2) for the Robotics Kinematics and Dynamics course at BINUS ASO School of Engineering, from September 2025 to January 2026. A laptop runs a YOLOv8n detector on two webcams, works out each strawberry's position in centimetres from the stereo pair, and sends the target over USB serial to an Arduino Uno that drives the servos through a PCA9685 servo driver.
The detector the arm used is not in this repository. The only weights here are a two-class image classifier from a separate experiment.
Files
| Path | What it is |
|---|---|
classification/best_ripeness_classifier.pth |
PyTorch state dict (9.2 MB) of a torchvision MobileNetV2 with a two-output head, the only weights in this repository. It is byte-identical to model_backup/results/ripeness_classification/best_ripeness_classifier.pth on the GitHub commit_fixes branch. |
classification/training_summary.md, classification_model/training_summary.md |
Two copies of the summary of a later EfficientNet-B0 run. Its weights are not in this repository. |
classification_model/README.md |
Notes for that EfficientNet-B0 checkpoint (best_enhanced_classifier.pth), which is not in this repository. |
detection/, yolov8n/, yolov8s/, yolov11n/ |
Notes for detector checkpoints. Only the READMEs are here; the weight files they list are not in this repository. |
results.csv |
The Ultralytics training log of one YOLOv8n run, kaggle_strawberry_yolov8n_20251204_115538, kept with its args.yaml on the GitHub commit_fixes branch. |
scripts/combine3.py |
Two-camera capture, YOLO detection and stereo triangulation; the same file as combine3.py on GitHub main. scripts/all_combine3.py is a copy. |
scripts/, notebooks/ |
Training, labelling and export scripts, the Colab training notebook (train_yolov8_colab.ipynb), and the Keras MobileNetV2 good/bad classifier (train_model.py, strawberry_training.ipynb). |
src/, webcam_inference.py, inference_example.py |
An earlier Python pipeline (serial bridge at 115200 baud, coordinate transformer, detection plus classification) and two webcam demos. |
ArduinoCode/codingservoarm.ino |
Servo test sketch: moves the servos on PCA9685 channels 0 and 1 to a typed angle. |
config.yaml, requirements.txt |
Project configuration and dependencies from the snapshot. config.yaml points into a model/ tree that is not in this repository, and requirements.txt still holds unresolved git merge markers. |
README |
The project README from December 2025, corrected where it disagreed with the sources. |
docs/ |
Training guide and git setup notes. |
Usage
Load the classifier
The checkpoint is a state dict, not a pickled model, so build the network first and load the weights into it. Its keys sit under a backbone. prefix, so the network is a torchvision MobileNetV2 wrapped in a module with a backbone attribute. The tensors were saved on a GPU; map_location="cpu" loads them on a machine without one.
import torch
from torch import nn
from torchvision import models
from huggingface_hub import hf_hub_download
class RipenessClassifier(nn.Module):
def __init__(self, num_classes=2):
super().__init__()
self.backbone = models.mobilenet_v2(weights=None)
self.backbone.classifier[1] = nn.Linear(self.backbone.last_channel, num_classes)
def forward(self, x):
return self.backbone(x)
path = hf_hub_download("theonegareth/strawberryPicker", "classification/best_ripeness_classifier.pth")
model = RipenessClassifier()
model.load_state_dict(torch.load(path, map_location="cpu", weights_only=True))
model.eval()
The training script for this run is in neither repository, so the input size, the normalisation and the order of the two outputs are not recorded. Its training summary names the two classes unripe and ripe. The example below uses the standard ImageNet preprocessing of torchvision's MobileNetV2 at 224ร224; that is an assumption, not a record of how the model was trained.
from PIL import Image
from torchvision import transforms
preprocess = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
image = Image.open("strawberry_crop.jpg").convert("RGB")
with torch.no_grad():
probabilities = torch.softmax(model(preprocess(image).unsqueeze(0)), dim=1)[0]
print(probabilities.tolist())
webcam_inference.py and the older notes in this repository load a classifier with a bare torch.load(...) call, as if the file held a whole model. On this checkpoint that call returns the state dict, not a model.
Run a detector
inference_example.py runs an Ultralytics YOLO detector on an image, or on the webcam when it gets no argument. It expects a checkpoint named best.pt in the working directory, and no detector checkpoint is in this repository. The December 2025 training runs, with their weights, are under model/detection/ on the GitHub commit_fixes branch.
pip install ultralytics opencv-python
python inference_example.py strawberries.jpg
The system it came from
One pick runs as a loop:
- Both webcams capture a frame.
- YOLOv8n runs on each frame. The model is trained to box only ripe strawberries, so ripeness is decided at this step.
- Each left detection is paired with a right detection, and the pair is triangulated into X, Y and Z in centimetres.
- The axes are remapped from camera to robot, and the laptop sends the target to the Arduino over serial at 9600 baud as
x,z,yin centimetres. It sends a new target only after the Arduino printsREADY. - The Arduino solves the inverse kinematics, checks the joint limits, and moves the five servos through the PCA9685.
- The scissor servo cuts the stem, and the gripper catches the strawberry for the basket.
The servos are an MG996R for the base, a DS3240 for the shoulder, an MG996R for the elbow, an SG90s for the wrist and an MG90s for the scissor end effector, which uses a razor blade as its cutting edge. A 5 V 10 A supply powers the driver and servos.
The detector was trained on 232 images plus 56 negative images: half Kaggle images, half home-made webcam images for real lighting, with negatives of leaves, shelves and clothing so that a red shirt does not count as fruit. The labels are bounding boxes drawn only on ripe strawberries, 198 instances in all. The team compared YOLOv8 with YOLOv11 and chose YOLOv8n for real-time detection. The live system ran the PyTorch weights (best.pt) on the laptop, with no INT8 quantization.
The GitHub README covers the hardware, the kinematics and control, the dataset, the firmware and how to run each part: github.com/theonegareth/strawberryPicker.
Results
The arm's detector, on its validation set:
| Metric | Value |
|---|---|
| mAP@0.5 | about 0.976 |
| Best F1 | about 0.94, at a confidence threshold of about 0.33 |
| Confusion matrix | 101 ripe strawberries detected, 3 false positives, 7 missed |
| Live frame rate | 8.7 and 9.4 FPS on the laptop with the two webcams |
Source: the team's final course presentation and poster, as reported in the GitHub README.
The classifier checkpoint in this repository reached a best validation accuracy of 91.94%, on 422 validation images (163 unripe, 259 ripe), after training on 1,436 images (564 unripe, 872 ripe). Source: the run's training summary on the GitHub commit_fixes branch.
results.csv logs a 50-epoch YOLOv8n run on a single-class (strawberry) dataset built from Kaggle images only, not the mixed dataset above. At its last epoch its validation mAP@0.5 is 0.989 and its mAP@0.5:0.95 is 0.682. Source: the last row of results.csv.
Limitations
- The arm's detector is not in this repository, and neither are the checkpoints described in
detection/,yolov8n/,yolov8s/,yolov11n/andclassification_model/. - In the live loop the detector decides ripeness by boxing only ripe strawberries. The classifier here is not part of that loop as the GitHub README describes it, and the project's sources disagree on the classifier's architecture and classes.
- The classifier's training code, input size, preprocessing and output order are not recorded.
- The detector's labelled boxes cluster in the upper and middle part of the frame, so its dataset has some positional bias.
- The figures are from a course project on a small dataset. No measured pick rate for the whole arm is recorded.
config.yamlanddocs/TRAINING_README.mddescribe Raspberry Pi and INT8 TensorFlow Lite options, andscripts/export_tflite_int8.pycan produce an INT8 model. The live system did not use them; vision ran on the laptop.
Team
- Bryan Wilberd Lo (@bryan-wilberd): camera calibration, integration of Python and Arduino
- Enrico Ethan: control system, transfer functions, PID tuning
- Gareth Aurelius Harrison (@theonegareth): machine-learning model, dataset, labelling, training
- Jancent: assembly, setting up the environment
- Samuel Justus Tan (@SamJuss): forward kinematics, inverse kinematics, Arduino code
License
This repository is released under the MIT License (copyright 2025 Gareth).
Citation
The citation metadata is in CITATION.cff.
@software{harrison_strawberry_picker_2025,
author = {Harrison, Gareth Aurelius},
title = {Strawberry Picker},
year = {2025},
version = {1.0.0},
url = {https://huggingface.co/theonegareth/strawberryPicker}
}
- Downloads last month
- 16