File size: 3,905 Bytes
efb1801 be3d87b efb1801 be3d87b efb1801 be3d87b efb1801 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
---
tags:
- image-classification
- efficientnet
- strawberry
- agriculture
- robotics
- computer-vision
- pytorch
- ripeness-classification
license: mit
datasets:
- custom
language:
- python
pretty_name: EfficientNet-B0 Strawberry Ripeness Classification
description: EfficientNet-B0 model for detailed strawberry ripeness classification with 4-class output
pipeline_tag: image-classification
---
# EfficientNet-B0 Strawberry Ripeness Classification Model
This directory contains the EfficientNet-B0 model for detailed strawberry ripeness classification, the second stage of the Strawberry Picker AI system.
## π Model Performance
| Metric | Value |
|--------|-------|
| **Overall Accuracy** | 91.94% |
| **Macro F1-Score** | 0.92 |
| **Weighted F1-Score** | 0.93 |
| **Model Size** | 56MB |
| **Input Size** | 128x128 |
### Class Performance (Validation Set)
| Class | Precision | Recall | F1-Score | Support |
|-------|-----------|--------|----------|---------|
| unripe | 0.92 | 0.89 | 0.91 | 163 |
| partially-ripe | 0.88 | 0.91 | 0.89 | 135 |
| ripe | 0.94 | 0.93 | 0.93 | 124 |
| overripe | 0.96 | 0.95 | 0.95 | 422 |
## π― Ripeness Classes
| Class | Description | Pick? |
|-------|-------------|-------|
| **unripe** | Green, hard texture | β |
| **partially-ripe** | Pink/red, firm | β |
| **ripe** | Bright red, soft | β
|
| **overripe** | Dark red/brown, mushy | β |
## π Quick Start
### Installation
```bash
pip install torch torchvision pillow
```
### Python Inference
```python
import torch
from torchvision import transforms
from PIL import Image
# Load model
model = torch.load('best_ripeness_classifier.pth', map_location='cpu')
model.eval()
# Preprocessing
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
# Load and preprocess image
image = Image.open('strawberry_crop.jpg')
input_tensor = transform(image).unsqueeze(0)
# Inference
with torch.no_grad():
output = model(input_tensor)
probabilities = torch.softmax(output, dim=1)
predicted_class = torch.argmax(probabilities, dim=1).item()
confidence = probabilities[0][predicted_class].item()
class_names = ['unripe', 'partially-ripe', 'ripe', 'overripe']
print(f"Ripeness: {class_names[predicted_class]} ({confidence:.2f})")
```
## π Files
- `best_ripeness_classifier.pth` - PyTorch model weights
- `training_summary.md` - Detailed training information
## π― Use Cases
- **Automated Harvesting**: Second stage ripeness verification
- **Quality Control**: Precise ripeness assessment for sorting
- **Agricultural Research**: Ripeness pattern analysis
## π§ Technical Details
- **Architecture**: EfficientNet-B0
- **Input Size**: 128x128 RGB
- **Output**: 4-class probabilities
- **Training Dataset**: 844 cropped strawberry images
- **Training Epochs**: 50 (early stopping)
- **Batch Size**: 8
- **Optimizer**: AdamW
- **Learning Rate**: 0.002 (cosine annealing)
## π Training Configuration
```python
# Model Architecture
model = EfficientNet.from_pretrained('efficientnet-b0')
model._fc = nn.Linear(model._fc.in_features, 4)
# Training Setup
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.AdamW(model.parameters(), lr=0.002)
scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=50)
```
## π Related Components
- [Detection Model](../detection/) - First stage for strawberry localization
- [Training Repository](https://github.com/theonegareth/strawberryPicker)
## π Documentation
- [Full System Documentation](https://github.com/theonegareth/strawberryPicker)
- [Training Summary](training_summary.md)
## π License
MIT License - See main repository for details.
---
**Model Version**: 1.0.0
**Training Date**: November 2025
**Part of**: Strawberry Picker AI System
|