Capstone Project | Data Science with GenAI | Entri Elevate Γ NSDC Γ Illinois Tech
Built by: Fathima Salga | Kochi, Kerala
Live App: https://pfveklr9pexfstzg65gq8s.streamlit.app
MedAI Nexus is a 5-module AI-powered healthcare assistant built and deployed end-to-end as a capstone project. It helps patients understand their own health data through computer vision, machine learning, OCR, and large language models β all integrated into a single Streamlit web application.
Medical Disclaimer: This is a student project for educational purposes only. All outputs are NOT medical diagnoses. Always consult a qualified healthcare professional before making any health decisions.
| Module | What it does |
|---|---|
| π¬ Skin Disease | Upload a skin photo β 20-class AI classification |
| π Health Risk | Fill health form β Diabetes risk + SHAP explanation |
| π Report Explainer | Upload lab report β OCR + Gemini plain-language explanation |
| π¬ AI Chatbot | Ask health questions β Personalised answers using your results |
| πΏ Lifestyle Coach | Fill habits form β 6-dimension score + 7-day wellness plan |
User uploads skin image β Module 1: MobileNetV2 β skin_result
User fills health form β Module 2: XGBoost β risk_result
User uploads lab report β Module 3: OCR + Gemini β report_result
β
st.session_state (shared)
β
Module 4: AI Chatbot (uses all 3 results)
Module 5: Lifestyle Coach (uses all 3 results)
All five modules share data through Streamlit's session_state β results from earlier modules automatically personalise later ones.
| Detail | Value |
|---|---|
| Model | MobileNetV2 (Transfer Learning) |
| Dataset | DermNet β 19,500+ images, 20 classes |
| Imbalance | 6.6:1 ratio β solved with Focal Loss (Ξ³=2.0) |
| Accuracy | 41.6% (20-class, random baseline = 5%) |
| Macro F1 | 0.368 |
| Training | 2 phases β frozen base β fine-tune top 40 layers |
Key challenge: Model saved with TF 2.19 (Keras 3.5+) had quantization_config in Dense layer config β caused deserialization failure on deployment. Fix: Rebuilt architecture in pure Python + save_weights() to .weights.h5 (12.1MB) β bypasses config entirely.
| Detail | Value |
|---|---|
| Model | XGBoost + Random Forest |
| Dataset | CDC BRFSS 2015 β 253,680 rows, 21 features |
| Imbalance | 4.78:1 ratio β solved with SMOTE only |
| XGBoost Accuracy | 83.7% |
| XGBoost AUC-ROC | 0.813 |
| RF Diabetic Recall | 50% (better for screening) |
| Explainability | SHAP TreeExplainer + waterfall plot |
Key challenge: Using SMOTE + scale_pos_weight simultaneously caused model collapse (logloss 0.691 β 0.746). Fix: Remove scale_pos_weight, keep SMOTE only.
Note: Random Forest chosen for the app despite lower accuracy because it achieves 50% diabetic recall vs XGBoost's 22% β recall matters more than accuracy in medical screening.
| Detail | Value |
|---|---|
| OCR Engine | Tesseract (--psm 4 --oem 3) |
| LLM | Gemini 2.5 Flash |
| Preprocessing | 5-step pipeline |
| OCR Accuracy | ~40% raw β ~85% after preprocessing |
| Output | Structured JSON β patient_summary, test_results, flags, next_steps |
5-Step OCR Preprocessing Pipeline:
Raw Image β Grayscale β Denoise β CLAHE β Binarise β Deskew β Tesseract
| Detail | Value |
|---|---|
| LLM | Gemini 2.5 Flash |
| Memory | client.chats.create() β auto history management |
| Personalisation | System instruction includes Module 1-3 results |
| Safety | 12 emergency keywords detected before API call |
| Detail | Value |
|---|---|
| LLM | Gemini 2.5 Flash |
| Scoring | 6 dimensions, 0-100 mathematical formulas |
| Visualisation | Matplotlib radar chart |
| Output | Full 7-day wellness plan (JSON) |
6 Scoring Dimensions:
| Dimension | Formula |
|---|---|
| Sleep | 100 if 7-9 hrs, else -15 per hour off |
| Activity | Intensity Γ 0.5 + (active days/7) Γ 50 |
| Nutrition | Fruit + Veg + Water + Diet bonus |
| Habits | 100 - 40(smoke) - 3Γ(alcohol units) |
| Mental | 100 - (stress-1) Γ 11 + quality bonus |
| Screen | 100 - max(0, hours-4) Γ 12 |
| Category | Technology |
|---|---|
| Language | Python 3.10 |
| Deep Learning | TensorFlow 2.16.2 Β· Keras |
| Machine Learning | XGBoost 1.7.6 Β· Scikit-learn Β· SHAP |
| OCR | Tesseract 5.5 Β· pytesseract Β· OpenCV |
| LLM | Google Gemini 2.5 Flash (google-genai) |
| Imbalance Handling | SMOTE (imbalanced-learn) |
| Web App | Streamlit 1.32 |
| Model Storage | Google Drive + gdown |
| Deployment | Streamlit Cloud |
| Version Control | Git Β· GitHub |
medai-nexus/
βββ app.py β Home page / entry point
βββ requirements.txt β Python dependencies
βββ packages.txt β System packages (Tesseract)
βββ pages/
β βββ 1_Skin_Disease.py
β βββ 2_Health_Risk.py
β βββ 3_Report_Explainer.py
β βββ 4_AI_Chatbot.py
β βββ 5_Lifestyle_Coach.py
βββ utils/
β βββ helpers.py β All inference functions
βββ models/
βββ skin_weights_only.weights.h5 β Downloaded from Google Drive
βββ skin_disease_class_names.pkl
βββ health_risk_xgb.pkl
βββ health_features.pkl
- Python 3.10+
- Tesseract OCR installed
# Ubuntu/Debian
sudo apt-get install tesseract-ocr tesseract-ocr-eng
# Mac
brew install tesseract# 1. Clone the repository
git clone https://github.com/fathimasalga/medai-nexus.git
cd medai-nexus
# 2. Install Python dependencies
pip install -r requirements.txt
# 3. Run the app
streamlit run app.pyGet a free API key from Google AI Studio and enter it in the sidebar when using Modules 3, 4, or 5.
| File | Size | Location |
|---|---|---|
| skin_weights_only.weights.h5 | 12.1 MB | Google Drive (auto-downloaded) |
| skin_disease_class_names.pkl | < 1 MB | GitHub repo |
| health_risk_xgb.pkl | ~5 MB | GitHub repo |
| health_features.pkl | < 1 MB | GitHub repo |
The skin model weights file is hosted on Google Drive and downloaded automatically at first launch using
gdown. It does not need to be uploaded to GitHub.
| Decision | Choice | Reason |
|---|---|---|
| LLM | Gemini 2.5 Flash | Free API β GPT-4o requires billing |
| Imbalance (Module 1) | Focal Loss | 6.6Γ imbalance β down-weights easy examples |
| Imbalance (Module 2) | SMOTE only | scale_pos_weight + SMOTE caused model collapse |
| Model saving | save_weights() .h5 | Avoids Keras version config conflicts |
| Model hosting | Google Drive + gdown | GitHub 25MB limit β weights file is 12.1MB |
| Evaluation metric | Recall over Accuracy | Medical screening β missing a case is worse than false alarm |
| # | Challenge | Solution |
|---|---|---|
| 1 | 6.6Γ class imbalance in DermNet | Focal Loss (Ξ³=2.0, Ξ±=0.25) |
| 2 | SMOTE + scale_pos_weight β model collapse | Removed scale_pos_weight, SMOTE only |
| 3 | Keras quantization_config error on deployment | Rebuilt architecture in Python + save_weights() |
| 4 | GitHub 25MB file size limit | Google Drive + gdown auto-download |
| 5 | GPT-4o billing required | Switched to Gemini 1.5 Flash β 2.5 Flash |
| 6 | google-generativeai SDK deprecated (Nov 2025) | Migrated to new google-genai SDK |
| 7 | Gemini chat client closing mid-session | Stored client in st.session_state |
| 8 | OCR accuracy ~40% on raw images | 5-step preprocessing pipeline β ~85% |
| 9 | Free GPU limits hit mid-training | Colab Pro + A100 GPU (still took 2 hours) |
| 10 | API quota exhaustion | User-provided keys + model rotation |
| Module | Metric | Value |
|---|---|---|
| Skin Disease | Overall Accuracy | 41.6% |
| Skin Disease | Macro F1-Score | 0.368 |
| Skin Disease | Best class (Nail Fungus) | 77% |
| Health Risk | XGBoost Accuracy | 83.7% |
| Health Risk | XGBoost AUC-ROC | 0.813 |
| Health Risk | RF Diabetic Recall | 50% |
| Report Explainer | OCR accuracy (after preprocessing) | ~85% |
| Lifestyle Coach | Scoring dimensions | 6 (0-100 each) |
Fathima Salga
Aspiring Data Scientist | Kochi, Kerala
- M.Sc Physical Oceanography β CUSAT (CGPA 8.29)
- Ex-Project Associate β DRDO NPOL (2022-2024)
- Data Science with GenAI β Entri Γ Illinois Tech Γ NSDC
- GitHub
This project is built for educational purposes as part of the Data Science with GenAI capstone program.
All health outputs include a disclaimer: Not a medical diagnosis. Always consult a qualified healthcare professional.
TensorFlow Β· XGBoost Β· Tesseract Β· Gemini 2.5 Flash Β· Streamlit