Skip to content

Commit b39ff81

Browse files
committed
feat: PneumoScan AI — chest X-ray pneumonia detection with Grad-CAM explainability
- MobileNetV2 transfer learning with two-phase fine-tuning - FastAPI backend with Pydantic validation, health checks, OpenAPI docs - Grad-CAM heatmap endpoint for model explainability - Modern glassmorphism frontend with drag-and-drop upload - Training pipeline with confusion matrix, ROC-AUC, classification report - 12 unit + integration tests (pytest) - Docker multi-stage build with health checks - GitHub Actions CI pipeline
0 parents  commit b39ff81

18 files changed

Lines changed: 1840 additions & 0 deletions

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
venv/
2+
__pycache__/
3+
data/
4+
*.pyc
5+
.env

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI — PneumoScan AI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint-and-test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Cache pip
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
29+
restore-keys: ${{ runner.os }}-pip-
30+
31+
- name: Install dependencies
32+
run: |
33+
pip install --upgrade pip
34+
pip install -r requirements.txt
35+
pip install pytest httpx anyio pytest-anyio
36+
37+
- name: Run unit tests
38+
run: pytest tests/ -v --tb=short
39+
40+
docker-build:
41+
runs-on: ubuntu-latest
42+
needs: lint-and-test
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Build Docker image
47+
run: docker build -t pneumoscan-ai:test .

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Virtual environment
2+
venv/
3+
.venv/
4+
env/
5+
6+
# Python
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
*.egg-info/
11+
dist/
12+
build/
13+
*.egg
14+
15+
# Model files (large binaries — download or train locally)
16+
model/*.h5
17+
model/*.keras
18+
19+
# Data (too large for GitHub — document download instructions in README)
20+
data/
21+
22+
# IDE
23+
.vscode/
24+
.idea/
25+
*.swp
26+
*.swo
27+
28+
# OS
29+
.DS_Store
30+
Thumbs.db
31+
desktop.ini
32+
33+
# Jupyter
34+
.ipynb_checkpoints/
35+
36+
# Logs & outputs
37+
*.log
38+
training/plots/
39+
runs/
40+
41+
# Environment variables
42+
.env

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ── Stage 1: Build ──
2+
FROM python:3.11-slim AS builder
3+
4+
WORKDIR /app
5+
6+
# Install system deps for OpenCV
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
libgl1-mesa-glx libglib2.0-0 && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
COPY requirements.txt .
12+
RUN pip install --no-cache-dir -r requirements.txt
13+
14+
# ── Stage 2: Runtime ──
15+
FROM python:3.11-slim
16+
17+
WORKDIR /app
18+
19+
RUN apt-get update && apt-get install -y --no-install-recommends \
20+
libgl1-mesa-glx libglib2.0-0 && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
# Copy installed packages from builder
24+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
25+
COPY --from=builder /usr/local/bin /usr/local/bin
26+
27+
# Copy application code
28+
COPY app/ app/
29+
COPY frontend/ frontend/
30+
COPY model/ model/
31+
32+
EXPOSE 8000
33+
34+
# Health check
35+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
36+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
37+
38+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)