YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

🌾 AgriVision-Gemma3n

View Inference Demo Notebook on Kaggle β†’

An offline-first, multimodal agricultural assistant built on Google’s Gemma 3n architecture. Fine-tuned on CDDM-Bench and Agri-LLaVA datasets, this 4-bit quantized model runs entirely on-device to diagnose crop diseases from images and answer farm-related questionsβ€”no internet required.


πŸ“– Model Card

  • Hub repo: shreyansh24/AgriVision-gemma3n
  • Base architecture: Gemma 3n (4-bit quantized; many-in-1 submodel)
  • Intended use: On-device crop disease diagnosis & agricultural advisory
  • License: MIT License

πŸš€ Installation

pip install --upgrade transformers timm torch pillow requests

For best performance, run on a machine with CPU+30GB RAM or GPU and PyTorch 2.x or later.


πŸ› οΈ Quick Start

import torch
from PIL import Image
import requests
from transformers import AutoModelForCausalLM, AutoProcessor

# 1. Load the model
hub_repo_id = "shreyansh24/AgriVision-gemma3n"
model = AutoModelForCausalLM.from_pretrained(
    hub_repo_id,
    torch_dtype=torch.float32,
    device_map="auto",
    trust_remote_code=True,
)
processor = AutoProcessor.from_pretrained(hub_repo_id)

# 2. Load an example image
image_url = "https://extension.psu.edu/media/catalog/product/8/8/88a3d35ed41ece903afa179a81c33c13.jpeg"
image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB")

# 3. Prepare prompt
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": image},
            {"type": "text", "text": "Which plant leaf is this, what disease does it have, and describe it in detail?"},
        ],
    }
]

# 4. Tokenize and format
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
batch = processor(text=inputs, images=[[image]], return_tensors="pt")

# 5. Generate response
output = model.generate(**batch)
decoded = processor.decode(output[0], skip_special_tokens=True)

# 6. Print final response
final_answer = decoded.split("model\n")[-1].strip()
print("\nModel's Reply:\n", final_answer)

πŸ”Ή Performance & Hardware

Metric Value
Accuracy (CDDM test set) ~87%
Avg. Response time ~20 seconds (CPU)
Model size ~4.9 GB (4-bit)

πŸ™‹ Contributing

Contributions and feedback are welcome. For questions or suggestions, feel free to open an issue or discussion on GitHub.


⚠️ Disclaimer

This model is for research and demonstration purposes only. Always consult with a certified agronomist or expert before taking agricultural action based on AI outputs.


Built for the Google Gemma 3n Impact Challenge ✨

Downloads last month
-
Safetensors
Model size
5B params
Tensor type
F16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for shreyansh24/AgriVision-gemma3n

Quantizations
1 model