Delete README (2).md
Browse files- README (2).md +0 -248
README (2).md
DELETED
|
@@ -1,248 +0,0 @@
|
|
| 1 |
-
# PneumoDetect AI - Externally Validated Pneumonia Detection System
|
| 2 |
-
|
| 3 |
-
**π₯ 96.4% sensitivity β’ 86% accuracy β’ Externally validated on 485 independent chest X-rays**
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
[](https://pneumodetectai.streamlit.app/) [](https://github.com/ayushirathour/chest-xray-pneumonia-detection) [](https://huggingface.co/ayushirathour/chest-xray-pneumonia-detection) [](https://opensource.org/licenses/MIT)
|
| 8 |
-
|
| 9 |
-
## β¨ What This Does
|
| 10 |
-
|
| 11 |
-
Transform chest X-ray images into pneumonia screening results in seconds. This AI model serves as a **research-validated screening support tool** to assist in pneumonia detection tasks and support educational applications.
|
| 12 |
-
|
| 13 |
-
**Suitable for:** Research, education, screening support evaluation, and medical AI development projects.
|
| 14 |
-
|
| 15 |
-
## π Get Started in 30 Seconds
|
| 16 |
-
|
| 17 |
-
### Installation
|
| 18 |
-
```bash
|
| 19 |
-
pip install tensorflow huggingface-hub pillow numpy requests
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
### Complete Working Example
|
| 23 |
-
```python
|
| 24 |
-
from huggingface_hub import hf_hub_download
|
| 25 |
-
import tensorflow as tf
|
| 26 |
-
import numpy as np
|
| 27 |
-
from PIL import Image
|
| 28 |
-
|
| 29 |
-
# Download and load model
|
| 30 |
-
model_path = hf_hub_download(
|
| 31 |
-
repo_id="ayushirathour/chest-xray-pneumonia-detection",
|
| 32 |
-
filename="best_chest_xray_model.h5"
|
| 33 |
-
)
|
| 34 |
-
model = tf.keras.models.load_model(model_path)
|
| 35 |
-
|
| 36 |
-
def predict_pneumonia(image_path):
|
| 37 |
-
"""
|
| 38 |
-
Predict pneumonia from chest X-ray image.
|
| 39 |
-
|
| 40 |
-
Args:
|
| 41 |
-
image_path (str): Path to chest X-ray image
|
| 42 |
-
|
| 43 |
-
Returns:
|
| 44 |
-
tuple: (diagnosis, confidence) - diagnosis string and confidence score
|
| 45 |
-
"""
|
| 46 |
-
img = Image.open(image_path).convert('RGB')
|
| 47 |
-
img = img.resize((224, 224))
|
| 48 |
-
img_array = np.array(img) / 255.0
|
| 49 |
-
img_array = np.expand_dims(img_array, axis=0)
|
| 50 |
-
|
| 51 |
-
prediction = model.predict(img_array)[0][0]
|
| 52 |
-
result = "Pneumonia" if prediction > 0.5 else "Normal"
|
| 53 |
-
confidence = prediction if prediction > 0.5 else 1 - prediction
|
| 54 |
-
|
| 55 |
-
return result, confidence
|
| 56 |
-
|
| 57 |
-
# Example usage
|
| 58 |
-
result, confidence = predict_pneumonia("chest_xray.jpg")
|
| 59 |
-
print(f"Diagnosis: {result} (Confidence: {confidence:.2%})")
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
> **Input Requirements:** 224Γ224 RGB chest X-ray images (PNG, JPEG, or DICOM formats supported)
|
| 63 |
-
|
| 64 |
-
**π― That's it!** Upload any chest X-ray image and get instant screening results.
|
| 65 |
-
|
| 66 |
-
## π Performance at a Glance
|
| 67 |
-
|
| 68 |
-

|
| 69 |
-
|
| 70 |
-
| Metric | Score | What This Means |
|
| 71 |
-
|--------|-------|-----------------|
|
| 72 |
-
| **Accuracy** | 86.0% | Correctly identifies 86 out of 100 cases |
|
| 73 |
-
| **Sensitivity** | 96.4% | Catches 96 out of 100 pneumonia cases |
|
| 74 |
-
| **Specificity** | 74.8% | Correctly identifies 75 out of 100 normal cases |
|
| 75 |
-
| **F1-Score** | 87.7% | Balanced overall performance |
|
| 76 |
-
|
| 77 |
-
**π Validation:** Tested on 485 independent chest X-rays (234 normal, 251 pneumonia) from external datasets to ensure real-world reliability.
|
| 78 |
-
|
| 79 |
-

|
| 80 |
-
|
| 81 |
-
## π― Why Choose PneumoDetect AI?
|
| 82 |
-
|
| 83 |
-
### β
**Externally Validated**
|
| 84 |
-
Unlike many AI models, we tested this on completely independent data (485 samples) to prove robust generalization across different data sources.
|
| 85 |
-
|
| 86 |
-
### β
**Screening Optimized**
|
| 87 |
-
96.4% sensitivity means it rarely misses pneumonia cases - critical for research applications focused on high-sensitivity detection.
|
| 88 |
-
|
| 89 |
-
### β
**Research Ready**
|
| 90 |
-
Built on MobileNetV2 for fast inference, deployed with Streamlit demo, FastAPI REST API capabilities, and comprehensive documentation for research applications.
|
| 91 |
-
|
| 92 |
-
### β
**Transparent Performance**
|
| 93 |
-
Only 8.8% accuracy drop from training to external validation shows robust generalization across different datasets and imaging protocols.
|
| 94 |
-
|
| 95 |
-

|
| 96 |
-
|
| 97 |
-
<details>
|
| 98 |
-
<summary><b>π§ Advanced Integration Examples</b></summary>
|
| 99 |
-
|
| 100 |
-
### Batch Processing Multiple X-rays
|
| 101 |
-
```python
|
| 102 |
-
from pathlib import Path
|
| 103 |
-
|
| 104 |
-
def batch_screening(folder_path):
|
| 105 |
-
results = []
|
| 106 |
-
for img_file in Path(folder_path).glob("*.{jpg,jpeg,png}"):
|
| 107 |
-
result, confidence = predict_pneumonia(str(img_file))
|
| 108 |
-
results.append({
|
| 109 |
-
'image_id': img_file.stem,
|
| 110 |
-
'diagnosis': result,
|
| 111 |
-
'confidence': f"{confidence:.1%}",
|
| 112 |
-
'priority': 'HIGH' if 'Pneumonia' in result and confidence > 0.8 else 'NORMAL'
|
| 113 |
-
})
|
| 114 |
-
return results
|
| 115 |
-
|
| 116 |
-
screening_results = batch_screening("research_xrays/")
|
| 117 |
-
```
|
| 118 |
-
|
| 119 |
-
### REST API Integration
|
| 120 |
-
```python
|
| 121 |
-
import requests
|
| 122 |
-
|
| 123 |
-
def api_prediction(image_path, api_endpoint):
|
| 124 |
-
with open(image_path, 'rb') as f:
|
| 125 |
-
response = requests.post(f"{api_endpoint}/predict", files={"file": f})
|
| 126 |
-
return response.json()
|
| 127 |
-
|
| 128 |
-
# For research deployments
|
| 129 |
-
# result = api_prediction("xray.jpg", "https://your-research-api.com")
|
| 130 |
-
```
|
| 131 |
-
|
| 132 |
-
### Integration with DICOM Medical Images
|
| 133 |
-
```python
|
| 134 |
-
import pydicom
|
| 135 |
-
from PIL import Image
|
| 136 |
-
|
| 137 |
-
def predict_from_dicom(dicom_path):
|
| 138 |
-
# Load DICOM file
|
| 139 |
-
dcm = pydicom.dcmread(dicom_path)
|
| 140 |
-
img_array = dcm.pixel_array
|
| 141 |
-
|
| 142 |
-
# Convert to PIL Image and process
|
| 143 |
-
img = Image.fromarray(img_array).convert('RGB')
|
| 144 |
-
|
| 145 |
-
# Use standard prediction pipeline
|
| 146 |
-
return predict_pneumonia_from_pil(img)
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
-
</details>
|
| 150 |
-
|
| 151 |
-
## π₯ Research & Educational Applications
|
| 152 |
-
|
| 153 |
-
### **Primary Use Cases**
|
| 154 |
-
- **π Pneumonia Detection Research:** High-sensitivity screening algorithm development
|
| 155 |
-
- **β‘ Educational Applications:** AI-assisted learning for medical students and researchers
|
| 156 |
-
- **π¨ββοΈ Algorithm Validation:** Benchmarking and comparison studies
|
| 157 |
-
- **π Medical AI Development:** Foundation for advanced pneumonia detection systems
|
| 158 |
-
|
| 159 |
-
### **Deployment Options**
|
| 160 |
-
This model is designed to support radiology workflows through multiple deployment options:
|
| 161 |
-
- **Web Interface:** Research demonstration via Streamlit demo
|
| 162 |
-
- **REST API:** Programmatic integration for research applications
|
| 163 |
-
- **Batch Processing:** High-volume analysis capabilities for research datasets
|
| 164 |
-
- **DICOM Support:** Compatible with medical imaging research standards
|
| 165 |
-
|
| 166 |
-

|
| 167 |
-
|
| 168 |
-
## π¬ Technical Architecture
|
| 169 |
-
|
| 170 |
-

|
| 171 |
-
|
| 172 |
-
<details>
|
| 173 |
-
<summary><b>ποΈ Technical Details</b></summary>
|
| 174 |
-
|
| 175 |
-
### Model Specifications
|
| 176 |
-
- **Architecture:** MobileNetV2 with transfer learning
|
| 177 |
-
- **Input:** 224Γ224 RGB chest X-ray images
|
| 178 |
-
- **Output:** Binary classification (Normal/Pneumonia) with confidence scores
|
| 179 |
-
- **Framework:** TensorFlow 2.x / Keras
|
| 180 |
-
- **Optimization:** Balanced for accuracy and inference speed
|
| 181 |
-
|
| 182 |
-
### Training & Validation Pipeline
|
| 183 |
-
- **Training Data:** Curated subset of Kaggle Chest X-ray Dataset
|
| 184 |
-
- **External Validation:** 485 independent samples from separate data sources
|
| 185 |
-
- **Preprocessing:** Standardized resizing, normalization, and data augmentation
|
| 186 |
-
- **Quality Control:** Systematic filtering for optimal training data quality
|
| 187 |
-
|
| 188 |
-
### Performance Visualizations
|
| 189 |
-
- **ROC Curves:** Area under curve analysis
|
| 190 |
-
- **Precision-Recall Curves:** Optimized for medical screening research
|
| 191 |
-
- **Class Distribution:** Balanced validation dataset
|
| 192 |
-
- **Error Analysis:** Detailed false positive/negative breakdown
|
| 193 |
-
|
| 194 |
-
</details>
|
| 195 |
-
|
| 196 |
-
## π Validation Results
|
| 197 |
-
|
| 198 |
-

|
| 199 |
-

|
| 200 |
-
|
| 201 |
-
The model demonstrates strong performance across multiple evaluation metrics with particular strength in sensitivity (pneumonia detection) which is critical for screening research applications.
|
| 202 |
-
|
| 203 |
-
## β οΈ Medical Considerations & Limitations
|
| 204 |
-
|
| 205 |
-
### π¨ **Important Usage Guidelines**
|
| 206 |
-
|
| 207 |
-
**This is a research prototype and educational tool, NOT a diagnostic device.**
|
| 208 |
-
|
| 209 |
-
- **Research Use Only:** Designed for academic research, education, and algorithm development
|
| 210 |
-
- **Not for Clinical Diagnosis:** Not approved for clinical use or patient care decisions
|
| 211 |
-
- **Professional Oversight Required:** Any research involving medical data should follow appropriate protocols
|
| 212 |
-
- **False Positive Rate:** 25.2% - important consideration for research design and interpretation
|
| 213 |
-
|
| 214 |
-
### **Technical Limitations**
|
| 215 |
-
- **Training Scope:** Optimized for standard posteroanterior chest X-rays
|
| 216 |
-
- **Population Variance:** Performance may differ across demographic groups and datasets
|
| 217 |
-
- **Equipment Dependency:** Best results with standard medical imaging protocols
|
| 218 |
-
- **Not FDA Approved:** For research and educational purposes only
|
| 219 |
-
|
| 220 |
-
### **Recommended Research Workflow**
|
| 221 |
-
1. **Algorithm Evaluation:** Use model for pneumonia detection research
|
| 222 |
-
2. **Comparative Studies:** Benchmark against other detection algorithms
|
| 223 |
-
3. **Educational Applications:** Demonstrate AI capabilities in medical imaging
|
| 224 |
-
4. **Further Development:** Foundation for enhanced pneumonia detection systems
|
| 225 |
-
|
| 226 |
-
## π Research & Citation
|
| 227 |
-
|
| 228 |
-
If you use PneumoDetect AI in your research or educational work:
|
| 229 |
-
|
| 230 |
-
```bibtex
|
| 231 |
-
@misc{rathour2025pneumodetect,
|
| 232 |
-
title={PneumoDetect AI: Externally Validated Pneumonia Detection System},
|
| 233 |
-
author={Rathour, Ayushi},
|
| 234 |
-
year={2025},
|
| 235 |
-
note={Externally validated deep learning system achieving 96.4% sensitivity on 485 independent samples},
|
| 236 |
-
url={https://huggingface.co/ayushirathour/chest-xray-pneumonia-detection}
|
| 237 |
-
}
|
| 238 |
-
```
|
| 239 |
-
|
| 240 |
-
## π©βπ» Creator
|
| 241 |
-
|
| 242 |
-
**Ayushi Rathour** - Biotechnology Graduate specializing in AI for Healthcare
|
| 243 |
-
|
| 244 |
-
[](https://github.com/ayushirathour) [](https://www.linkedin.com/in/ayushi-rathour/) [](mailto:ayushirathour1804@gmail.com)
|
| 245 |
-
|
| 246 |
-
---
|
| 247 |
-
|
| 248 |
-
**π¬ Advancing Medical AI Through Rigorous Validation** | Built with β€οΈ for the research community
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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