OpenCV + ResNet-50

Crumble Vision
Biscuit Tray Inspector

Real‑time defect detection on production trays. 99.7% accuracy across 735 cells.
Built with PyTorch, OpenCV, and deployed on edge.

GitHub Dataset Source
Total Cells
735
Correct Predictions
733
System Accuracy
99.7%
Defect‑Free Cells
284
Trays Processed
82

How it works

Each tray contains 9 biscuit cells. A fine‑tuned ResNet‑50 classifies each cell into one of four categories: No Defect, Shape, Object, Color. The system simulates a real production line: load a tray image, slice it, run inference, and compute a quality score.

1
Load tray
Tray image (3×3 grid) is loaded from assets/trays/
2
Slice cells
Each 224×224 crop is extracted using coordinates from tray_manifest.csv
3
ResNet‑50 inference
Pretrained model with custom FC layer outputs class probabilities
4
Quality score
Tray score = % of cells predicted as "Defect_No"

Training data provenance

Dataset note: This proof-of-concept was developed using an industrial biscuit defect dataset as an analogue for dessert surface quality inspection. While not identical to Crumble’s product line, the defect classes — shape, colour, foreign object, and acceptable product — closely map to real-world production-grade visual quality assurance workflows.

Dataset source: Kaggle – Industry Biscuit / Cookie Dataset

This allows rapid prototyping of the computer vision pipeline before deployment on a live top-down edge camera feed in production.

Confusion matrix & metrics

Tested on 82 unseen trays (735 cells). Only 2 errors total.

ClassPrecisionRecallF1Support
Defect_No1.001.001.00284
Defect_Shape1.001.001.00279
Defect_Object1.000.990.9995
Defect_Color0.991.000.9977
No
Shape
Object
Color
No
284
0
0
0
Shape
1
278
0
0
Object
0
0
94
1
Color
0
0
0
77

Inspect any tray

Select a tray from production. The left panel shows the actual tray image, the right panel shows predictions per cell.

Tray photo
Actual tray layout (from assets/trays/)
Click any cell to see ground truth

Insight: Tray scores range from 0% to 77%. Even with 99.7% per‑cell accuracy, the tray‑level metric exposes composition bias – a valuable signal for production line audits.

Run it yourself

# Clone the repo
git clone https://github.com/sobanmujtaba/crumble-vision
cd crumble-vision

# Install dependencies
pip install torch torchvision opencv-python pandas streamlit

# Generate trays from test set
python src/tray_simulator.py

# Run inference
python src/tray_inference.py

# Launch dashboard
streamlit run src/dashboard.py