CoolFace
Apppublic

parvv-24/CoughGPT

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

๐Ÿฉบ CoughGPT

CoughGPT is an AI health analysis project that takes natural-language symptom descriptions or condition names, predicts a likely disease or medication list, and generates a plain-English medical explanation with Gemini. The app is split into a Streamlit frontend and a FastAPI backend, with language detection and translation built in for multilingual use.


[!CAUTION] ## โš ๏ธ Medical Disclaimer โ€” READ BEFORE USE CoughGPT is a student/learning project built purely for educational and demonstration purposes. - The disease predictions and drug recommendations generated by this application are NOT medically verified, NOT clinically validated, and must NOT be used for self-diagnosis or self-medication. - The AI model outputs are based on limited training data and can produce incorrect, incomplete, or misleading results. - Do NOT take any medication based on what this app suggests. Always consult a qualified medical professional for health concerns, diagnosis, and treatment. - The creators of CoughGPT are not medical professionals and accept no responsibility or liability for any actions taken based on the outputs of this application. - If you are experiencing a medical emergency, call your local emergency services immediately. Use this project only to explore how ML pipelines and LLM integrations work โ€” not as a health tool.

๐Ÿง  Overview

CoughGPT is designed as a fast, modular health assistant with three core capabilities:

  1. 1.Disease prediction from comma-separated symptom input.
  2. 2.Drug recommendation based on the predicted condition.
  3. 3.AI-generated explanation of the result using Google Gemini.

The system also detects the user's language, translates non-English input to English for analysis, and translates the final response back to the original language when needed.

โœจ Key Features

  • โ€”FastAPI backend with startup model loading through a lifespan context manager.
  • โ€”X-API-Key authentication for protected endpoints.
  • โ€”Language detection using langdetect.
  • โ€”Translation using deep-translator.
  • โ€”Disease prediction with FastText embeddings and a trained classifier.
  • โ€”Drug recommendation from the drug review dataset.
  • โ€”Medical explanation generation using Google Gemini 2.5 Flash.
  • โ€”Streamlit frontend with a clean, responsive UI.

๐Ÿ› ๏ธ Tech Stack

LayerTechnology
FrontendStreamlit
BackendFastAPI
NLP / EmbeddingsFastText, Gensim
MLScikit-learn, Joblib, NumPy, Pandas
Language Toolslangdetect, deep-translator
AI ExplanationGoogle Generative AI (Gemini 2.5 Flash)
DeploymentDocker, Supervisord, Hugging Face Spaces

โš™๏ธ How It Works

The backend performs the full pipeline in a single /api/analyze call:

  1. 1.Detect the input language.
  2. 2.Translate to English if necessary.
  3. 3.Decide whether the input is a symptom list or a condition name.
  4. 4.Predict the disease for symptom input, then derive recommended drugs.
  5. 5.Call Gemini for a short medical explanation.
  6. 6.Translate the explanation back to the user's language when required.

๐Ÿš€ Deployment Architecture

This specific branch (hf-deployment) is optimized for deployment on Hugging Face Spaces using a custom Docker container.

  • โ€”Dual-Service: Uses supervisord to run both the FastAPI backend and Streamlit frontend in a single container.
  • โ€”Dynamic Model Loading: Heavy ML models (.pkl, .h5, etc.) are omitted from this repository to save space and are downloaded dynamically from a dedicated Hugging Face Model repository at runtime using huggingface_hub.
  • โ€”Environment Variables: Secrets (like GEMINI_API_KEY and API_SECRET_KEY) are injected securely at runtime via Hugging Face Space Settings.

๐Ÿ“ก API Endpoints

MethodEndpointDescription
GET/api/healthBackend health check
POST/api/detect-languageDetect text language
POST/api/translateTranslate text between languages
POST/api/predict-diseasePredict disease from symptoms
POST/api/predict-drugsPredict medications for condition
POST/api/explainGenerate Gemini explanation
POST/api/analyzeFull end-to-end analysis pipeline

๐Ÿ“ Notes

  • โ€”The backend loads ML models once at startup to avoid reloading large artifacts on every request.
  • โ€”The frontend is UI-only and talks to the backend over HTTP internally within the Docker container.
  • โ€”This project is intended for educational and informational use only and is not a substitute for professional medical advice.

๐Ÿ“„ License

This project is licensed under the MIT License.