Skip to Content
ServicesAI ServiceAI Service

AI Service

The AI Service is the machine learning inference engine for the DermaDetect platform. It provides diagnosis predictions, image validation, triage, and adaptive questionnaire logic.

Overview

Location: services/ai_service/

Technology Stack:

  • FastAPI with Pydantic validation
  • TensorFlow for ML inference
  • OpenCV for image processing
  • NumPy/Pandas for data processing
  • Scikit-learn for preprocessing

Default Port: 8080

Key Capabilities

ML Inference

Diagnosis Prediction

  • Multi-disease classification using TensorFlow models
  • Probability scores for each disease
  • Confidence level assessment

Image Quality Validation

  • Automated image quality assessment
  • Checks for blur, lighting, framing
  • Returns validity score and feedback

Red Flags Detection

  • Identifies urgent medical conditions
  • Rule-based and ML-based detection
  • Prioritizes cases requiring immediate attention

Patient Triage

  • Assesses urgency based on symptoms
  • Assigns priority levels
  • Routes to appropriate care pathway

Adaptive Questionnaires

  • Dynamic question selection
  • Based on previous answers
  • Optimizes diagnostic information gathering

Architecture

The AI Service is designed as a stateless inference service:

API Gateway β†’ [HTTP] β†’ AI Service ↓ TensorFlow Models (local filesystem)

Key Design Principles:

  • βœ… Stateless: No database dependencies, purely inference
  • βœ… Fast: Optimized model loading and caching
  • βœ… Scalable: Can scale independently of API Gateway
  • βœ… GPU-Ready: Automatically uses GPU when available

Performance

  • GPU Support: Automatically detects and uses GPU
  • Model Caching: Models loaded once at startup
  • Async Processing: Non-blocking I/O for concurrent requests
  • Horizontal Scaling: Add more replicas for higher throughput

Data Flow

All patient data flows through the API Gateway:

  1. Client sends anamnesis data to API Gateway
  2. API Gateway calls AI Service with formatted data
  3. AI Service runs ML inference
  4. API Gateway receives predictions
  5. API Gateway stores results in database
  6. Client receives response

The AI Service never accesses the database or cloud storage directly.

Last updated on