β Live Demo on Hugging Face Spaces
Experience AgriGemma-3n instantly in your browser - upload crop images, ask questions, get expert agricultural advice!
π₯ Click here to watch the phone demo on YouTube
-
Download PocketPal AI app
-
Search for the model in the app:
Nadhari/AgriGemma-3n-E2B-it-gguf -
Download and start diagnosing - chat with it for instant expert advice!
π₯ Click here to watch the Ollama demo on YouTube
ollama run hf.co/Nadhari/AgriGemma-3n-E2B-it-gguf:Q8_0For multimodal chat with image and text support, use Ollamate - check their repository for detailed installation instructions.
Every year, crop diseases destroy approximately 20-40% of global agricultural production, translating to economic losses exceeding $220 billion. For smallholder farmers in developing regions, these losses can mean the difference between prosperity and poverty. While agricultural experts exist, their reach is limited. For instance in Sub-Saharan Africa, the ratio of extension workers to farmers can be as low as 1:1000.
Traditional computer vision approaches to crop disease diagnosis, while technically impressive, fail to bridge the knowledge gap. They can identify diseases but cannot engage in the nuanced, conversational support farmers need: understanding symptoms, explaining disease progression, recommending context-appropriate treatments, and adapting advice to local conditions.
AgriGemma-3n transforms crop disease diagnosis from a classification problem into a comprehensive agricultural advisory system. Built on Gemma 3n's efficient architecture, our models combine:
- Visual Understanding: Fine-tuned on a subset of 137,000 carefully curated images spanning 60 disease categories across 16 major crops
- Domain Expertise: Trained on a subset 1 million question-answer pairs covering diagnosis, prevention, and treatment strategies
- Conversational Intelligence: Capable of multi-turn discussions that mirror consultations with agricultural experts
- On-Device Deployment: Optimized to run on mobile devices with limited connectivity
Explore our complete model collection on Hugging Face:
- AgriGemma-3n-E2B-it
- AgriGemma-3n-E4B-it
- GGUF Versions: Quantized models for mobile and edge deployment
- π¬ Accurate Disease Diagnosis: Identifies crop diseases from images with high precision
- π¬ Conversational Guidance: Provides detailed explanations and treatment recommendations
- π± Offline Capable: Works without internet connection after initial download
- π Fast Inference: Optimized for real-time responses on mobile devices
- π― Context-Aware: Adapts recommendations to local conditions and farming practices
Using Unsloth, we implemented a comprehensive LoRA-based fine-tuning strategy:
model = FastVisionModel.get_peft_model(
model,
finetune_vision_layers = True,
finetune_language_layers = True,
finetune_attention_modules = True,
finetune_mlp_modules = True,
r = 32,
lora_alpha = 32,
lora_dropout = 0.05,
bias = "none",
random_state = 3407,
target_modules = "all-linear",
)This approach enables the model to learn domain-specific visual features critical for accurate diagnosis while maintaining conversational abilities.
We use 9000 samples of the Crop Diseases Domain Multimodal Dataset The whole dataset contains:
- 137,000 images spanning 60 disease categories across 16 major crops
- 1 million Q&A pairs covering diagnosis, prevention, and treatment
- Expert-validated annotations
- Balanced distribution across crop types and diseases
from transformers import AutoProcessor, AutoModelForVision2Seq
from PIL import Image
# Load model and processor
model = AutoModelForVision2Seq.from_pretrained("Nadhari/AgriGemma-3n-E2B-it")
processor = AutoProcessor.from_pretrained("Nadhari/AgriGemma-3n-E2B-it")
# Load and process image
image = Image.open("path/to/crop_disease_image.jpg")
prompt = "What disease is affecting this plant and how can I treat it?"
# Generate response
inputs = processor(images=image, text=prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
response = processor.decode(outputs[0], skip_special_tokens=True)
print(response)We welcome contributions!
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- Crop Diseases Domain Multimodal Dataset
@article{liu2025multimodal,
title={A Multimodal Benchmark Dataset and Model for Crop Disease Diagnosis},
author={Liu, X. and Zhou, J. and others},
journal={arXiv preprint arXiv:2503.06973},
year={2025}
}For questions, suggestions, or collaborations:
- Open an issue on GitHub
- Reach out on Hugging Face
