lung-detect / replit.md
drewinspirit's picture
Publish from Replit
9f1a43f verified
|
Raw
History Blame Contribute Delete
1.99 kB

A newer version of the Gradio SDK is available: 6.22.0

Upgrade

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["<filename>"] 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