This application allows users to upload images or capture images from a camera, then uses a trained YOLO model to detect and classify corn kernels into categories (black, corn, white, and fragments). It provides count statistics for each category and maintains a cumulative count.
The application provides a simple web interface where users can upload images or capture photos using their camera. The processed images are displayed along with classification results.
After processing, the application displays the analyzed image with detected corn kernels and a detailed breakdown of kernel counts by category:
| Category | Description |
|---|---|
| Good Seeds | Healthy corn kernels with no infection |
| Aspergillus niger | Kernels infected with the Aspergillus niger fungus, a common mycotoxin-producing mold that appears as black spots |
| Penicillium | Kernels infected with Penicillium fungi, which typically appears as blue-green or black mold on corn |
| Corn Fragments | Broken or partial corn kernel pieces |
| Total Seeds | The total count of all detected kernels and fragments |
The application also maintains a cumulative count of detected kernels across multiple images, which can be reset as needed.
This application uses a custom-trained YOLOv8 model for corn kernel detection and classification. The model achieves impressive accuracy:
- mAP: 99.2%
- Precision: 98.2%
- Recall: 97.7%
You can access, duplicate, or experiment with our model on Roboflow:
Corn Detection Model
The dataset is available for download through the Roboflow platform, allowing you to train your own models or modify our approach for similar detection tasks.
- Python 3.x
- Pip package manager
-
Clone the repository or download the project files
-
Create and activate a virtual environment (optional but recommended):
python -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install the required dependencies:
pip install flask opencv-python ultralytics werkzeug
-
Ensure the YOLO model file (
best.pt) is in the model directory -
Make sure all required directories exist:
mkdir -p check results static templates uploads
You may need to update the file paths in app.py to match your system:
UPLOAD_FOLDER = '/path/to/your/project/check'
RESULTS_FOLDER = '/path/to/your/project/results'
STATIC_FOLDER = '/path/to/your/project/static'-
Start the Flask server:
python app.py
-
Open a web browser and navigate to:
http://127.0.0.1:5000/
-
The application provides two ways to submit images:
- Upload an image file
- Capture an image using your camera
-
After processing, the application will:
- Display the processed image with detections
- Show counts for each kernel type (black, corn, white, fragments)
- Display the total kernel count
- Show the cumulative count across all processed images
-
You can reset the cumulative count using the reset button
- app.py: Main Flask application
- best.pt: YOLO model trained for corn kernel detection
- index.html: HTML template for the web interface
- check: Temporary storage for uploaded images
- results: Directory for saving processed images
- static: Static files served by the application
- uploads: Directory for storing uploaded files
- Flask: Web framework
- OpenCV: Image processing
- Ultralytics YOLO: Object detection model
- JavaScript/HTML/CSS: Frontend
[agungferdi] thanks

