Skip to content
variablePotatoPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

8 Commits

Folders and files

Repository files navigation

AI-Powered Pneumonia Detection System

Professional-grade medical AI web application for chest X-ray pneumonia detection.

🎯 Overview

  • Modern React Frontend with premium healthcare UI
  • FastAPI Backend with robust API design
  • Modular ML Integration for easy model swapping
  • Hospital-grade Security and validation
  • Batch Processing capabilities
  • Professional Medical Design

✨ Key Features

  • βœ… Multi-image upload with drag-and-drop
  • βœ… Batch prediction support (up to 10 images)
  • βœ… Two-column UI (Upload + Results)
  • βœ… Real-time confidence scores
  • βœ… Professional medical color palette
  • βœ… Responsive mobile design
  • βœ… Comprehensive error handling
  • βœ… REST API with full documentation
  • βœ… Model placeholder integration

πŸ“ Project Structure

antigravity/
β”œβ”€β”€ backend/                 # FastAPI backend
β”‚   β”œβ”€β”€ main.py             # Application entry point
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ predict.py      # Prediction endpoints
β”‚   β”‚   └── __init__.py
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ model_loader.py # Model loading placeholder
β”‚   β”‚   └── __init__.py
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ preprocess.py   # Image preprocessing pipeline
β”‚   β”‚   └── __init__.py
β”‚   └── requirements.txt     # Python dependencies
β”‚
β”œβ”€β”€ frontend/                # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”‚   β”œβ”€β”€ App.jsx         # Root component
β”‚   β”‚   β”œβ”€β”€ index.jsx       # Entry point
β”‚   β”‚   └── index.css       # Tailwind styles
β”‚   β”œβ”€β”€ public/             # Static assets
β”‚   β”œβ”€β”€ package.json        # Node dependencies
β”‚   β”œβ”€β”€ vite.config.js      # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js  # Tailwind configuration
β”‚   └── index.html          # HTML entry point
β”‚
β”œβ”€β”€ README.md               # This file
β”œβ”€β”€ SETUP.md               # Setup instructions
└── API_DOCS.md            # API documentation

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • npm or yarn

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run development server:
python main.py

Backend will be available at http://localhost:8000

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create environment file .env:
REACT_APP_API_URL=http://localhost:8000/api
  1. Run development server:
npm run dev

Frontend will be available at http://localhost:3000

πŸ”§ Model Integration

The application includes placeholder model integration. To integrate your trained Kaggle model:

Step 1: Prepare Your Model

mkdir -p backend/models
# Copy your trained model to: backend/models/pneumonia_model.h5 (or .pkl, .pt)

Step 2: Update Model Loader

Edit backend/services/model_loader.py:

# Replace the load_model() function with:
def load_model():
    import tensorflow as tf
    model = tf.keras.models.load_model('models/pneumonia_model.h5')
    return model

# Replace the predict() function with:
def predict(model, preprocessed_images):
    predictions = model.predict(preprocessed_images)
    results = []
    for pred in predictions:
        results.append({
            "prediction": "Pneumonia" if pred[0] > 0.5 else "Normal",
            "confidence": float(max(pred) * 100),
            "probability_normal": float(pred[0]),
            "probability_pneumonia": float(pred[1])
        })
    return results

Step 3: Update Preprocessing

Edit backend/utils/preprocess.py to match your model's training preprocessing

πŸ“Š API Endpoints

Health Check

GET /health
Response: {"status": "running"}

Predict

POST /api/predict
Content-Type: multipart/form-data

Request:
- files: List of image files (JPG, JPEG, PNG)

Response:
[
  {
    "filename": "xray1.png",
    "prediction": "Pneumonia",
    "confidence": 96.4,
    "probability_normal": 0.036,
    "probability_pneumonia": 0.964,
    "status": "success"
  }
]

Configuration

GET /api/predict/config
Response: Configuration and constraints

🎨 UI Components

  • Navbar - Navigation with logo
  • Hero - Landing section with CTA
  • UploadArea - Drag-and-drop upload zone
  • ImagePreviewCard - Image thumbnail preview
  • PredictionCard - Result display with confidence
  • LoadingSpinner - Loading indicator
  • ErrorMessage - Error notification
  • HowItWorks - Process explanation
  • Features - Product features showcase
  • Footer - Footer with medical disclaimer

πŸ”’ Security

  • File type validation (JPG, JPEG, PNG only)
  • File size limit (10 MB per file)
  • Batch size limit (10 files maximum)
  • CORS enabled for safe cross-origin requests
  • Input sanitization
  • Error handling without exposing internals

πŸ“± Responsive Design

  • Mobile-first approach
  • Tablet optimization
  • Desktop full-featured layout
  • Touch-friendly UI elements
  • Flexible grid system

⚠️ Medical Disclaimer

IMPORTANT: ANTIGRAVITY is an AI-assisted screening tool and is NOT a substitute for professional medical diagnosis.

All predictions must be:

  • Reviewed by qualified healthcare professionals
  • Used only as a screening aid
  • Followed by proper clinical evaluation
  • Documented in patient records

🚒 Deployment

Backend Deployment (Gunicorn)

gunicorn -w 4 -b 0.0.0.0:8000 main:app

Frontend Deployment

npm run build
# Deploy dist/ directory to static hosting

See DEPLOYMENT.md for detailed deployment guidance.

πŸ“š Documentation

πŸ› οΈ Development

Running Tests

# Backend tests
cd backend
pytest

# Frontend tests
cd frontend
npm test

Code Quality

# Linting
cd frontend
npm run lint

πŸ“ˆ Performance

  • Batch processing: Up to 10 images per request
  • Image preprocessing: < 1s per image
  • Model inference: Depends on your model
  • Response time: Typically < 5s for batch of 10

🀝 Contributing

  1. Create feature branch
  2. Implement changes
  3. Test thoroughly
  4. Submit pull request

πŸ“„ License

This project is licensed under the MIT License.

πŸ“ž Support

For issues, questions, or suggestions:

  • Open GitHub issue
  • Contact: [email]
  • Documentation: [docs]

ANTIGRAVITY - AI-powered chest X-ray screening for pneumonia detection

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages