Two public agricultural datasets were used to train and evaluate AGRIBOT’s classification models — CWFID for initial validation and the BoniRob sugar beet dataset from the Photogrammetry & Robotics Lab at the University of Bonn for final model selection. Each dataset feeds a different preprocessing pipeline and input resolution, so it is important to understand their differences before runningDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Dhruv2012/Autonomous-Farm-Robot/llms.txt
Use this file to discover all available pages before exploring further.
main.py.
CWFID Dataset
Full name: Crop/Weed Field Image Dataset CWFID contains annotated RGB images of carrot crops growing alongside weed, captured in a real agricultural field. It is a compact dataset well suited for rapid prototyping and architecture validation.| Property | Value |
|---|---|
| Crop type | Carrot |
| Input resolution | 128 × 128 (UNet) or 512 × 384 (Bonnet) — set by h/w in main.py |
| Annotation format | PNG masks (per-pixel class labels) |
| Split definition | train_test_split.yaml |
| Image directory | images/ |
| Annotation directory | annotations/ |
| URL | https://github.com/cwfid/dataset |
train and test lists. The load_cwfid_withyaml() helper in utils.py reads this file and assembles x_train, y_train, x_test, y_test arrays automatically. The resolution passed to this helper is determined by the model selected (h = 128, w = 128 for UNet; h = 512, w = 384 for Bonnet) not by a fixed CWFID property.
BoniRob Dataset (Bonn Sugar Beets)
The BoniRob dataset was captured by the BoniRob agricultural robot from the University of Bonn’s Photogrammetry & Robotics Lab. It contains multi-spectral images of sugar beet fields with dense three-class pixel annotations.| Property | Value |
|---|---|
| Crop type | Sugar beet |
| Labels | Weed (0), Crop (1), Soil (2) |
| Input resolution | 512 × 384 pixels |
| Input channels | 10 (RGB + vegetation indices + HSV) |
| Approximate size | ~6 GB uncompressed |
| Splits | train/, val/, test/ under preprocessed directories |
| URL | https://www.ipb.uni-bonn.de/data/sugarbeets2016/ |
Datasets(Git)/BoniRob dataset/Dataset Analysis lists all such samples so they can be removed before training. The preprocess() helper in utils.py performs this filtering automatically by taking the intersection of filenames found in the input and output directories.
The preprocessed dataset is then split into train, validation, and test subsets by pre-process.py using an 80/20/validation strategy:
- Train: ~64 % of total samples
- Test: ~20 % of total samples
- Validation: ~16 % of total samples
10-Channel Input for BoniRob
Plain RGB is insufficient to reliably distinguish green weed from green crop in field conditions. AGRIBOT extends the three RGB channels with seven additional channels — computed vegetation indices and HSV colour-space components — to give the Bonnet model richer spectral information. The channel construction is implemented inmultichannel_input() in utils.py and mirrored by load_input() in real-time.py. In both functions the image is first in RGB order (channels 0=R, 1=G, 2=B), and the indices below use the same convention:
real-time.py the input frame arrives as BGR (from OpenCV) and is converted to RGB via frame[:,:,[2, 1, 0]] before the vegetation index computation, so the same channel indexing applies.
| Channel | Name | Formula |
|---|---|---|
| 0 | Red (normalised) | R / 255 |
| 1 | Green (normalised) | G / 255 |
| 2 | Blue (normalised) | B / 255 |
| 3 | ExG | (2·G − R − B) / 255 |
| 4 | ExR | (1.4·R − G) / 255 |
| 5 | CIVE | (0.881·G − 0.441·R − 0.385·B − 18.78745) / 255 |
| 6 | NDI | (G − R) / (G + R) |
| 7 | Hue | H / 360 |
| 8 | Saturation | S (0–1 range from OpenCV HSV) |
| 9 | Value | V / 255 |
float16 to reduce memory pressure during batch generation.
Dataset Configuration in main.py
Use the dictionaries at the top ofmain.py to switch between datasets and architectures before running training:
DATASET = dataset["bonirob"] is set, main.py instantiates three data_gen() generators (train, val, test) rather than loading everything into memory, which is essential for a dataset of this size.