CoolFace
Datasetpublic

ugahost991/plant-disease-detector

๐ŸŒฑ Plant Disease Detection - Vector Database This dataset contains pre-computed embeddings and FAISS index for plant disease detection using a RAG (Retrieval-Augmented Generation) approach. ๐Ÿ“Š Dataset Overview Total Images: 54,304 Disease Classes: 38 Embedding Model: ResNet-50 (Microsoft) Embedding Dimension: 2048 Index Type: FAISS IndexFlatIP (Cosine Similarity) ๐Ÿ“ Files File Size Description embeddings.npy ~440 MB Pre-computed 2048-Dโ€ฆ See the full description on the dataset page: https://huggingface.co/datasets/ugahost991/plant-disease-detector.

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes50downloads
Dataset Card

๐ŸŒฑ Plant Disease Detection - Vector Database

This dataset contains pre-computed embeddings and FAISS index for plant disease detection using a RAG (Retrieval-Augmented Generation) approach.

๐Ÿ“Š Dataset Overview

  • โ€”Total Images: 54,304
  • โ€”Disease Classes: 38
  • โ€”Embedding Model: ResNet-50 (Microsoft)
  • โ€”Embedding Dimension: 2048
  • โ€”Index Type: FAISS IndexFlatIP (Cosine Similarity)

๐Ÿ“ Files

FileSizeDescription
embeddings.npy~440 MBPre-computed 2048-D feature vectors for all images
metadata.json~8 MBImage paths, disease classes, and split information
faiss_index.bin~440 MBFAISS similarity search index

๐ŸŒฟ Supported Plant Diseases

The dataset covers 38 disease classes across multiple crops:

Tomato (10 classes)

  • โ€”Target Spot
  • โ€”Septoria Leaf Spot
  • โ€”Early Blight
  • โ€”Late Blight
  • โ€”Bacterial Spot
  • โ€”Leaf Mold
  • โ€”Spider Mites
  • โ€”Yellow Leaf Curl Virus
  • โ€”Mosaic Virus
  • โ€”Healthy

Pepper/Bell Pepper (2 classes)

  • โ€”Bacterial Spot
  • โ€”Healthy

Corn/Maize (4 classes)

  • โ€”Northern Leaf Blight
  • โ€”Common Rust
  • โ€”Cercospora Leaf Spot
  • โ€”Healthy

Potato (3 classes)

  • โ€”Early Blight
  • โ€”Late Blight
  • โ€”Healthy

Apple (4 classes)

  • โ€”Apple Scab
  • โ€”Black Rot
  • โ€”Cedar Apple Rust
  • โ€”Healthy

Grape (4 classes)

  • โ€”Black Rot
  • โ€”Esca (Black Measles)
  • โ€”Leaf Blight
  • โ€”Healthy

Cherry (2 classes)

  • โ€”Powdery Mildew
  • โ€”Healthy

Strawberry (2 classes)

  • โ€”Leaf Scorch
  • โ€”Healthy

Other Crops

  • โ€”Peach, Raspberry, Soybean, Squash, and more

๐Ÿš€ Usage

Load the Database

python
import numpy as np
import json
import faiss

# Load embeddings
embeddings = np.load('embeddings.npy')
print(f"Embeddings shape: {embeddings.shape}")  # (54304, 2048)

# Load metadata
with open('metadata.json', 'r') as f:
    metadata = json.load(f)
print(f"Total images: {len(metadata)}")

# Load FAISS index
index = faiss.read_index('faiss_index.bin')
print(f"Index size: {index.ntotal}")

Search for Similar Images

python
from transformers import AutoImageProcessor, AutoModel
from PIL import Image
import torch

# Load model
processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
model = AutoModel.from_pretrained("microsoft/resnet-50")

# Process query image
image = Image.open("plant_leaf.jpg")
inputs = processor(images=image, return_tensors="pt")

# Extract features
with torch.no_grad():
    outputs = model(**inputs)
    query_embedding = outputs.pooler_output.numpy()

# Normalize
query_embedding = query_embedding / np.linalg.norm(query_embedding)

# Search
k = 5  # Top 5 similar images
distances, indices = index.search(query_embedding, k)

# Get results
for i, idx in enumerate(indices[0]):
    similar_image = metadata[idx]
    print(f"{i+1}. {similar_image['class']} - Similarity: {distances[0][i]:.4f}")

Use with FastAPI

python
from fastapi import FastAPI, File, UploadFile
import numpy as np
import faiss

app = FastAPI()

# Load database on startup
embeddings = np.load('embeddings.npy')
metadata = json.load(open('metadata.json'))
index = faiss.read_index('faiss_index.bin')

@app.post("/predict")
async def predict(file: UploadFile = File(...)):
    # Extract features from uploaded image
    # ... (feature extraction code)
    
    # Search similar images
    distances, indices = index.search(query_embedding, k=5)
    
    # Majority voting for disease class
    classes = [metadata[idx]['class'] for idx in indices[0]]
    predicted_class = max(set(classes), key=classes.count)
    
    return {"disease": predicted_class, "confidence": distances[0][0]}

๐ŸŽฏ Use Cases

  1. 1.Plant Disease Detection: Identify diseases from leaf images
  2. 2.Agricultural Monitoring: Track crop health
  3. 3.Research: Study plant disease patterns
  4. 4.Education: Learn about plant diseases
  5. 5.Mobile Apps: Build plant disease detection apps

๐Ÿ”ฌ Technical Details

Embedding Extraction

  • โ€”Model: microsoft/resnet-50
  • โ€”Input Size: 224x224 pixels
  • โ€”Normalization: L2 normalization
  • โ€”Batch Size: 64 (GPU)
  • โ€”Processing Time: ~15 minutes on T4 GPU

FAISS Index

  • โ€”Type: IndexFlatIP (Inner Product)
  • โ€”Metric: Cosine Similarity
  • โ€”Dimension: 2048
  • โ€”Search Time: <10ms per query

๐Ÿ“ˆ Performance

  • โ€”Search Speed: Sub-10ms per query
  • โ€”Accuracy: High (based on similarity)
  • โ€”Scalability: Can handle millions of images
  • โ€”Memory: ~1.8 GB total

๐Ÿ› ๏ธ Building the Database

The database was built using:

python
# Extract features
from transformers import AutoImageProcessor, AutoModel
processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
model = AutoModel.from_pretrained("microsoft/resnet-50")

# Process images
embeddings = []
for image_path in image_paths:
    image = Image.open(image_path)
    inputs = processor(images=image, return_tensors="pt")
    outputs = model(**inputs)
    embedding = outputs.pooler_output.numpy()
    embeddings.append(embedding)

# Build FAISS index
embeddings = np.vstack(embeddings)
faiss.normalize_L2(embeddings)
index = faiss.IndexFlatIP(2048)
index.add(embeddings)

๐Ÿ“ฆ Integration

Download in Your App

python
from huggingface_hub import hf_hub_download

files = ['embeddings.npy', 'metadata.json', 'faiss_index.bin']

for filename in files:
    hf_hub_download(
        repo_id="ugahost991/plant-disease-detector",
        filename=filename,
        repo_type="dataset",
        local_dir="vector_store"
    )

๐Ÿ“„ License

MIT License - Free to use for commercial and non-commercial purposes

๐Ÿ™ Acknowledgments

  • โ€”Dataset: PlantVillage Dataset
  • โ€”Model: Microsoft ResNet-50
  • โ€”Framework: FAISS (Facebook AI)
  • โ€”Platform: Hugging Face Hub

๐Ÿ“ž Contact

Gaston Software Solutions LLP

For business inquiries, partnerships, or custom solutions, please contact us via email or visit our website.

๐Ÿ”— Related Resources

๐Ÿ“Š Statistics

json
{
  "total_images": 54304,
  "unique_classes": 38,
  "embedding_dimension": 2048,
  "index_type": "FAISS IndexFlatIP",
  "file_size_mb": 888,
  "build_time_minutes": 15,
  "gpu_used": "T4"
}

๐ŸŽ“ Citation

If you use this dataset, please cite:

bibtex
@dataset{plant_disease_embeddings_2024,
  title={Plant Disease Detection Vector Database},
  author={ugahost991},
  year={2024},
  publisher={Hugging Face},
  howpublished={\url{https://huggingface.co/datasets/ugahost991/plant-disease-detector}}
}

Built with โค๏ธ using ResNet-50, FAISS, and Hugging Face ๐ŸŒฑ๐Ÿš€