How md-shaon-khan/farmer-s-friend works
Paddy Check accepts a leaf photo, rejects images that do not pass the paddy gate, classifies accepted leaves by pathogen category, and returns similar reference images plus attention-based localization for diseased leaves. The backend also serves the browser UI and reference thumbnails. Core inference and routing relationships are visible in the sampled source; frontend request wiring is not shown, so that connection is marked unverified.
Main entry points: pipeline.py Prediction pipeline · feature_extractor.py Similarity engine · predict.py Prediction endpoint · index.html Home page
Components 16
Application entry
- FastAPI app
Backend/main.py - Prediction endpoint
Backend/routers/predict.py - Prediction response
Backend/schemas/predict.py
Leaf inference
- Runtime settings
Backend/config.py - Image preprocessing
Backend/utils/image_utils.py - Prediction pipeline
Backend/ml/pipeline.py - Paddy gatekeeper
Backend/ml/paddy_detector.py - Pathogen classifier
Backend/ml/disease_classifier.py
Image analysis
- Attention localization
Backend/ml/spot_detector.py - Similarity engine
Backend/ml/feature_extractor.py - Reference gallery
Backend/data
Browser interface
- Home page
Frontend/index.html - Classification page
Frontend/pages/classify.html - Classification UI
Frontend/js/classify.js - Shared page behavior
Frontend/js/main.js
Other components
- Grower
Connections 25
- Grower → Home page: opens
README.md - Grower → Classification page: submits photo
- Home page → Classification page: offers classification
- Classification page → Classification UI: loads script
- Classification UI → Prediction endpoint: requests prediction
- FastAPI app → Prediction endpoint: registers routes
Backend/main.py - FastAPI app → Home page: serves frontend
Backend/main.py - Prediction endpoint → Prediction pipeline: runs pipeline
Backend/routers/predict.py - Prediction endpoint → Prediction response: validates response
Backend/routers/predict.py - Prediction pipeline → Paddy gatekeeper: checks paddy
Backend/ml/pipeline.py - Prediction pipeline → Pathogen classifier: classifies leaf
Backend/ml/pipeline.py - Prediction pipeline → Similarity engine: finds matches
Backend/ml/pipeline.py - Prediction pipeline → Attention localization: localizes disease
Backend/ml/pipeline.py - Prediction pipeline → Image preprocessing: decodes image
Backend/ml/pipeline.py - Paddy gatekeeper → Image preprocessing: decodes and transforms
Backend/ml/paddy_detector.py - Pathogen classifier → Image preprocessing: decodes and transforms
Backend/ml/disease_classifier.py - Similarity engine → Image preprocessing: decodes and transforms
Backend/ml/feature_extractor.py - Prediction pipeline → Runtime settings: reads settings
Backend/ml/pipeline.py - Paddy gatekeeper → Runtime settings: reads settings
Backend/ml/paddy_detector.py - Pathogen classifier → Runtime settings: reads settings
Backend/ml/disease_classifier.py - Similarity engine → Runtime settings: reads settings
Backend/ml/feature_extractor.py - Similarity engine → Reference gallery: loads and caches embeddings
Backend/ml/feature_extractor.py - FastAPI app → Reference gallery: serves reference images
Backend/main.py - Classification UI → Prediction response: renders results
- Shared page behavior → Home page: marks page loaded