File size: 4,065 Bytes
fa2f0df
 
 
 
 
 
 
 
 
 
0570906
 
fa2f0df
 
 
 
 
 
 
 
 
ca151da
fa2f0df
ca151da
fa2f0df
ca151da
fa2f0df
ca151da
0570906
ca151da
 
 
 
0570906
ca151da
0570906
ca151da
0570906
ca151da
 
0570906
 
ca151da
0570906
ca151da
0570906
ca151da
 
0570906
ca151da
0570906
ca151da
0570906
 
ca151da
0570906
 
 
 
 
 
 
 
fa2f0df
 
0570906
fa2f0df
0570906
fa2f0df
ca151da
fa2f0df
0570906
 
 
 
ca151da
 
0570906
ca151da
0570906
 
 
ca151da
fa2f0df
 
ca151da
0570906
ca151da
0570906
 
 
 
ca151da
0570906
 
 
 
 
ca151da
0570906
fa2f0df
ca151da
0570906
ca151da
fa2f0df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca151da
fa2f0df
ca151da
 
 
 
fa2f0df
 
 
ca151da
 
 
 
0570906
ca151da
0570906
ca151da
0570906
 
 
ca151da
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
---
license: mit
library_name: rfdetr
tags:
  - plant-disease
  - disease-detection
  - agriculture
  - computer-vision
  - object-detection
  - rf-detr
  - precision-agriculture
  - crop-health
datasets:
  - plant-disease-faxnj
metrics:
  - map
pipeline_tag: object-detection
---

# CropScan - Plant Disease Detection Model

CropScan is a plant disease detection model based on RF-DETR, designed to help farmers quickly identify health issues in their crops.

## Why CropScan?

Farming is hard work. Farmers face countless daily challenges: unpredictable weather, economic pressures, and most critically, crop diseases that can devastate entire harvests in just a few days.

**CropScan was built to:**

- **Help farmers** detect diseases early, before they spread
- **Reduce crop losses** through rapid and targeted intervention
- **Optimize treatment usage** by precisely identifying affected areas
- **Democratize access** to advanced diagnostic tools, once reserved for experts

Whether you're a small-scale farmer or a large producer, CropScan gives you the power to protect your crops with artificial intelligence.

## Detection Example

| Original Image | Detection Result |
|:--------------:|:----------------:|
| ![Original](examples/original.png) | ![Detection](examples/detection_result.png) |

The left image shows a leaf with disease symptoms. The right image shows CropScan's result: each diseased region is identified and segmented with precision using SAM2 integration.

## Technical Details

| Specification | Value |
|--------------|-------|
| **Architecture** | RF-DETR (medium) |
| **Task** | Object Detection / Disease Localization |
| **Performance** | mAP@50: 0.502 |
| **Model Size** | 134 MB |
| **Format** | PyTorch (.pth) |

## Usage

### Installation

```bash
pip install rfdetr torch torchvision
```

### Inference

```python
import torch
from rfdetr import RFDETRBase
from PIL import Image

# Load the model
model = RFDETRBase()
checkpoint = torch.load("checkpoint_best_total.pth", map_location="cpu")
model.load_state_dict(checkpoint)
model.eval()

# Load an image
image = Image.open("your_image.jpg")

# Run detection
with torch.no_grad():
    predictions = model(image)

# predictions contains bounding boxes of diseased regions
```

### SAM2 Integration (Recommended)

For precise segmentation masks instead of bounding boxes, combine CropScan with SAM2:

```python
from sam2.sam2_image_predictor import SAM2ImagePredictor

# Use CropScan boxes as prompts for SAM2
predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-small")
predictor.set_image(image)

for box in predictions.boxes:
    masks, scores, _ = predictor.predict(box=box, multimask_output=False)
    # masks contains the precise segmentation mask
```

## Training Data

This model was trained on the Plant Disease dataset from Roboflow Universe, containing images of leaves with various diseases.

```bibtex
@misc{plant-disease-faxnj_dataset,
    title = { Plant disease Dataset },
    type = { Open Source Dataset },
    author = { Project },
    howpublished = { \url{ https://universe.roboflow.com/project-oklwn/plant-disease-faxnj } },
    url = { https://universe.roboflow.com/project-oklwn/plant-disease-faxnj },
    journal = { Roboflow Universe },
    publisher = { Roboflow },
    year = { 2024 },
    month = { feb },
}
```

## Use Cases

- **Precision Agriculture**: Automated crop monitoring via drone or fixed camera
- **Field Diagnosis**: Mobile app for rapid disease identification
- **Agricultural Research**: Study of plant disease propagation
- **Education**: Teaching tool for agronomy students

## Limitations

- Trained primarily on PlantVillage-style images
- Best performance on individual leaf images with clear backgrounds
- SAM2 recommended for precise segmentation masks
- Does not replace expert agronomist diagnosis

## License

This model is distributed under the MIT license. You are free to use, modify, and distribute it for commercial or non-commercial purposes.

---

*Built with passion to support those who feed us.*