π©Ί 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