No Internet? No Problem. How I Built a Crop Disease Detector for Rural India According to the article, KhetAI is a fully offline AI crop diagnostic tool built for Indian smallholder farmers, utilizing the Gemma 4 E4B model to analyze crop photos and answer questions without needing internet or cloud connectivity. The tool addresses the problem of farmers losing 20-30% of their harvest to unidentified diseases by providing diagnoses, treatments, and local remedies in multiple Indian languages directly on the user's device. The developer chose Gemma 4 because it handles vision, language, and multilingual responses in a single local model call, eliminating the need for separate systems or internet dependency. Every year, Indian farmers lose 20–30% of their harvest to crop diseases they cannot identify in time. Agricultural experts are concentrated in cities. Internet is unreliable in villages. And most existing tools are in English - a language most farmers don't read or speak. I built KhetAI to change that. KhetAI is a fully offline AI crop diagnostic tool for Indian smallholder farmers. A farmer: No internet needed. No cloud. No data ever leaves the device. Tech Stack: The result the farmer sees includes: ▶️ Demo Video: Watch on YouTube Real output from KhetAI - tested with a flower photo asking "What is it's name?": { "diagnosis": "Healthy crop - Black-eyed Susan Rudbeckia family ", "confidence": "Medium", "treatment": "Ensure soil remains consistently moist but not waterlogged", "Feed with balanced slow-release fertilizer at start of growing season" , "local remedies": "Add compost around the base to improve soil nutrients", "Light mulch layer of wood chips conserves moisture" , "prevention": "Avoid overhead watering - water the base instead", "Deadhead spent flowers regularly to encourage new blooms" , "escalate": false, "summary": "Your crop is healthy - maintain consistent watering and add compost for best yields" } Gemma 4 correctly identified the plant, gave practical advice, and suggested affordable local remedies - all in one response, in the farmer's chosen language. 🔗 GitHub Repository: https://github.com/Tech-Psycho95/KhetAI Run it yourself: 1. Pull the model ollama pull gemma4:e4b 2. Install dependencies pip install fastapi uvicorn python-multipart ollama 3. Start the backend uvicorn main:app --reload --port 8000 4. Open frontend Just double-click index.html in your browser The backend /analyze endpoint accepts a crop photo + question, converts the image to base64, and sends both to Gemma 4 via Ollama: response = ollama.chat model="gemma4:e4b", messages= { "role": "user", "content": f" Language: {language} \nFarmer's question: {question}", "images": image b64 , } , system=SYSTEM PROMPT, options={"temperature": 0.2}, The system prompt instructs Gemma 4 to always return a clean structured JSON object with diagnosis, treatment, remedies, prevention, and an escalation flag. Low temperature 0.2 ensures consistent, reliable output every time. I chose Gemma 4 E4B gemma4:e4b - here's why it was the right fit: Multimodal out of the box Gemma 4 processes both a crop photo and a text question together in a single API call. No separate vision pipeline, no extra model. The farmer uploads an image and asks their question — Gemma 4 analyzes both simultaneously. Runs fully offline via Ollama gemma4:e4b runs locally on a consumer GPU with no API key, no internet, and no subscription. This is non-negotiable for rural India deployment where connectivity is absent. Multilingual natively Gemma 4 handles Hindi, Kannada, Tamil, Telugu, Marathi, Bengali, Gujarati, and Punjabi without any translation layer. I simply pass the farmer's preferred language in the system prompt — the model responds in that language automatically. Why E4B over E2B or 31B Dense? Before Gemma 4, this project would have required a separate vision model, a separate language model, a translation layer, and a cloud API — meaning internet dependency. Gemma 4 collapses all four into a single local model call. KhetAI today runs on a single device for a single farmer. The roadmap: The infrastructure cost to serve 1,000 farmers? Zero. Because everything runs locally.