--- title: Digital Doctors Assistant ML API emoji: 🏥 colorFrom: blue colorTo: purple sdk: docker pinned: false license: mit --- # Digital Doctors Assistant ML API A FastAPI-based machine learning service that provides two prediction models for healthcare applications: 1. **Risk Assessment Model** - Predicts patient risk levels (Low/Medium/High) based on vitals and health metrics 2. **Treatment Outcome Model** - Predicts treatment success probability based on patient data and medication ## Features - RESTful API endpoints for ML predictions - Interactive web interface for easy testing - ONNX Runtime for fast inference - Pre-trained models hosted on HuggingFace - Docker support for easy deployment ## Quick Start ### Using HuggingFace Space Simply visit the Space URL and use the web interface to make predictions. ### Run Locally with Docker ```bash docker run -it -p 7860:7860 \ -e HUGGINGFACE_TOKEN="your_token_here" \ registry.hf.space/your-username-your-space-name:latest ``` ### Local Setup (Without Docker) 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Set your HuggingFace token: ```bash # Windows PowerShell $env:HUGGINGFACE_TOKEN="your_token_here" # Windows CMD set HUGGINGFACE_TOKEN=your_token_here # Linux/Mac export HUGGINGFACE_TOKEN=your_token_here ``` 3. Run the server: ```bash uvicorn ml:app --host 0.0.0.0 --port 7860 ``` 4. Open your browser: - Web Interface: http://localhost:7860 - API Docs: http://localhost:7860/docs - Health Check: http://localhost:7860/health ## API Endpoints ### POST /predict/risk Predict patient risk level based on health metrics. **Request Body:** ```json { "age": 45, "bmi": 28.5, "systolic_bp": 140, "diastolic_bp": 90, "chronic_conditions": "diabetes,hypertension", "severity_score": 7.5 } ``` **Response:** ```json { "success": true, "model": "risk_assessment", "prediction": "High", "confidence": 0.85, "probabilities": { "Low": 0.05, "Medium": 0.10, "High": 0.85 } } ``` ### POST /predict/treatment Predict treatment outcome success probability. **Request Body:** ```json { "patient_age": 55, "severity_score": 6.5, "compliance_rate": 0.85, "medication": "Metformin", "condition": "Diabetes Type 2" } ``` **Response:** ```json { "success": true, "model": "treatment_outcome", "prediction": 1, "success_probability": 78.5, "confidence": 0.78, "probabilities": { "failure": 0.22, "success": 0.78 } } ``` ## Supported Medications - Paracetamol - Ibuprofen - Amoxicillin - Ciprofloxacin - Metformin - Lisinopril - Amlodipine - Omeprazole ## Supported Conditions - Common Cold - Influenza - Pneumonia - Bronchitis - Hypertension - Diabetes Type 2 - Migraine - Gastroenteritis ## Environment Variables - `HUGGINGFACE_TOKEN` - Required. Your HuggingFace access token for downloading models ## Technology Stack - FastAPI - Web framework - ONNX Runtime - ML inference - NumPy - Numerical computing - HuggingFace Hub - Model hosting - Pydantic - Data validation - Uvicorn - ASGI server ## License MIT