How gismal/to-ai-or-not-to-ai works
This is an image-origin detection product: browser or API clients submit images and receive a five-label confidence-aware prediction, optionally with a GradCAM heatmap. The principal flow validates uploads, checks the prediction cache, runs ONNX inference, classifies confidence, and logs results. Separate branches cover feedback and human labeling, drift-triggered retraining, browser-extension use, and monitoring. Training and some extension wiring are represented from the README and tree; their implementation details were not sampled, so those links are documented or marked unverified.
Main entry points: inference_routes.py Inference routes · main.py FastAPI application · inference_service.py Inference orchestration · popup.js Analysis popup
Components 25
API and inference
- Inference routes
src/api/inference_routes.py - Image validation
src/api/inference_routes.py - Inference orchestration
src/services/inference_service.py - ONNX predictor
src/inference.py - pHash cache
src/services/cache_service.py - GradCAM explainability
src/services/explainability_service.py - FastAPI application
src/main.py
Data and feedback
- Feedback routes
src/api/feedback_routes.py - Feedback handling
src/services/feedback_service.py - Prediction logs
src/repositories/prediction_log_repository.py - Feedback repository
src/repositories/feedback_repo.py - PostgreSQL data
src/infra/database.py
MLOps and monitoring
- Admin and review routes
src/api/admin_routes.py - Drift detection
src/services/retrain_service.py - Retraining worker
src/worker/tasks.py - Model training
scripts/train.py - Dataset preparation
scripts/prepare_dataset.py - Prometheus metrics
src/infra/metrics.py - Grafana dashboard
Browser extension
- Passive page scanning
extension/content.js - Image context menu
extension/background.js - Analysis popup
extension/popup.js - Result view
extension/results.js
Other components
- Image user
- Website visitor
Connections 26
- Image user → FastAPI application: submits image
- FastAPI application → Inference routes: registers routes
src/main.py - Inference routes → Image validation: validates upload
src/api/inference_routes.py - Inference routes → Inference orchestration: requests prediction
src/api/inference_routes.py - Inference orchestration → pHash cache: checks cache
src/services/inference_service.py - Inference orchestration → ONNX predictor: runs inference
src/services/inference_service.py - Inference routes → GradCAM explainability: requests heatmap
src/api/inference_routes.py - Inference routes → Prediction logs: logs predictions
src/api/inference_routes.py - Inference routes → Feedback routes: registers routes
src/main.py - Feedback routes → Feedback handling: submits feedback
src/api/feedback_routes.py - Feedback handling → Feedback repository: stores feedback
src/services/feedback_service.py - Prediction logs → PostgreSQL data: writes logs
- Feedback repository → PostgreSQL data: persists feedback
- FastAPI application → Admin and review routes: registers routes
src/main.py - Admin and review routes → Drift detection: checks drift
src/api/admin_routes.py - Drift detection → Retraining worker: enqueues retraining
src/services/retrain_service.py - Retraining worker → Model training: runs training
- Dataset preparation → Model training: prepares training data
- FastAPI application → Prometheus metrics: exposes metrics
- Prometheus metrics → Grafana dashboard: feeds dashboards
- Website visitor → Passive page scanning: browses page
- Website visitor → Image context menu: selects image
- Passive page scanning → FastAPI application: requests analysis
- Image context menu → Analysis popup: opens analysis
- Analysis popup → FastAPI application: requests analysis
- Analysis popup → Result view: shows results