Skip to content

NullClassifier/azira

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AZira AI Pest Manager

Production-ready FastAPI web app for pest photo classification and field guidance.

Run Locally

python3 -m venv --system-site-packages .venv
.venv/bin/python -m pip install -r requirements.txt
cp .env.example .env
.venv/bin/python -m uvicorn main:app --host 127.0.0.1 --port 8000 --reload

Open http://127.0.0.1:8000.

Gemini API Key

The backend reads GEMINI_API_KEY from .env in the project root. Without a key, scans still work and use the built-in pest knowledge fallback. With a key, the app uses GEMINI_MODEL, defaulting to gemini-2.5-flash.

Auth

User accounts are stored in azira.db by default through SQLAlchemy. The app uses email/password registration and login, validates email format, and protects scan uploads with bearer sessions.

For production, use Neon PostgreSQL or another managed Postgres service and set DATABASE_URL plus a strong AZIRA_SECRET_KEY.

Neon PostgreSQL

Create a Neon project, copy its pooled or direct connection string, and use it as:

DATABASE_URL=postgresql://NEON_USER:NEON_PASSWORD@NEON_HOST/NEON_DATABASE?sslmode=require

The app automatically normalizes postgresql:// and postgres:// URLs to SQLAlchemy's postgresql+psycopg:// driver format.

Set these deployment variables too:

GEMINI_API_KEY=YOUR_GEMINI_API_KEY_HERE
GEMINI_MODEL=gemini-2.5-flash
AZIRA_SECRET_KEY=YOUR_LONG_RANDOM_SECRET_HERE
AZIRA_MODEL_PATH=data/fastvit_t12_pest_float32.tflite
AZIRA_DEVICE=cpu
DB_POOL_SIZE=5
DB_MAX_OVERFLOW=10
DB_POOL_RECYCLE_SECONDS=300
AZIRA_AUTO_CREATE_TABLES=true

Generate a secret with:

.venv/bin/python -c "import secrets; print(secrets.token_urlsafe(64))"

Check the Neon connection after setting DATABASE_URL:

.venv/bin/python - <<'PY'
from azira.database import engine
with engine.connect() as conn:
    print(conn.exec_driver_sql("select current_database()").scalar())
PY

Model Choice

The app serves the float32 TFLite model at data/fastvit_t12_pest_float32.tflite with ai-edge-litert.

  • 15 pest classes
  • 224px RGB image input
  • float32 NHWC input tensor
  • float32 logits output tensor

API

  • GET /api/health - model and Gemini status.
  • GET /api/classes - pest classes and display names.
  • POST /api/analyze - multipart image upload with optional crop and region fields.

Chemical guidance is intentionally conservative: the app avoids fabricated brands, prices, and exact dosages. Always confirm local registration, labels, PPE, and pre-harvest intervals.

About

Pest detection system powered by fine-tuned fastViT model

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors