A high-contrast black/white farmer website with a React + TypeScript frontend, Python FastAPI backend, real local account login, and your unchanged YOLO model. There is no Streamlit runtime dependency.
- Extract the ZIP completely. Open the AgriScan_Web folder in VS Code.
- Use Python 3.12 (the tested version). Open Terminal → New Terminal.
- Run these commands one at a time:
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe -m uvicorn backend.main:app --host 127.0.0.1 --port 8000- Open http://localhost:8000. Click Create an account, register, and scan.
- Leave the terminal open. Press Ctrl+C to stop.
After the first installation, only the last command is needed. The frontend is
already built in frontend/dist/; Node.js is not needed just to run this ZIP.
Do not run the app.py inside original_project/ — it is your old backup app.
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python -m uvicorn backend.main:app --host 127.0.0.1 --port 8000Linux selects CPU-only PyTorch. No GPU or paid inference service is needed.
Some Linux systems need libgl1 and libglib2.0-0 for OpenCV. Install those
through your system package manager if a missing-library error occurs.
- Responsive monochrome interface with persistent Black / White mode.
- Register, log in, keep a session, and log out.
- Hashed passwords; session cookies are HttpOnly and SameSite=Strict.
- SQLite account data and scan reports; scan records isolated by account.
- Image upload, drag/drop, browser camera, device-camera fallback, clear image.
- Real CPU predictions, class/confidence, estimated circles, report/image download.
- Results grouped by predicted class rather than one card per model box.
- Optional known-crop selection flags a conflicting dominant crop prediction; it does not force the model to return the chosen crop.
- 29 separate guide URLs: 18 disease/pest classes and 11 healthy classes.
- Each guide includes a description, visible signs, care/treatment, prevention.
- Each disease result links to its guide and primary university extension sources.
- Account history of the latest 100 reports, download and deletion.
This app requires a Python-capable host with enough memory for PyTorch and a persistent disk for SQLite. Streamlit Community Cloud does not host this stack. No public deployment or hosting account is included in this ZIP. Free hosting availability and resource limits depend on the provider; none is guaranteed.
- Install
requirements.txtin a Python 3.12 environment. - The included frontend build can be served directly by FastAPI. To rebuild it,
use
npm ciandnpm run buildinfrontend/with Node.js 20+. - Copy
.env.exampleto.envand set:AGRISCAN_ALLOWED_ORIGINS=https://your-exact-domain.exampleAGRISCAN_SECURE_COOKIES=1AGRISCAN_DATA_DIRto a persistent writable directory.
- Use a host-managed HTTPS endpoint/proxy and start:
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --workers 1Adapt the port to the provider. Camera access requires HTTPS or localhost. Use one application worker for this small deployment to keep model memory low. The shared model is protected with a lock; two scan slots bound parallel request pressure. Set trusted proxy configuration according to the hosting provider. Never expose the development Vite server as the production site. Back up the SQLite data directory; ephemeral disks lose accounts and history.
With Python running on port 8000:
cd frontend
npm ci
npm run devOpen http://localhost:5173. Vite proxies /api to Python. Both local origins are
allowed by default. Build changes with npm run build, then restart the Python
server if assets changed. No authentication tokens are stored in localStorage;
only the visual theme preference is stored there.
The unchanged checkpoint exposes 29 classes, not 29 separate diseases. It includes 11 healthy leaf classes. Exact class names/IDs are preserved from the checkpoint, independent of the original data.yaml ordering.
Tests on cropped photos from the supplied PDF showed false-healthy predictions for its bell-pepper leaf-spot and grape-black-rot examples, and other mismatches. Those PDF captions are reference labels, not independent diagnostic ground truth. Rebuilding the frontend does not improve the model's learned accuracy.
The app therefore says the model suggests a healthy leaf, never that it certifies a disease-free plant. A high confidence score can still be wrong. Basic colour/texture leaf screening can reject real leaves or accept unrelated objects. Missing detections are treated as uncertain, rather than healthy.
Red circles are estimated discoloured regions inside detected affected leaves, adapted from your pixel-analysis approach. If no spot is located, the leaf region is circled instead. They are not verified segmentation masks. No disease name is invented from pixel colours, the selected crop, or a reference image.
Treatment sections give general care guidance, not a chemical prescription. Product legality, dose, timing, protective equipment and harvest intervals are location-specific. Confirm the diagnosis and follow a locally registered product label with local agricultural advice. Virus guides do not promise a curative spray.
The browser sends photos to this Python server. The app processes photos in
memory and returns an annotated result; it does not store image files in accounts
or send them to an external AI API. Accounts and prediction reports persist in
data/agriscan.sqlite3 by default. History deletion removes account scan reports.
This is an installation-local login system, not Google login. Email verification,
password reset, account deletion, and email sending are not configured. No admin
password or test account is packaged. HTTPS and secure cookies are required for
public use. Do not upload personal information in leaf photographs.
original_project/ contains every supplied original project file unchanged.
model/best.pt is a byte-for-byte copy of the supplied best.pt.zip, which is
already a PyTorch checkpoint internally; do not extract it as a normal archive.
The original scripts and notebook remain available in the backup. Uploaded PDF
and screenshots were used for review only and are not included in this ZIP.
python -m pip install -r requirements-dev.txt
python -m pytest -q testsSee VALIDATION.md for performed checks and limits. Tests create temporary
accounts/databases outside the packaged persistent-data directory.