Instructions to use anfruizhu/forages-rois-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use anfruizhu/forages-rois-models with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("anfruizhu/forages-rois-models", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
ForagesROIs models
ONNX models used by ForagesROIs, an application that detects, numbers and measures individual forage plants in RGB orthomosaics of field trials. Documentation: https://afruizh.github.io/forages_rois/
| File | Task | Model | Input | Classes |
|---|---|---|---|---|
forages_rois_yolo_full_1024.onnx |
Plant detection | YOLOv8n detect | 1024 × 1024 tiles | 0 urochloa, 1 megathyrsus |
crop_detection.onnx |
Crop field segmentation | YOLO11m-seg | whole orthomosaic resized to 640 × 640 | 0 crop, 1 target (not used) |
Version 1.0.0 (tag v1.0.0) is the version distributed with ForagesROIs 1.0.0. Checksums are in SHA256SUMS.
Intended use
- RGB orthomosaics (GeoTIFF) of forage trials of Urochloa (Brachiaria) and Megathyrsus maximus (Panicum), acquired by UAV at 1 to 3 cm per pixel. The training orthomosaics are 1.1 to 1.7 cm per pixel; at coarser resolutions plants become too small to detect.
- One box per plant, which ForagesROIs then numbers in field book order and uses to measure canopy area and cover.
- Not tested on other species, on multispectral bands or on imagery from other sensors.
Plant detector: forages_rois_yolo_full_1024.onnx
- Architecture: YOLOv8n detect (3.0 M parameters), initialised from the COCO weights
yolov8n.pt, trained with Ultralytics 8.3.134. - Training data: 374 tiles of about 1024 px with 25 % overlap, cut from the 8 orthomosaics of the dataset Forage grasses in crop fields from ultra-high spatial resolution UAV-based imagery (Harvard Dataverse, doi:10.7910/DVN/DBGUFW); 12,346 boxes (urochloa 3,809, megathyrsus 8,537). Random split by tile: 261 train, 56 validation and 57 test tiles.
- Training: 1024 px, batch 32, early stopping with patience 100; best epoch 259 of 359.
- Metrics (57 test tiles, best epoch): precision 0.972, recall 0.967, mAP@0.5 0.990, mAP@0.5:0.95 0.763. Species classification: 98 % of urochloa and 97 % of megathyrsus plants assigned to the right class.
- Limitations of these metrics: they are optimistic. The dataset configuration set the validation split to the test tiles, so the best epoch was chosen on them, and tiles of the same orthomosaics (which overlap) are in all splits. Expect lower values on new fields and flights.
- Output:
(1, 6, N)without NMS (4 box coordinates and 2 class scores per candidate). ForagesROIs applies the threshold (default 0.10) and NMS.
Crop field segmenter: crop_detection.onnx
- Architecture: YOLO11m-seg (22.4 M parameters), trained on Roboflow with Ultralytics 8.3.171, exported to ONNX with Ultralytics 8.4.27.
- Training data: orthomosaics annotated with crop field polygons in Roboflow [XX: project, version and number of images].
- Training: 640 px, batch 6, up to 300 epochs, patience 10.
- Metrics: [XX: from the Roboflow test split].
- Output: with NMS (
(1, 300, 38)detections and(1, 32, 160, 160)mask prototypes). The classtargetis not used: at the 640 px scale of a whole orthomosaic a ground target is only a few pixels.
Use with ForagesROIs
The models can be downloaded by the ForagesROIs release. To use them separately, put both files in one folder (keep the file names) and select it in the application with File > Set Models Folder.... Direct download of a file of this version:
https://huggingface.co/anfruizhu/forages-rois-models/resolve/v1.0.0/<file>.onnx
License
These models were trained with Ultralytics YOLO and are distributed under the GNU Affero General Public License v3.0 (see LICENSE). The ForagesROIs code is distributed separately under the Apache License 2.0.
Citation
Training data: Forage grasses in crop fields from ultra-high spatial resolution UAV-based imagery, Harvard Dataverse, doi:10.7910/DVN/DBGUFW.
Developed at the Tropical Forages Team / Alliance of Bioversity International and CIAT (Tropical Forages Program). Questions and issues: https://github.com/afruizh/forages_rois/issues