File size: 12,285 Bytes
38a8dcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
---
license: mit
task_categories:
- object-detection
- image-segmentation
- image-classification
language:
- en
tags:
- agriculture
- computer-vision
- fruit-detection
- instance-segmentation
- precision-agriculture
- ripeness-assessment
- agricultural-robotics
size_categories:
- 1K<n<10K
---

# SmartHarvest: Multi-Species Fruit Ripeness Detection Dataset

## Dataset Description

**SmartHarvest** is a comprehensive multi-species fruit ripeness detection and segmentation dataset designed for precision agriculture applications. The dataset contains high-resolution images of fruits in natural garden environments with detailed polygon-based instance segmentation annotations and ripeness classifications.

### Key Features
- **8 fruit species**: Apple, cherry, cucumber, strawberry, tomato, plum, raspberry, pepper
- **Multi-class ripeness**: Ripe, unripe, spoiled, plus obscured category
- **Instance segmentation**: Polygon annotations with 3-126 vertices per instance
- **Real-world conditions**: Natural lighting, occlusion, and clustering challenges
- **Expert validation**: Agricultural specialist annotation review and quality control

### Dataset Statistics
- **Total images**: 486 high-resolution images
- **Total annotations**: 6,984 individual fruit instances  
- **Average annotations per image**: 14.4 instances
- **Polygon complexity**: 14.1 ± 9.8 vertices per annotation
- **Occlusion coverage**: 53.8% partially obscured instances
- **Image resolution**: Resized and padded to 1200×1200 pixels

## Supported Tasks

### Primary Tasks
- **Object Detection**: Fruit localization with species and ripeness classification
- **Instance Segmentation**: Pixel-level fruit boundary delineation
- **Multi-class Classification**: Combined species and ripeness state prediction

### Agricultural Applications
- **Robotic Harvesting**: Automated fruit picking with quality assessment
- **Yield Prediction**: Crop monitoring and harvest optimization
- **Quality Control**: Post-harvest sorting and grading
- **Precision Agriculture**: Species-specific crop management

## Dataset Structure

### Data Fields

Each sample contains:

```python
{
    'image': PIL.Image,                    # Original fruit image
    'image_id': int,                       # Unique image identifier
    'annotations': [
        {
            'id': int,                     # Unique annotation ID
            'category_id': int,            # Species-ripeness category
            'species': str,                # Fruit species name
            'ripeness': str,               # Ripeness state
            'bbox': [x, y, width, height], # Bounding box coordinates
            'segmentation': [[x1,y1, ...]], # Polygon vertices
            'area': float,                 # Annotation area in pixels²
            'iscrowd': bool,               # Multiple objects flag
            'visibility': str              # Occlusion status
        }
    ],
    'metadata': {
        'source': str,                     # Image source information
        'capture_conditions': str,         # Lighting and environment
        'quality_score': float            # Annotation quality metric
    }
}
```

### Category Mapping

| Category ID | Species | Ripeness | Description |
|-------------|---------|-----------|-------------|
| 0 | background | - | Background class |
| 1 | apple | unripe | Green/immature apples |
| 2 | apple | ripe | Harvest-ready apples |
| 3 | apple | spoiled | Overripe/damaged apples |
| 4 | cherry | unripe | Immature cherries |
| 5 | cherry | ripe | Harvest-ready cherries |
| 6 | cherry | spoiled | Overripe cherries |
| 7 | cucumber | unripe | Small/immature cucumbers |
| 8 | cucumber | ripe | Harvest-ready cucumbers |
| 9 | cucumber | spoiled | Overripe cucumbers |
| 10 | strawberry | unripe | White/green strawberries |
| 11 | strawberry | ripe | Red strawberries |
| 12 | strawberry | spoiled | Overripe strawberries |
| 13 | tomato | unripe | Green tomatoes |
| 14 | tomato | ripe | Red tomatoes |
| 15 | tomato | spoiled | Overripe tomatoes |

*Additional species (plums, raspberries, peppers) in development*

## Dataset Splits

### Current Distribution
- **Total**: 486 images with 6,984 annotations
- **Apple subset**: 98 images, 2,582 annotations  
- **Cherry subset**: 86 images, 969 annotations
- **Tomato subset**: 94 images, 1,572 annotations
- **Strawberry subset**: 111 images, 1,397 annotations
- **Cucumber subset**: 97 images, 464 annotations

### Recommended Splits
For reproducible experiments, we recommend:
- **Training**: 80% (389 images)
- **Validation**: 20% (97 images)
- **Stratification**: Balanced across species and ripeness states

## Data Collection and Annotation

### Collection Methodology
- **Sources**: Natural garden environments, orchard partnerships
- **Geographic coverage**: Multiple growing regions to reduce bias
- **Temporal coverage**: Different seasons and growth stages  
- **Lighting conditions**: Natural outdoor lighting with time-of-day variation
- **Image quality**: High-resolution captures with professional equipment

### Annotation Protocol
- **Tool**: VGG Image Annotator (VIA) with custom configuration
- **Annotators**: Trained computer vision researchers with agricultural consultation
- **Quality control**: 25% overlap for inter-annotator agreement (κ > 0.85)
- **Expert review**: 10% agricultural specialist validation
- **Polygon precision**: Minimum 8 vertices, detailed boundary delineation

### Species-Specific Criteria

#### Color-Based Ripeness (Apples, Tomatoes, Cherries, Peppers)
- **Ripe**: >75% characteristic color coverage
- **Unripe**: <25% color development  
- **Spoiled**: Brown/black discoloration, visible mold

#### Size-Based Ripeness (Cucumbers, Pears)
- **Ripe**: 80-100% of variety-specific size range
- **Unripe**: <80% expected size
- **Spoiled**: Yellowing, soft spots, wrinkled skin

#### Texture-Based Ripeness (Strawberries, Raspberries)
- **Ripe**: Uniform color, firm but yielding texture
- **Unripe**: White/green areas, hard texture
- **Spoiled**: Soft spots, mold, collapsed structure

## Usage Examples

### Loading the Dataset

```python
from datasets import load_dataset

# Load complete dataset
dataset = load_dataset("TheCoffeeAddict/SmartHarvest")

# Load specific split
train_data = load_dataset("TheCoffeeAddict/SmartHarvest", split="train")

# Access sample
sample = dataset['train'][0]
image = sample['image']
annotations = sample['annotations']
```

### PyTorch Integration

```python
import torch
from torch.utils.data import Dataset
from torchvision import transforms
from datasets import load_dataset

class SmartHarvestDataset(Dataset):
    def __init__(self, split="train", transform=None):
        self.dataset = load_dataset("TheCoffeeAddict/SmartHarvest", split=split)
        self.transform = transform
        
    def __len__(self):
        return len(self.dataset)
        
    def __getitem__(self, idx):
        sample = self.dataset[idx]
        image = sample['image']
        target = {
            'boxes': torch.tensor(sample['bboxes']),
            'labels': torch.tensor(sample['labels']),
            'masks': torch.tensor(sample['masks'])
        }
        
        if self.transform:
            image = self.transform(image)
            
        return image, target

# Usage
transform = transforms.Compose([
    transforms.Resize((800, 800)),
    transforms.ToTensor(),
])

dataset = SmartHarvestDataset(split="train", transform=transform)
```

### Data Visualization

```python
import matplotlib.pyplot as plt
import numpy as np

def visualize_sample(sample):
    image = sample['image']
    annotations = sample['annotations']
    
    fig, ax = plt.subplots(1, 1, figsize=(12, 8))
    ax.imshow(image)
    
    for ann in annotations:
        # Draw bounding box
        x, y, w, h = ann['bbox']
        rect = plt.Rectangle((x, y), w, h, fill=False, color='red', linewidth=2)
        ax.add_patch(rect)
        
        # Add label
        species = ann['species']
        ripeness = ann['ripeness']
        ax.text(x, y-5, f"{species}-{ripeness}", color='red', fontsize=10)
    
    ax.set_title("SmartHarvest Sample Annotation")
    plt.show()

# Visualize first sample
sample = dataset['train'][0]
visualize_sample(sample)
```

## Baseline Results

### Model Performance (Apple-Cherry Subset)

Trained Mask R-CNN with ResNet-50 backbone:

| Metric | Value | Description |
|--------|-------|-------------|
| **AP@0.5** | **22.49%** | Average precision at IoU=0.5 |
| **AP@0.75** | **7.98%** | Average precision at IoU=0.75 |
| **COCO mAP** | **60.63%** | Mean AP across IoU 0.5-0.95 |

### Per-Class Performance

| Class | AP@0.5 | Notes |
|-------|--------|--------|
| Apple-Ripe | 10.45% | Challenging due to color variation |
| Apple-Unripe | 25.00% | Better defined characteristics |
| Apple-Spoiled | **32.60%** | Distinctive visual features |
| Cherry-Ripe | 18.20% | Small size challenges |
| Cherry-Unripe | 17.10% | Consistent with apple pattern |
| Cherry-Spoiled | **31.56%** | Best performance per species |

*Code available at: https://github.com/Maksim3l/SmartHarvest*

## Considerations for Use

### Strengths
- **Real-world applicability**: Natural garden conditions with authentic challenges
- **Multi-species coverage**: Broad agricultural applicability  
- **Expert validation**: Agricultural specialist involvement in annotation
- **Detailed annotations**: Polygon-level segmentation for precise localization
- **Ripeness granularity**: Practical quality assessment categories

### Limitations
- **Geographic bias**: Limited to specific growing regions
- **Seasonal bias**: Collection timing affects ripeness distribution
- **Equipment bias**: Single camera system characteristics
- **Scale limitations**: Limited images per species for production deployment
- **Class imbalance**: Varying representation across ripeness states

### Recommended Applications
- **Research benchmarking**: Computer vision method evaluation
- **Algorithm development**: Detection and segmentation model training
- **Educational use**: Agricultural computer vision teaching
- **Prototype development**: Proof-of-concept agricultural systems

### Usage Considerations
- **Data augmentation**: Recommended for training robustness
- **Cross-validation**: Stratified splits to maintain species balance
- **Evaluation metrics**: Use agricultural-relevant metrics beyond standard CV measures
- **Deployment testing**: Validate on target agricultural environments

## Ethical Considerations

### Data Privacy
- **Image sources**: Publicly available images or consent-obtained private collections
- **Location privacy**: No GPS coordinates or specific farm identifiers included
- **Farmer consent**: Proper permissions obtained for orchard data collection

### Bias and Fairness
- **Geographic diversity**: Active efforts to include multiple growing regions
- **Seasonal representation**: Multiple collection periods to reduce temporal bias
- **Equipment standardization**: Documentation of capture conditions for bias awareness

### Environmental Impact
- **Sustainable agriculture**: Supporting precision farming for reduced resource use
- **Technology access**: Open-source approach for global accessibility
- **Local adaptation**: Encouragement of regional dataset development

## Citation

If you use this dataset in your research, please cite:

```bibtex
@inproceedings{loknar2025comprehensive,
    title={Comprehensive Multi-Species Fruit Ripeness Dataset Construction: From Eight-Species Collection to Focused Apple-Cherry Detection},
    author={Loknar, Maksim and Mlakar, Uroš},
    booktitle={Student Computing Research Symposium},
    year={2025},
    organization={University of Maribor},
    url={https://huggingface.co/datasets/TheCoffeeAddict/SmartHarvest}
}
```

## Dataset Card Contact

**Authors**: Maksim Loknar, Uroš Mlakar  
**Institution**: Faculty of Electrical Engineering and Computer Science, University of Maribor, Slovenia  
**Email**: maksim.loknar@student.um.si, uros.mlakar@um.si  
**Project Page**: https://github.com/Maksim3l/SmartHarvest

For questions about dataset usage, additional species requests, or collaboration opportunities, please open an issue in the GitHub repository or contact the authors directly.