About MyAgriScan
MyAgriScan helps farmers quickly identify plant diseases from a single photo and provides short, practical treatment and prevention advice generated by an expert AI. The site combines a lightweight image classifier running in a FastAPI backend with a server-side generative model that produces farmer-friendly recommendations.
How it solves the problem
- Quick detection: Upload a clear photo of a leaf and the system returns a probable diagnosis within seconds.
- Practical advice: After classification the site requests short, actionable guidance (prevention, treatment, tips) from a generative model, formatted for farmers.
- Safe deployment: The image model uses weights saved as a state dict to avoid unsafe pickled objects, and the generative API key is kept server-side so it is never exposed to users.
- Fault-tolerant flow: If the generative service is unavailable the classifier still returns a result so farmers can make decisions without blocking.
How it works (technical overview)
- The frontend uploads the image to a Next.js API route which proxies the file to a FastAPI classifier.
- FastAPI runs a PyTorch model (ResNet9) on the image and returns the top prediction and confidence.
- The frontend calls a separate Next.js server route which asks a generative model (server-side) for short structured advice about the predicted disease.
- The frontend displays both the classification and the parsed advice (prevention, treatment, tips). If the generative step fails, the UI still shows the classification and a friendly message.
Step-by-step: How farmers can use this site
- Take a clear photo of the affected leaf (good lighting, close-up of spots or symptoms).
- Open the Diagnose page and upload the photo using the "Analyze" button.
- Wait for the classification to finish — you'll see the predicted disease name and confidence score.
- The site will then fetch short prevention and treatment tips; read these and follow the simple steps recommended.
- If you're unsure or the confidence is low, save the image to your history and consult a local extension officer with the saved report.
Privacy & Safety
Uploaded photos are not published publicly. The generative AI key is stored server-side and is never exposed to the browser. For production deployments you should add logging, rate-limiting and explicit consent flows before collecting large numbers of images.
Need help?
If you run into issues or want to improve model accuracy, please:
- Double-check your image quality and retake photos where necessary.
- Contact the project maintainers or your local agricultural extension for region-specific advice.