AI-Powered Pneumonia Detection System
Professional-grade medical AI web application for chest X-ray pneumonia detection.
- 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
- β 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
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
- Python 3.8+
- Node.js 16+
- npm or yarn
- Navigate to backend directory:
cd backend- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run development server:
python main.pyBackend will be available at http://localhost:8000
- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Create environment file
.env:
REACT_APP_API_URL=http://localhost:8000/api
- Run development server:
npm run devFrontend will be available at http://localhost:3000
The application includes placeholder model integration. To integrate your trained Kaggle model:
mkdir -p backend/models
# Copy your trained model to: backend/models/pneumonia_model.h5 (or .pkl, .pt)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 resultsEdit backend/utils/preprocess.py to match your model's training preprocessing
GET /health
Response: {"status": "running"}
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"
}
]
GET /api/predict/config
Response: Configuration and constraints
- 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
- 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
- Mobile-first approach
- Tablet optimization
- Desktop full-featured layout
- Touch-friendly UI elements
- Flexible grid system
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
gunicorn -w 4 -b 0.0.0.0:8000 main:appnpm run build
# Deploy dist/ directory to static hostingSee DEPLOYMENT.md for detailed deployment guidance.
- SETUP.md - Detailed setup instructions
- API_DOCS.md - Complete API reference
- MODEL_INTEGRATION.md - Model integration guide
- DEPLOYMENT.md - Deployment instructions
# Backend tests
cd backend
pytest
# Frontend tests
cd frontend
npm test# Linting
cd frontend
npm run lint- 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
- Create feature branch
- Implement changes
- Test thoroughly
- Submit pull request
This project is licensed under the MIT License.
For issues, questions, or suggestions:
- Open GitHub issue
- Contact: [email]
- Documentation: [docs]
ANTIGRAVITY - AI-powered chest X-ray screening for pneumonia detection