🩺 Clinical Diagnosis Application & medReport Model

Welcome to the Clinical Diagnosis Application, a NLP-powered deep learning solution for automated medical diagnosis based on clinical notes. This project leverages BioBERT, Natural Language Processing, and Hugging Face Transformers to analyze patient reports and predict diseases with high accuracy.

πŸš€ Live Model Hosted on Hugging Face: DrSyedFaizan/medReport

πŸ”¬ Overview medReport is a fine-tuned BioBERT model trained on clinical text data to predict diseases based on patient reports. The associated Clinical Diagnosis App allows users to upload medical notes (PDF/TXT) and receive disease predictions along with recommended medications and specialists.

✨ Features βœ… Fine-tuned BioBERT Model for medical text classification βœ… Predict diseases from clinical notes βœ… Extract text from PDFs and TXT files βœ… Recommend medications & specialists based on prediction βœ… Streamlit-powered web app for easy access βœ… Deployable on Hugging Face Spaces / Local Server

πŸ“‚ Project Structure

πŸ“ Clinical-Diagnosis-App/ │── πŸ“‚ patient_model/ # Trained BioBERT model files │── πŸ“‚ results/ # Model training results & logs │── πŸ“‚ sample_data/ # Sample clinical reports │── πŸ“œ app.py # Streamlit-based UI for predictions │── πŸ“œ requirements.txt # Required dependencies │── πŸ“œ README.md # Documentation │── πŸ“œ label_encoder.pkl # Pre-trained Label Encoder │── πŸ“œ clinical_notes.csv # Sample dataset πŸš€ Installation & Setup 1️⃣ Clone the Repository

git clone https://github.com/SYEDFAIZAN1987/Clinical-Diagnosis-Application-using-Natural-Language-Processing.git cd Clinical-Diagnosis-Application-using-Natural-Language-Processing 2️⃣ Install Dependencies

pip install -r requirements.txt 3️⃣ Run the Applicationbash

streamlit run app.py The app will launch at http://localhost:8501 πŸŽ‰

πŸ“Œ Model Details The medReport model is fine-tuned on a clinical notes dataset using BioBERT, a biomedical NLP model. It has been trained for multi-label classification, allowing it to predict diseases from unstructured clinical text.

πŸ”— Load the Model You can access the trained model directly via Hugging Face:

python Copy Edit from transformers import BertForSequenceClassification, BertTokenizer from huggingface_hub import hf_hub_download import pickle import torch

Load Model & Tokenizer

model = BertForSequenceClassification.from_pretrained("DrSyedFaizan/medReport") tokenizer = BertTokenizer.from_pretrained("DrSyedFaizan/medReport")

Load Label Encoder

label_encoder_path = hf_hub_download(repo_id="DrSyedFaizan/medReport", filename="label_encoder.pkl") with open(label_encoder_path, "rb") as f: label_encoder = pickle.load(f) πŸ“Š Performance Metrics Metric Score Accuracy 100$

βœ… Trained on BioBERT βœ… Optimized with AdamW βœ… Fine-tuned for Clinical NLP

πŸ“– Usage πŸ”Ή Predict Disease from a Clinical Note python Copy Edit def predict_disease(text, model, tokenizer, label_encoder): inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512) with torch.no_grad(): outputs = model(**inputs) logits = outputs.logits predicted_label = torch.argmax(logits, dim=1).item() return label_encoder.inverse_transform([predicted_label])[0] 🎨 Web App UI (Streamlit) The Streamlit UI allows drag & drop of PDF/TXT files for quick disease predictions.

πŸ“₯ Upload Clinical Notes 1️⃣ Upload clinical notes (PDF or TXT) 2️⃣ Extract text from reports 3️⃣ Predict disease 4️⃣ Get medication & specialist recommendations

πŸ₯ Example Predictions Clinical Note Predicted Disease Medications Specialists "Patient reports persistent heartburn..." Gastroesophageal Reflux Disease (GERD) Omeprazole, Ranitidine Gastroenterologist "Male patient with history of smoking, chronic cough..." Chronic Obstructive Pulmonary Disease (COPD) Tiotropium, Albuterol Pulmonologist "Elderly patient with diabetes, experiencing numbness..." Diabetic Neuropathy Metformin, Insulin Endocrinologist 🌍 Deployment Options 1️⃣ Run Locally with Streamlit

bash Copy Edit streamlit run app.py 2️⃣ Deploy on Hugging Face Spaces

Create a Streamlit space on Hugging Face Upload the repository Add a requirements.txt file Run app.py automatically 3️⃣ Deploy on Cloud (AWS, GCP, Azure)

Use FastAPI + Uvicorn Deploy via Docker / Kubernetes πŸ› οΈ Tech Stack βœ” BioBERT (Fine-Tuned) βœ” Transformers (Hugging Face) βœ” PyTorch (Deep Learning) βœ” Streamlit (UI Framework) βœ” Hugging Face Hub (Model Hosting)

πŸ§‘β€πŸ’» Contribution 🀝 Contributions are welcome! If you'd like to improve the model or app, feel free to fork the repo and submit a pull request.

Fork the repository Clone locally Create a branch (git checkout -b feature-new) Commit changes (git commit -m "Added feature X") Push & Submit a PR πŸ“© Contact πŸ’‘ Author: Syed Faizan, MD πŸ“§ Email: [email protected] πŸ€– Hugging Face: DrSyedFaizan πŸ“‚ GitHub: SYEDFAIZAN1987

Downloads last month
79
Safetensors
Model size
108M params
Tensor type
F32
Β·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Space using DrSyedFaizan/medReport 1