Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Agriculture Pest Detection
|
| 2 |
+
by Oscar Mendoza
|
| 3 |
+
|
| 4 |
+
Model Description:
|
| 5 |
+
The model I worked on is a computer vision model that uses object detection to help identify common agricultural pest in crop images.
|
| 6 |
+
The model was trained to identify six different insects and put them into classes. Those classes were ants, aphids, beetles, caterpillars,
|
| 7 |
+
grasshoppers, and weevils. The model was trained using Yolo V11 for its fast and accurate object detection.
|
| 8 |
+
The model aims to support early pest detection in agriculture from images captured in field conditions like plants, soil, and foliage
|
| 9 |
+
|
| 10 |
+
Training Data:
|
| 11 |
+
The dataset was found called Pest Detection Computer Vision Model
|
| 12 |
+
https://universe.roboflow.com/sams-sgift/pest-detection-qbalv
|
| 13 |
+
The dataset originally came with 7.3k images, but I narrowed it down to 2.5k images
|
| 14 |
+
Each class was pretty balanced for images, with ahids being the only one not in the 400s for photos
|
| 15 |
+
Below are the images per class:
|
| 16 |
+
Ant: 497 images
|
| 17 |
+
Aphid: 283 images
|
| 18 |
+
Beetle: 413 images
|
| 19 |
+
Caterpillar: 409 images
|
| 20 |
+
Grasshopper: 483
|
| 21 |
+
Weevil: 480 images
|
| 22 |
+
Classes were reduced from 19 to 6 for better focus, classes were selected on how common its found in crops, and relevance to agriculture.
|
| 23 |
+
Annotation Process:
|
| 24 |
+
Dataset was reviewed and cleaned using roboflow, approximately reveiwed 50 images for annotations. Corrections like misidentified labels, or
|
| 25 |
+
innacurate bounding boxes, removing images that didn't match any of the classes.
|
| 26 |
+
Train: 70%
|
| 27 |
+
Validation: 20%
|
| 28 |
+
Split: 10%
|
| 29 |
+
|
| 30 |
+
No data augmentation was applied.
|
| 31 |
+
Link to my annotated refined dataset:
|
| 32 |
+
https://app.roboflow.com/oscars-space-teemy/pest-detection-qbalv-a6hpf/models/pest-detection-qbalv-a6hpf/3
|
| 33 |
+
Limitation in my dataset:
|
| 34 |
+
Some insects such as aphids are small and difficult to detect, natural backgrounds can make insects harder to find due to blending in with its
|
| 35 |
+
environment. Dataset also may not represent all agricultural environments.
|
| 36 |
+
|
| 37 |
+
Training Procedure:
|
| 38 |
+
Framework: Ultralytics YOLOv11
|
| 39 |
+
Hardware: Using Google Colab on A100 GPU runtime
|
| 40 |
+
Epochs: 50
|
| 41 |
+
Image size: 640x640
|
| 42 |
+
|
| 43 |
+
Evaluation Results:
|
| 44 |
+
Overall Metrics
|
| 45 |
+
mAP50: 0.676
|
| 46 |
+
mAP50-95: 0.345
|
| 47 |
+
Precision: 0.726
|
| 48 |
+
Recall: 0.659
|
| 49 |
+
|
| 50 |
+
Per Class Performance (Average Precision):
|
| 51 |
+
Ant: 0.263
|
| 52 |
+
Aphid: 0.176
|
| 53 |
+
Beetle: 0.370
|
| 54 |
+
Caterpillar: 0.172
|
| 55 |
+
Grasshopper: 0.420
|
| 56 |
+
Weevil: 0.675
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+

|
| 60 |
+
|
| 61 |
+

|
| 62 |
+
|
| 63 |
+

|
| 64 |
+
|
| 65 |
+
In my results image, you can see that the traning and validation loss curves decrease over time, meaning that the model is successfully learning
|
| 66 |
+
and improving its prection across epochs. Precision and recall both increase steadily through training, meaning most predictions are correct,
|
| 67 |
+
and the model detects a majority but not all of pests. Overall the trends show the model is learning effectively, but there are limitations,
|
| 68 |
+
especially when it comes to detecting smaller objects.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
|
| 73 |
+
My confusion matrix shows a nice diagnol line showing that most objects are getting detected and detected correctly, but we also see that
|
| 74 |
+
some of the best are getting confused with the background.
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+

|
| 78 |
+
|
| 79 |
+
My F1- Confidecne Curve shows how the model's F1 score changes with different confidence thresholds for each class. We see weevil performing
|
| 80 |
+
the best and maintaing a high F1 score (around 0.9) across a wide range of thresholds, while aphid and caterpillar perform the worst, with
|
| 81 |
+
lower F1 scores, meaning there is some difficult detecting these two classes.
|
| 82 |
+
|
| 83 |
+
Performance Analysis:
|
| 84 |
+
Overall, the model performs well across most classes. The best beeing the Weevil with a 0.675 AP and lowest being Caterpillar at 0.172 AP. Some
|
| 85 |
+
issues that I saw when looking at the performance was small insects like aphids were frequently missed, and some insects blend into natural
|
| 86 |
+
backgrounds, as well as some visual similarity between weevils and beetles. The recall score being 65.9% means that pest are being detected but
|
| 87 |
+
a significant portion are still missed, which wouldnt be the best for a solo agriculture detection system.
|
| 88 |
+
|
| 89 |
+
Limitations and Biases:
|
| 90 |
+
Poor performing classes would include the aphids and caterpillars, since aphids are typically green, you can't expect the model to identify the
|
| 91 |
+
aphid on green backgrounds. As for caterpillars, they are always changing their appearance based on the environment which would make it harder
|
| 92 |
+
for the model to detect them. As far as a dataset bias, the dataset isn't as diverse as it could be with most photos having a green background,
|
| 93 |
+
instead of showing a birds view of the insect on a white background to better detect. The model shouldn't be used as a fully automated pest
|
| 94 |
+
detection system since it cannot fully identify the objects. It would also not be suitable for anything that doesn't have human supervision, since
|
| 95 |
+
it would most likely make a mistake or not detect an insect.
|