# 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 application - `model_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 model - `requirements.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 `PORT` env 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[""]` for file loading ## Gotchas - Port 8080 is used by the API server artifact; use 8000 for the Python app - Gradio 6.0: pass `css` and `theme` to `launch()`, not `Blocks()` - CUDA warnings at startup are expected (CPU inference only) - `cnn_model_lung_detection.keras` — 4 output classes with softmax activation