nexusbert's picture
Fix Hugging Face metadata
52d0c20
|
Raw
History Blame Contribute Delete
4.29 kB

A newer version of the Gradio SDK is available: 6.24.0

Upgrade
metadata
title: Tomato Blight Classifier
emoji: πŸ…
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 4.26.0
python_version: '3.10'
app_file: app.py
pinned: false
license: mit
short_description: Tomato disease classifier with Gradio

πŸ… Tomato Disease Classifier

A Gradio-based web application that uses a Vision Transformer (ViT) model from Hugging Face to classify tomato leaf diseases in real-time.

Features

  • Real-time Classification: Upload tomato leaf images to instantly identify diseases
  • Three Disease Categories:
    • 🟒 Healthy: No disease detected
    • πŸ”΄ Early Blight: Fungal disease in early stages (easier to treat)
    • πŸ”΄πŸ”΄ Late Blight: Advanced fungal disease (more severe, requires immediate action)
  • Confidence Scores: View the model's confidence level for each prediction
  • Visual Interface: Easy-to-use web interface powered by Gradio
  • Pre-trained Model: Uses nexusbert/tomato-disease-vit from Hugging Face

πŸš€ Quick Start

Simply upload an image of a tomato leaf and click "Classify Disease" to get instant predictions!

Installation

  1. Clone or use this space directly on Hugging Face

  2. Create a virtual environment (if running locally):

python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

Run the application:

python app.py

The application will launch a web interface (typically at http://localhost:7860) where you can:

  1. Upload an image of a tomato leaf
  2. Click "Classify Disease" to get predictions
  3. View confidence scores for each disease category
  4. See a bar chart showing the prediction distribution

Model Details

  • Model Name: nexusbert/tomato-disease-vit
  • Architecture: Vision Transformer (ViT)
  • Task: Image Classification
  • Input: RGB images of tomato leaves
  • Output: Classification scores for disease categories

How It Works

The classifier uses two approaches:

  1. Pipeline API: For quick, simple predictions
from transformers import pipeline
classifier = pipeline("image-classification", model="nexusbert/tomato-disease-vit")
results = classifier("path/to/tomato_image.jpg")
  1. Direct Model & Processor: For more detailed control
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("nexusbert/tomato-disease-vit")
model = AutoModelForImageClassification.from_pretrained("nexusbert/tomato-disease-vit")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)

Requirements

  • Python 3.8+
  • PyTorch
  • Transformers
  • Gradio
  • CUDA (optional, for GPU acceleration)

See requirements.txt for complete dependency list.

Project Structure

tomato_blight_classifier/
β”œβ”€β”€ app.py              # Main Gradio application
β”œβ”€β”€ requirements.txt    # Python dependencies
└── README.md          # This file

Performance Notes

  • First run will download the model (takes a few minutes)
  • Subsequent runs are faster as the model is cached
  • GPU recommended for faster inference (CUDA)
  • CPU inference is supported but slower

πŸ” Example Workflow

  1. Prepare: Take a clear photo of a tomato leaf (both sides work)
  2. Upload: Click the upload area and select your image
  3. Analyze: Click "Classify Disease"
  4. Review: Check the predictions and confidence scores

Troubleshooting

Model Download Issues

If the model fails to download, ensure you have internet connection and sufficient disk space (~300MB).

Memory Issues

If you encounter out-of-memory errors, close other applications or use CPU inference.

Slow Performance

Enable GPU acceleration by installing PyTorch with CUDA support.

Model Source

This classifier uses the pre-trained model: nexusbert/tomato-disease-vit

View Model on Hugging Face

References

License

MIT License - See LICENSE file for details