Spaces:
Sleeping
Sleeping
Commit
Β·
2086b03
1
Parent(s):
5a4607e
π Fix Hugging Face README config
Browse files
README.md
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: "CropGuard: Leaf Disease Detector"
|
3 |
+
colorFrom: green
|
4 |
+
colorTo: indigo
|
5 |
+
sdk: gradio
|
6 |
+
sdk_version: "4.14.0"
|
7 |
+
app_file: app.py
|
8 |
+
pinned: false
|
9 |
+
---
|
10 |
+
|
11 |
+
# CropGuard: Leaf Disease Detector
|
12 |
+
|
13 |
+
**CropGuard** is a lightweight, deployable machine learning app that detects **leaf diseases** in **Potato**, **Tomato**, and **Grape** plants from user-uploaded or captured images.
|
14 |
+
|
15 |
+
Built using **PyTorch**, **Gradio**, **Docker**, and **Hugging Face Spaces**, it provides the following capabilities:
|
16 |
+
|
17 |
+
- Upload or capture a leaf image
|
18 |
+
- Predict plant health status
|
19 |
+
- Identify likely disease (if any)
|
20 |
+
- Visualize model attention using **GradCAM++** heatmaps
|
21 |
+
- Provide quick disease information and treatment suggestions
|
22 |
+
|
23 |
+
---
|
24 |
+
|
25 |
+
## Project Structure
|
26 |
+
|
27 |
+
```
|
28 |
+
CropGuard/
|
29 |
+
βββ app.py # Gradio app
|
30 |
+
βββ Dockerfile # Docker container definition
|
31 |
+
βββ requirements.txt # Python dependencies
|
32 |
+
βββ notebooks/ # Step-by-step project development
|
33 |
+
β βββ 01_data_preprocessing.ipynb
|
34 |
+
β βββ 02_model_training.ipynb
|
35 |
+
β βββ 03_model_validation.ipynb
|
36 |
+
β βββ 04_gradcam_visualization.ipynb
|
37 |
+
βββ src/ # Source code (organized into modules)
|
38 |
+
β βββ app/
|
39 |
+
β βββ data/
|
40 |
+
β βββ model/
|
41 |
+
β βββ utils/
|
42 |
+
βββ sample_images/ # Few test images (optional for demo)
|
43 |
+
βββ disease_info.json # Disease descriptions
|
44 |
+
βββ README.md # (this file)
|
45 |
+
```
|
46 |
+
|
47 |
+
---
|
48 |
+
|
49 |
+
## Notebooks Overview
|
50 |
+
|
51 |
+
| Notebook | Purpose |
|
52 |
+
|:-|:-|
|
53 |
+
| `01_data_preprocessing.ipynb` | Download PlantVillage dataset, clean and split into train/val/test sets |
|
54 |
+
| `02_model_training.ipynb` | Set up data augmentation, train MobileNetV2 model, monitor training curves |
|
55 |
+
| `03_model_validation.ipynb` | Evaluate model performance, generate metrics, confusion matrix |
|
56 |
+
| `04_gradcam_visualization.ipynb` | Generate GradCAM++ heatmaps to visualize model focus |
|
57 |
+
|
58 |
+
---
|
59 |
+
|
60 |
+
## How to Run Locally
|
61 |
+
|
62 |
+
1. **Clone the repo:**
|
63 |
+
|
64 |
+
```bash
|
65 |
+
git clone https://github.com/YOUR_USERNAME/CropGuard.git
|
66 |
+
cd CropGuard
|
67 |
+
```
|
68 |
+
|
69 |
+
2. **Create a virtual environment:**
|
70 |
+
|
71 |
+
```bash
|
72 |
+
python3 -m venv .venv
|
73 |
+
source .venv/bin/activate
|
74 |
+
```
|
75 |
+
|
76 |
+
3. **Install dependencies:**
|
77 |
+
|
78 |
+
```bash
|
79 |
+
pip install --upgrade pip
|
80 |
+
pip install -r requirements.txt
|
81 |
+
```
|
82 |
+
|
83 |
+
4. **Launch the app:**
|
84 |
+
|
85 |
+
```bash
|
86 |
+
python app.py
|
87 |
+
```
|
88 |
+
|
89 |
+
It will be available at [http://localhost:7860](http://localhost:7860).
|
90 |
+
|
91 |
+
---
|
92 |
+
|
93 |
+
## How to Build and Run with Docker
|
94 |
+
|
95 |
+
```bash
|
96 |
+
docker build -t cropguard-app .
|
97 |
+
docker run -p 7860:7860 cropguard-app
|
98 |
+
```
|
99 |
+
|
100 |
+
---
|
101 |
+
|
102 |
+
## Web Deployment
|
103 |
+
|
104 |
+
Easily deployable on:
|
105 |
+
|
106 |
+
- Hugging Face Spaces
|
107 |
+
- DockerHub
|
108 |
+
|
109 |
+
---
|
110 |
+
|
111 |
+
## Sample Images
|
112 |
+
|
113 |
+
We provide a few **sample leaf images** in the `sample_images/` directory so users can test the model even without their own images.
|
114 |
+
|
115 |
+
---
|
116 |
+
|
117 |
+
## License
|
118 |
+
|
119 |
+
MIT License.
|
120 |
+
|
121 |
+
---
|
122 |
+
|
123 |
+
## Acknowledgments
|
124 |
+
|
125 |
+
- **Dataset:** [PlantVillage Dataset](https://www.kaggle.com/datasets/mohitsingh1804/plantvillage)
|
126 |
+
- **Base Model:** [MobileNetV2 (pretrained on ImageNet)](https://arxiv.org/abs/1801.04381)
|
127 |
+
- **Visualization:** GradCAM++
|
128 |
+
|
129 |
+
---
|
130 |
+
|
131 |
+
## Author
|
132 |
+
|
133 |
+
Made by **[Arka Mitra](https://github.com/mitraarka27)** Β© 2025.
|
134 |
+
|
135 |
+
---
|
136 |
+
|