Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AgriGemma-3n: On-Device Agricultural Intelligence

ChatGPT Image Aug 9, 2025, 04_26_09 AM

Hugging Face Demo License

πŸš€ Try It Now - No Installation Required!

β†’ Live Demo on Hugging Face Spaces

Experience AgriGemma-3n instantly in your browser - upload crop images, ask questions, get expert agricultural advice!

πŸ“± Run on Your Phone

πŸ“Ή Watch Mobile Demo (Text-only)

Phone Demo Video

πŸŽ₯ Click here to watch the phone demo on YouTube

iOS & Android Instructions:

  1. Download PocketPal AI app

  2. Search for the model in the app:

    Nadhari/AgriGemma-3n-E2B-it-gguf
    
  3. Download and start diagnosing - chat with it for instant expert advice!

πŸ’» Run on Desktop (Multimodal)

πŸ“Ή Watch Desktop Demo

Desktop Demo Video

πŸŽ₯ Click here to watch the Ollama demo on YouTube

Quick Start with Ollama

ollama run hf.co/Nadhari/AgriGemma-3n-E2B-it-gguf:Q8_0

Enhanced Experience with Ollamate

For multimodal chat with image and text support, use Ollamate - check their repository for detailed installation instructions.

Screenshot 2025-08-07 at 5 56 31

🌾 About AgriGemma-3n

The Challenge We Address

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.

Our Approach

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:

  1. Visual Understanding: Fine-tuned on a subset of 137,000 carefully curated images spanning 60 disease categories across 16 major crops
  2. Domain Expertise: Trained on a subset 1 million question-answer pairs covering diagnosis, prevention, and treatment strategies
  3. Conversational Intelligence: Capable of multi-turn discussions that mirror consultations with agricultural experts
  4. On-Device Deployment: Optimized to run on mobile devices with limited connectivity

πŸ€— Model Collection

Explore our complete model collection on Hugging Face:

β†’ AgriGemma-3n Collection

Available Models

🌟 Key Features

  • πŸ”¬ 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

πŸ› οΈ Technical Details

Training

Using Unsloth, we implemented a comprehensive LoRA-based fine-tuning strategy:

Screenshot 2025-08-09 at 3 05 35 Screenshot 2025-08-09 at 3 05 47
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.

Dataset

Screenshot 2025-08-09 at 4 18 48

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

πŸš€ Quick Start for Developers

Using Transformers

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)

Contributing

We welcome contributions!

πŸ“„ License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Acknowledgments

  • 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}
}

πŸ“¬ Contact

For questions, suggestions, or collaborations:


Made with ❀️

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages