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
Quick Links
Data Flow
All patient data flows through the API Gateway:
- Client sends anamnesis data to API Gateway
- API Gateway calls AI Service with formatted data
- AI Service runs ML inference
- API Gateway receives predictions
- API Gateway stores results in database
- Client receives response
The AI Service never accesses the database or cloud storage directly.
Last updated on