Skip to content

healthai-vision

Service d'analyse nutritionnelle par photo de repas.

  • Image : ghcr.io/healthai-corpo/healthai-vision
  • Port : 8001
  • Swagger : http://localhost:8001/docs

Rôle

Identifie les aliments dans une photo de repas via YOLOv8 et calcule les macronutriments en interrogeant la table aliment de PostgreSQL.

Stack IA

ComposantTechnologie
DétectionUltralytics YOLOv8 (yolov8n.pt)
Traitement imagePillow + OpenCV (headless)
EnrichissementSQLAlchemy async → table aliment PostgreSQL

Flux de données

Client (image)
  → POST /analyze
  → YOLOv8 inference (seuil confiance > 0.5)
  → Mapping labels anglais → table aliment
  → Calcul macronutriments agrégés
  → JSON (nutrition data)

Structure

src/
├── api/             # Endpoint POST /analyze/meal
├── core/            # Config (modèles HuggingFace)
├── infrastructure/  # Connexion PostgreSQL (table aliment)
├── services/        # Logique IA (YOLO / EfficientNet)
└── main.py          # Serveur (port 8001)

Points d'attention

Cache du modèle

Le fichier .pt est stocké dans le conteneur. Utiliser un volume pour éviter le re-téléchargement au reboot :

yaml
volumes:
  - ./.hf_cache:/app/.hf_cache

Dépendances système

Le Dockerfile doit inclure libgl1 et libglib2.0-0 pour qu'OpenCV fonctionne en environnement Linux Slim.

Sérialisation

Les types Numeric/Decimal de PostgreSQL sont convertis en float automatiquement pour la compatibilité JSON.

Lancement isolé

bash
cd healthai-vision
uv sync
docker compose up --build healthai-vision

État d'implémentation

  • [x] Chargement asynchrone de YOLOv8 au démarrage (Singleton)
  • [x] Endpoint POST /analyze — détection + filtrage confiance > 0.5
  • [x] Mapping labels anglais YOLO → table PostgreSQL aliment
  • [x] Calcul des macronutriments agrégés