Skip to the content.

Hackathon Contest

Youth Digital Citizen Challenge 2025 Theme: AI for Climate: Twin Transition in Action

This project is developed as part of Youth Digital Citizen Challenge 2025, focusing on applying Artificial Intelligence to address climate-related challenges, particularly in agriculture and food security.

The solution aligns with the Twin Transition approach:

Rice AI Backend – Disease Detection & Outbreak Risk API

Problem Statement

Rice farmers often face significant crop losses due to late detection of rice diseases and lack of early warning systems for disease outbreaks. Traditional inspection methods are manual, time-consuming, and do not scale well across large farming regions.

Additionally, farmers usually lack actionable information after detecting a disease, such as:

Solution Overview

Rice AI Backend is a FastAPI-based AI service that provides:

Image-based rice disease detection using a deep learning model (DINOv2)

Outbreak risk prediction based on recent disease reports and environmental signals

Disease knowledge retrieval (RAG) to suggest symptoms and treatment information

RESTful APIs designed for easy integration with mobile or web applications

The system is designed for hackathon deployment, rapid integration, and future scalability.

Key Features

Project Structure

.
├── main.py                    # FastAPI entry point
├── api/                        # API routes
│   ├── disease.py              # Disease detection endpoints
│   ├── outbreak.py             # Outbreak prediction endpoints
│   ├── rag.py                  # Disease knowledge (RAG)
│   └── health.py               # Health check
├── services/                   # Core AI logic
│   ├── disease_service.py
│   └── outbreak_service.py
├── models/                     # Pydantic schemas
├── rag/                        # RAG pipeline (FAISS + LLM)
├── knowledge/                  # Disease knowledge base
├── artifact/                   # Trained model artifacts
├── core/                       # Configuration
└── data/

Setup & Installation

Prerequisites

Python 3.10+

pip

CPU environment (GPU optional)

OS: Windows / Linux / macOS

Install Dependencies

pip install -r requirements.txt

Main dependencies:

fastapi
uvicorn
pydantic
numpy
joblib
scikit-learn
xgboost
torch
torchvision
python-multipart
faiss-cpu
sentence-transformers
transformers
requests

Run Instructions

Local Host

uvicorn app.main:app --reload

API Documentation (Swagger UI)

http://localhost:8000/docs

Health Check

GET /health

Response:

{
  "status": "ok"
}

User Guide – API Usage

1. Disease Detection (Image Upload)

Backbone: DINOv2 (Vision Transformer)

Framework: PyTorch

Input: Leaf image (JPEG / PNG)

Output:

Asynchronous inference is handled using FastAPI BackgroundTasks to improve responsiveness.

Endpoint

POST /observations

Request

Response

{
  "observation_id": "uuid",
  "status": "queued"
}

POST/observation response

2. Get Disease Detection Result

Endpoint

GET /observations/{observation_id}

Response

{
  "status": "done",
  "result": {
    "status": "unhealthy",
    "disease": "Bacterial Leaf Blight",
    "confidence": 0.92,
    "all_probabilities": {
      "Bacterial Leaf Blight": 0.92,
      "Brown Spot": 0.04,
      "Healthy Rice Leaf": 0.04
    }
  }
}

GET/observation/{observation_id} response

3. Outbreak Risk Prediction

Model: Classical ML (Logistic Regression)

Inputs:

Outputs:

This component enables early warning signals for regional disease spread.

Endpoint

POST /outbreak/predict

Request Body

{
  "dominant_disease": "Bacterial Leaf Blight",
  "reports_3d": 12,
  "reports_7d": 30,
  "reports_14d": 55,
  "unique_users_7d": 18,
  "same_disease_ratio": 0.7,
  "rainfall_7d": 120,
  "avg_temp_7d": 29
}

Response

{
  "outbreak_risk_score": 0.78,
  "risk_level": "high",
  "outbreak_predicted": 1,
  "threshold": 0.6,
  "model_info": {
    "created_at": "2025-01",
    "description": "XGBoost outbreak forecasting model"
  }
}

POST/outbreak/predict input

POST/outbreak/predict output

4. Disease Information & Treatment (RAG)

Embeddings: Sentence Transformers

Vector Database: FAISS

Knowledge Source: Structured disease JSON documents

Function:

A dedicated ingestion pipeline builds the FAISS index before API runtime.

Endpoint

POST /rag/disease-info

Request Body

{
  "disease": "Bacterial Leaf Blight",
  "status": "unhealthy"
}

Response

{
  "status": "unhealthy",
  "disease": "Bacterial Leaf Blight",
  "symptoms": [...],
  "treatment": [...]
}

RAG/rag/disease-info input

RAG/rag/disease-info output

AI Models Used

Disease Classification

Backbone: DINOv2 (ViT)

Framework: PyTorch

Outbreak Prediction

Model: Classical ML (XGBoost)

RAG System

Embeddings: Sentence Transformers

Vector DB: FAISS

Notes for Hackathon

Fake in-memory database is used for observations

Models are preloaded on startup

System is optimized for demo & prototype scale

Ready for cloud deployment (Render, Docker, etc.)