← Back to selected projects Applied AI case study / 02

COMPUTER VISION · OBJECT DETECTION

YOLOv11 Mango Detection

A documented computer-vision workflow that fine-tunes YOLOv11-n to locate mangoes in orchard images.

I structured the dataset setup, defined two training configurations, compared their recorded validation results, selected the tuned checkpoint and reported its performance on a held-out test split.

Precision0.936Correctness of positive detections
Recall0.971Coverage of annotated mangoes
mAP@0.50.989Detection performance at IoU 0.50
mAP@0.5:0.950.704Performance across stricter IoU thresholds
Selected model / prediction exampleConfidence threshold 0.25
Fine-tuned YOLOv11-n model detecting multiple mangoes in an orchard image
Bounding boxes show model detections on an orchard image. The public repository includes additional prediction examples and a configurable inference script.

01 / PROBLEM

Detect fruit in visually complex orchard scenes.

Automated fruit detection can support later tasks such as counting, crop-load estimation and orchard monitoring. Before those applications are possible, the model must first localise fruit reliably despite leaves, branches, clustering, scale changes and uneven lighting.

The project question

Can a lightweight YOLOv11-n detector be fine-tuned to identify mangoes in the recorded orchard dataset and maintain useful performance on a separate held-out test split?

The scope was deliberately limited to one class—mango. The project does not infer ripeness, quality, disease, variety or commercial yield.

01

Occlusion

Leaves, branches and overlapping fruit can hide object boundaries and reduce localisation quality.

02

Scale variation

Mangoes appear at different sizes depending on their distance from the camera.

03

Lighting

Highlights, shadows and colour shifts can change the visual appearance of the same class.

04

Clustering

Closely grouped mangoes make it harder to separate individual detections accurately.

02 / DATASET

Public data, documented attribution and separate evaluation splits.

The project uses a publicly available YOLO-format dataset from Roboflow Universe under CC BY 4.0. The source and licence are documented in the repository.

Recorded dataset 1,730

annotated orchard images

Training1,38480.0% of images
Validation26015.0% of images
Test865.0% of images
Validation

Used to compare experiments and choose the final model before viewing final test performance.

Held-out test

Used for the final reported metrics after model selection.

Repository scope

The complete dataset and trained checkpoint are excluded; attribution, setup and download instructions are provided instead.

03 / PIPELINE

A workflow designed for repeatable experimentation.

The cleaned notebook provides separate code sections for dataset validation, experiment configuration, validation comparison, final evaluation and inference.

01Validate dataCheck image and label counts across train, validation and test folders.
02Fine-tuneStart from pretrained YOLOv11-n weights using controlled experiment settings.
03SelectCompare baseline and tuned checkpoints using recorded validation metrics.
04EvaluateEvaluate the selected checkpoint on the held-out test split.
05InferUse the command-line script on an image, video, supported URL or directory.
  • Python 3.12
  • YOLOv11-n
  • Ultralytics
  • PyTorch
  • CUDA
  • Google Colab
  • Pandas
  • OpenCV

04 / EXPERIMENTS

Model selection based on validation evidence.

Two experiments used the same YOLOv11-n architecture, image size, batch size, optimiser and random seed. The tuned configuration extended the training budget, reduced the initial learning rate and increased early-stopping patience.

ExperimentPurposeEpochsLearning ratePatienceVal mAP@0.5Val mAP@0.5:0.95
BaselineReference run500.0010150.9888310.701359
TunedSelectedLonger, lower-LR run100 planned
stopped at 77
0.0008200.9900000.703000
Best epoch57

The selected run stopped at epoch 77 after no further improvement within the configured patience window.

Controlled variables640 × 640 · batch 16

Both configurations used pretrained YOLOv11-n weights, AdamW and a fixed random seed of 42.

Selection ruleValidation first

The tuned model was selected using the recorded validation comparison before final test performance was reported.

05 / RESULTS

Strong detection scores with room for tighter localisation.

The selected checkpoint was evaluated on 86 held-out images containing 694 annotated mango instances.

Precision93.64%

Most predicted mango boxes corresponded to annotated fruit.

Recall97.12%

The model recovered a high proportion of annotated mango instances.

mAP@0.598.94%

Detection was very strong at the standard IoU 0.50 threshold.

mAP@0.5:0.9570.43%

Performance decreased when localisation was judged across stricter IoU thresholds.

Interpretation

The gap between mAP@0.5 and mAP@0.5:0.95 is consistent with the detector finding mangoes more reliably than it places consistently tight boxes around them. Recall was also higher than precision, indicating high coverage with some remaining false-positive risk.

Training historyOpen full size ↗
YOLOv11-n mango detector training and validation metric history
The recorded training curves provide supporting context for convergence and model behaviour.
Precision–recall curveOpen full size ↗
Precision-recall curve for the mango object-detection model
The curve shows the trade-off between finding more mangoes and limiting false detections.
Confusion matrixOpen full size ↗
Confusion matrix for mango detections and background errors
The matrix provides additional evidence about background errors and missed detections.

06 / PREDICTIONS

Inspecting outputs beyond aggregate metrics.

Prediction examples provide a qualitative view of how the detector behaves in orchard scenes, including fruit at different scales and levels of occlusion.

First mango detection example with multiple bounding boxes
Dense orchard scene
Second mango detection example showing fruit under varied lighting
Lighting and scale variation
Third mango detection example showing clustered fruit
Clustered and partially occluded fruit

07 / MY CONTRIBUTION

From experiment configuration to a documented computer-vision workflow.

I reorganised the academic work into a public repository with explicit dataset setup, training configurations, recorded metrics, evaluation code and inference tooling.

01

Dataset workflow

Configured the YOLO-format directory structure, added image-and-label count checks, generated a runtime dataset configuration and documented attribution.

02

Experiment configuration

Defined baseline and tuned settings with shared image size, batch size, optimiser and seed, then varied the training budget, learning rate and patience.

03

Model selection and evaluation

Documented the validation comparison, selected the tuned run and reported final performance on a separate held-out test split.

04

Reusable tooling and documentation

Cleaned the notebook, created a configurable command-line inference script, added a model card and documented dataset and model licensing.

09 / LIMITATIONS

What the results show—and what still needs validation.

The held-out split provides performance evidence for this dataset and recorded training run. External datasets and target-device benchmarks are still needed to measure behaviour across new orchards, seasons, cameras and deployment environments.

Data coverage

Limited orchard conditions

The dataset represents a restricted range of locations, capture conditions and visual environments.

External validity

One held-out test split

The model has not yet been validated against a separately collected external orchard dataset.

Task boundary

Detection only

The model does not classify ripeness, variety, damage, disease or fruit quality.

Deployment

No device benchmark yet

Latency, memory use and throughput still need testing on target local or edge hardware.

10 / NEXT STEPS

Move from detection research toward useful orchard tooling.

The next stage should prioritise generalisation and measurable deployment behaviour before adding more product features.

  1. 01

    External validation

    Test images from new orchards, seasons, cultivars, camera systems and lighting conditions.

  2. 02

    Model comparison

    Compare YOLOv11-n with larger variants and measure accuracy, memory and inference-speed trade-offs.

  3. 03

    Counting and load estimation

    Extend detections into image-level counting and evaluate counting error against annotated ground truth.

  4. 04

    Prototype deployment

    Build an image-upload demonstration and benchmark the selected model on realistic hardware.

CASE STUDY 02

Review the implementation evidence.