Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.22.0
Lung Detector
A Gradio web app that detects lung diseases from chest X-ray images using a CNN model.
Run & Operate
PORT=8000 python3 app.pyβ start the Gradio app (workflow: "Lung Detector")pip install -r requirements.txtβ install Python dependencies
Stack
- Python 3.11
- Gradio (UI)
- TensorFlow / Keras (CNN model inference)
- Pillow, NumPy (image preprocessing)
model_setup.pyβ file path resolver (local + HuggingFace Hub)
Where things live
app.pyβ main Gradio applicationmodel_setup.pyβ maps filenames to local paths (or HF Hub downloads)model_config.jsonβ HuggingFace Hub config (hub_repo_id, hub_files)cnn_model_lung_detection.kerasβ the trained CNN modelrequirements.txtβ Python dependencies
Architecture decisions
- Always load model files via
model_setup.paths["filename"]β never hard-coded paths - Model input: 128Γ128 RGB, normalized to [0, 1]
- Model output: 4-class softmax (COVID-19, Normal, Viral Pneumonia, Lung Opacity)
- CSS + theme passed to
demo.launch()(Gradio 6.0 API) - Port read from
PORTenv var, defaulting to 7860
Product
Users upload a chest X-ray image. The app runs CNN inference and displays:
- Primary finding label (COVID-19 / Normal / Viral Pneumonia / Lung Opacity)
- Confidence percentage
- Clinical description of the finding
- Probability bar chart for all 4 classes
User preferences
- Pure Python project β no TypeScript, React, or database scaffolding
- Flat file tree (no lib/, no artifacts/ for the Python app)
- Medical tool visual style: dark background, thin letters, professional
- Always use
model_setup.paths["<filename>"]for file loading
Gotchas
- Port 8080 is used by the API server artifact; use 8000 for the Python app
- Gradio 6.0: pass
cssandthemetolaunch(), notBlocks() - CUDA warnings at startup are expected (CPU inference only)
cnn_model_lung_detection.kerasβ 4 output classes with softmax activation