An AI-powered cocoon quality assessment system that automates silk cocoon grading and yield estimation using a two-stage deep learning pipeline:
- YOLOv8 – for cocoon detection and segmentation
- EfficientNet-B0 – for fine-grained classification into 6 quality categories
Includes a Renditta-based silk yield estimator and a Flask-based web interface for real-time industrial deployment.
Manual silk cocoon grading is slow, inconsistent, and subjective, with accuracy typically ranging from 70–80%.
This project leverages computer vision and deep learning to improve grading consistency, speed, and precision, achieving:
- 96.1% mAP@0.5 in cocoon segmentation
- 97% classification accuracy for quality grading
The system is suitable for industrial-scale silk factories and small farms, offering:
- Automated defect detection (double, pierced, crushed, decayed, yellow-spotted)
- Batch-level grading and yield forecasting
- Real-time web-based reporting
-
Data Acquisition
- 3,460 cocoons photographed with high-resolution smartphone cameras
- Final dataset: 3,068 annotated cocoons across 6 quality categories
-
Preprocessing & Augmentation
- Resized to 640×640 pixels (YOLOv8) / 224×224 pixels (EfficientNet-B0)
- Augmentations: mosaic, mixup, flips, rotations, brightness/contrast adjustments
-
Stage 1 – Segmentation (YOLOv8)
- Detects and segments individual cocoons from batch images
- Achieves high precision even under varying lighting and dense packing
-
Stage 2 – Classification (EfficientNet-B0)
- Classifies each cocoon into one of six categories:
- Good (Qualified)
- Double, Crushed, Decayed, Pierced, Yellow-spotted (Defective)
- Classifies each cocoon into one of six categories:
-
Yield Estimation
- Uses industry-standard Renditta formula to estimate silk production from batch weight and quality distribution
-
Deployment
- Flask backend + HTML/CSS/JavaScript frontend for real-time use
- Generates detailed batch reports with grading and yield outputs
Cocoon_Classification/
├── app.py # Flask backend for model inference and API
├── app.js # Frontend logic (AJAX requests to backend)
├── index.html # Web interface for uploading and viewing results
├── style.css # Frontend styling
├── best_classifier.pth # Trained EfficientNet-B0 classification model
├── best_s_300.pt # Trained YOLOv8 segmentation model
├── uploads/ # Directory for uploaded cocoon images
└── requirements.txt # Python dependencies
- mAP@0.5: 96.1%
- Precision: 98.3%
- Recall: 94.9%
- F1-score: 96.6%
- Accuracy: 97%
- Defective Precision/Recall: 100% / 93%
- Qualified Precision/Recall: 94% / 100%
git clone https://github.com/omrajbhalke/Cocoon_Classification.git
cd Cocoon_Classificationpip install -r requirements.txtEnsure best_s_300.pt and best_classifier.pth are present in the root folder.
(If not, download from release assets or contact the maintainers.)
python app.pyThe backend will start at http://localhost:5000.
Open index.html in your browser or serve it via a local server.
- Total images: 3,068 cocoons
- Categories:
- Good – 773 samples
- Double – 468 samples
- Crushed – 681 samples
- Decayed – 474 samples
- Pierced – 207 samples
- Yellow-spotted – 465 samples
- Annotated using Roboflow for YOLOv8 segmentation training
- Python 3.x
- YOLOv8 – segmentation
- EfficientNet-B0 – classification
- PyTorch – deep learning framework
- Roboflow – dataset labeling & augmentation
- OpenCV – image preprocessing
- Flask – backend API
- HTML, CSS, JavaScript – frontend
The system predicts silk yield using Renditta:
Silk Yield (kg) = Total Cocoon Weight (kg) / Effective Renditta
Grades batches as:
- Grade A: > 85% qualified cocoons
- Grade B: 70–84%
- Grade C: 50–69%
- Substandard: < 50%
This project is licensed under the MIT License – see the LICENSE file for details.
- Omraj Ravindra Bhalke, Aryan Vats, Krrish Agrawal, Aditya Singh
For queries or collaboration:
- Email: omrajbhalke245@gmail.com
- GitHub: @omrajbhalke