How sud747/vizualai works
Purpose and deployment shape
VizualAI recognizes foods in tray images and returns an itemized bill. It is a multi-client repository centered on a Python FastAPI inference service, with packaged ML weights and Flutter/native Android clients. The API is intended to run locally on port 8001; Docker support is present via Dockerfile.
Backend API entry points
The documented service entry point is backend/food_app.py, which exposes REST endpoints and hosts model inference. backend/app.py is a second backend application/module and should be assessed before consolidating server startup behavior. A static browser-facing dashboard is co-located with the backend at backend/static/food_ui.html and backend/static/index.html.
Vision inference pipeline
The core recognition boundary is the two-stage pipeline in backend/yolo_pipeline.py:
1. YOLOv8 detects candidate tray objects and bounding boxes.
2. Regions are cropped/preprocessed and classified by fine-tuned MobileNetV2.
3. Custom post-processing/NMS removes duplicates.
4. Recognized classes feed pricing/billing returned by the API.
The deployable model artifacts are models/yolov8n.pt and models/best_food_classifier.pth. backend/detect_food.py provides a likely CLI-oriented invocation path separate from the HTTP service.
Model lifecycle
Inference consumes checked-in model weights from models/. Training is separated from serving in backend/train_classifier.py, creating a material lifecycle boundary: training or replacing classifier weights must preserve the class-label and pricing assumptions used by the runtime pipeline. GPU acceleration is optional through CUDA-compatible PyTorch; CPU execution remains supported.
Flutter client flow
The principal cross-platform client starts at apps/flutter/lib/main.dart and targets Android, iOS, web, Windows, macOS, and Linux through Flutter platform hosts. UI flows are organized around start, scanning, and billing screens: apps/flutter/lib/screens/start_screen.dart, apps/flutter/lib/screens/scanner_screen.dart, and apps/flutter/lib/screens/billing_screen.dart. Scanner and payment state/control flows use BLoC boundaries in apps/flutter/lib/blocs/scanner/scanner_bloc.dart and apps/flutter/lib/blocs/payment/payment_bloc.dart.
Client-to-service and billing boundary
The Flutter repository layer, apps/flutter/lib/repositories/food_repository.dart, is the client-side boundary for food/API data. API endpoint configuration is isolated in apps/flutter/lib/config/api_config.dart. Domain payloads are represented by apps/flutter/lib/models/food_item.dart and apps/flutter/lib/models/bill.dart; the expected flow is scan image → API prediction → recognized items → bill display/payment state.
Native Android client
A separate Kotlin/Jetpack Compose Android implementation exists, entered through apps/android/app/src/main/java/com/example/foodsight/MainActivity.kt. It uses navigation via Navigation.kt, presents its primary UI in ui/main/MainScreen.kt, and separates screen state in ui/main/MainScreenViewModel.kt. Its data boundary is data/DataRepository.kt; it should be treated as an independent client implementation rather than a Flutter platform wrapper.
Infrastructure and external dependencies
Runtime dependencies include FastAPI/Uvicorn, Ultralytics YOLOv8, PyTorch/Torchvision, Pillow, and multipart upload handling, declared at repository level in requirements.txt. External execution dependencies are Python 3.8+, optional NVIDIA CUDA/GPU support, Flutter SDK for the cross-platform app, and Android Gradle tooling for the native client.
Main entry points: yolo_pipeline.py Food recognition pipeline · food_repository.dart Food repository · scanner_screen.dart Start, scan, bill UI · food_app.py FastAPI service
Components 18
Python Inference Service
- FastAPI service · REST upload and billing inference service on port 8001.
backend/food_app.py - Second backend module · Separate application module to assess before startup consolidation.
backend/app.py - Food recognition pipeline · Detects, crops, classifies, deduplicates, and prices foods.
backend/yolo_pipeline.py - CLI detection
backend/detect_food.py - Static dashboard
backend/static/food_ui.html
Model Lifecycle
- YOLOv8 weights
models/yolov8n.pt - Food classifier weights · Fine-tuned classifier consumed by serving.
models/best_food_classifier.pth - Classifier training · Replacement weights must retain runtime label and pricing assumptions.
backend/train_classifier.py
Flutter Client
- Flutter app · Cross-platform client for mobile, desktop, and web.
apps/flutter/lib/main.dart - Start, scan, bill UI
apps/flutter/lib/screens/scanner_screen.dart - Scanner BLoC
apps/flutter/lib/blocs/scanner/scanner_bloc.dart - Payment BLoC
apps/flutter/lib/blocs/payment/payment_bloc.dart - Food repository
apps/flutter/lib/repositories/food_repository.dart - API configuration
apps/flutter/lib/config/api_config.dart - Food and bill payloads
apps/flutter/lib/models/bill.dart
Native Android Client
- Compose Android app · Independent native Android client implementation.
apps/android/app/src/main/java/com/example/foodsight/MainActivity.kt - Main screen and state
- Data repository
Connections 17
- Static dashboard → FastAPI service: HTTP requests
- FastAPI service → Food recognition pipeline: runs inference
- Second backend module → Food recognition pipeline: may expose inference
- CLI detection → Food recognition pipeline: invokes
- Food recognition pipeline → YOLOv8 weights: loads detector
- Food recognition pipeline → Food classifier weights: loads classifier
- Classifier training → Food classifier weights: produces/replaces
- Flutter app → Start, scan, bill UI: hosts flow
- Start, scan, bill UI → Scanner BLoC: scan state
- Start, scan, bill UI → Payment BLoC: payment state
- Scanner BLoC → Food repository: submits image
- Food repository → API configuration: uses endpoint
- Food repository → FastAPI service: prediction request
- Food repository → Food and bill payloads: maps response
- Food and bill payloads → Payment BLoC: bill state
- Compose Android app → Main screen and state: hosts
- Main screen and state → Data repository: loads data