How dkg-2/pneumox-net works
Project type and purpose
• This is a lightweight ML-driven web application (“full‐stack” in the sense of front-end UI + back-end inference) for binary classification of chest X-rays (Pneumonia vs Normal).
• It uses Gradio to expose a user interface, TensorFlow/Keras (MobileNetV2) for inference, and standard Python libraries for image processing and visualization.
File structure
• Top-level files:
• app.py → the Gradio application entry point (handles uploads, calls the model, returns results)
• model.h5 → pre-trained MobileNetV2 weights
• requirements.txt → Python dependencies (Gradio, TensorFlow, OpenCV/Pillow, Matplotlib, Seaborn, etc.)
• README.md → project overview, tech stack, usage
• .gitattributes → Git configuration
• No separate “frontend” or “backend” directories; the code is consolidated in app.py.
• No database or external REST services; inference is local.
README for additional insights
• Deployment target: Hugging Face Spaces using Gradio.
• Core flow: user uploads X-ray → preprocessing (OpenCV/Pillow) → model inference (TensorFlow/Keras MobileNetV2) → postprocessing/visualization (Matplotlib/Seaborn) → display prediction.
a. Main components:
1) User Interface (Gradio front end in the browser)
2) Application Server (app.py):
– Preprocessing Module
– Inference Module (loads model.h5 into TensorFlow/Keras)
– Postprocessing & Visualization Module
3) Model Storage (model.h5 on disk)
4) External Dependencies (TensorFlow, OpenCV/Pillow, Matplotlib, Seaborn)
5) Hosting Environment (Hugging Face Spaces container)
b. Relationships & interactions:
• Browser ↔ Gradio UI
• Gradio UI → HTTP RPC to app.py
• app.py loads model.h5 at startup
• Preprocessing → Inference → Postprocessing pipeline
• app.py → returns results to Gradio UI → browser display
c. Architectural patterns / design principles:
• Single‐process service with clear modules (preprocess, infer, postprocess).
• Separation of concerns: UI vs ML logic.
• Lazy model load or load‐once at startup for performance.
• Stateless inference (no session management or DB).
d. Technologies/frameworks:
• Gradio (UI + API layer)
• TensorFlow/Keras (model inference)
• MobileNetV2 (transfer‐learning architecture)
• OpenCV/Pillow (image I/O & preprocessing)
• Matplotlib/Seaborn (visualization)
• Hugging Face Spaces (deployment)