This project implements a cutting-edge AI-powered medical image analysis system that leverages multiple fine tuned YOLO Nano segmentation model and Google's Gemini AI to detect various medical conditions from radiological images. The system provides real-time analysis, detailed reports, and professional medical insights for liver, brain, eye, kidney, and lung conditions.
- Introduction
- Features
- Supported Medical Conditions
- System Architecture
- Installation
- Configuration
- Usage
- API Endpoints
- Technologies Used
- Code Structure
- Contributing
- License
MediCure-AI revolutionizes medical imaging with AI-powered diagnostic precision. Our system combines state-of-the-art fine tuned YOLO Nano segmentation model with Google's Gemini AI to provide comprehensive analysis of medical scans including CT, MRI, X-ray, and ultrasound images. The platform is designed to assist healthcare professionals in making faster, more accurate diagnoses while generating detailed PDF reports for clinical documentation.
- Multi-Modal Medical Analysis: Support for liver, brain MRI, eye, kidney, and lung imaging
- Real-time Detection: Instant analysis with confidence scoring and bounding box visualization
- AI-Powered Insights: Integration with Google Gemini AI for professional medical interpretations
- Automated Report Generation: PDF reports with findings, confidence scores, and treatment recommendations
- Pseudo-Coloring: Advanced visualization techniques for better anomaly identification
- Web-Based Interface: User-friendly Flask web application
- Batch Processing: Support for multiple model analysis on single images
- Secure File Handling: Robust file upload and processing with validation
- Conditions Detected: Liver tumors, normal liver tissue
- Applications: Hepatocellular carcinoma detection, liver health assessment
- Conditions Detected: Brain tumors, anatomical structures
- Applications: Neurological disorder diagnosis, tumor detection
- Conditions Detected:
- Cataract
- Diabetic Retinopathy
- Glaucoma
- Normal eye conditions
- Applications: Ophthalmological screening, preventive care
- Conditions Detected: Kidney stones
- Applications: Urological assessment, stone detection
- Conditions Detected: Lung tumors/cancer
- Applications: Pulmonary oncology, early cancer detection
graph TD
A[Upload Medical Image] --> B[File Validation]
B --> C[Model Selection]
C --> D{Single Model or Multi-Model?}
D -->|Single| E[YOLO Model Processing]
D -->|Multi| F[All Models Processing]
E --> G[Detection & Visualization]
F --> G
G --> H[Pseudo-Coloring Application]
H --> I[Gemini AI Analysis]
I --> J[Generate PDF Report]
J --> K[Return Results]
graph TD
L[YOLO Models]
L --> M[Liver Model - liver_tumour.pt]
L --> N[Brain Model - brain_mri.pt]
L --> O[Eye Model - eye.pt]
L --> P[Kidney Model - kidney.pt]
L --> Q[Lung Model - lung cancer.pt]
- Image Upload & Validation: Secure file handling with format verification
- Multi-Model Detection: Parallel processing across specialized YOLO models
- Visualization Engine: Bounding box rendering with pseudo-coloring for anomalies
- AI Analysis: Google Gemini integration for medical insights
- Report Generation: Automated PDF creation with comprehensive findings
- Python 3.8 or later
- pip (Python package installer)
- CUDA-compatible GPU (recommended for faster inference)
git clone https://github.com/kknani24/medicure-ai-.git
cd medicure-ai-
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Install PyTorch with CUDA support (optional, for GPU acceleration)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# Install Ultralytics YOLO
pip install ultralytics
# Install additional packages
pip install flask opencv-python google-generativeai reportlab python-dotenv
Create a .env
file in the project root:
GEMINI_API_KEY=your_google_gemini_api_key_here
Ensure all YOLO model files are present:
├── liver_tumour.pt
├── brain_mri.pt
├── eye.pt
├── kidney.pt
└── lung cancer.pt
medicure-ai-/
├── app.py
├── .env
├── requirements.txt
├── static/
│ └── uploads/
├── templates/
│ └── index.html
├── models/
│ ├── liver_tumour.pt
│ ├── brain_mri.pt
│ ├── eye.pt
│ ├── kidney.pt
│ └── lung cancer.pt
└── README.md
python app.py
Open your browser and navigate to http://localhost:5000
- Select a medical image (PNG, JPG, JPEG formats supported)
- Choose a specific model or leave blank for multi-model analysis
- Click "Analyze Image" to process
- View results, AI insights, and download the PDF report
For programmatic access, you can also use the API endpoints directly:
import requests
# Upload and analyze image
files = {'file': open('medical_scan.jpg', 'rb')}
data = {'model': 'liver'} # Optional: specify model
response = requests.post('http://localhost:5000/detect', files=files, data=data)
result = response.json()
Analyzes uploaded medical images and returns detection results.
Parameters:
file
(required): Medical image file (PNG, JPG, JPEG)model
(optional): Specific model to use ('liver', 'brain_mri', 'eye', 'kidney', 'lung')
Response:
{
"message": "Detection completed",
"original_image": "/static/uploads/scan.jpg",
"processed_image": "/static/uploads/processed_scan.jpg",
"detections": {
"liver": [
{
"class": "tumor",
"confidence": 0.87,
"bbox": [150, 200, 300, 350]
}
]
},
"gemini_response": "AI medical analysis...",
"pdf_report": "/static/uploads/report_scan.pdf"
}
YOLO is a state-of-the-art real-time object detection system. In this project, we use specialized YOLO models trained on medical datasets for accurate detection of various pathological conditions. The models provide fast inference with high accuracy, making them ideal for clinical applications.
Google's Gemini AI provides advanced multimodal understanding capabilities. In our system, it analyzes medical images alongside detection results to generate professional medical insights, treatment recommendations, and diagnostic interpretations with the expertise of a seasoned clinician.
Flask serves as the web framework powering our medical analysis platform. Its lightweight nature and extensive ecosystem make it perfect for creating responsive web applications that can handle medical image processing workflows efficiently.
OpenCV handles all computer vision operations including image loading, processing, visualization, and pseudo-coloring. Its optimized algorithms ensure fast image manipulation and enhancement, crucial for real-time medical image analysis.
medicure-ai/
├── app.py # Main Flask application
├── static/
│ ├── uploads/ # Uploaded and processed images
│ └── css/ # Stylesheets
├── templates/
│ └── index.html # Web interface template
├── models/ # YOLO model files
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── README.md # Project documentation
allowed_file()
: Validates uploaded file formatsprocess_image()
: Main image processing pipelineprocess_multiple_model_results()
: Handles multi-model analysisgenerate_response_with_image()
: Interfaces with Gemini AIcreate_pdf_report()
: Generates comprehensive PDF reports
We welcome contributions to improve MediCure-AI! Here's how you can contribute:
- Fork the Repository
git fork https://github.com/kknani24/medicure-ai-.git
- Create a Feature Branch
git checkout -b feature/amazing-feature
- Make Your Changes
- Add new medical models
- Improve detection accuracy
- Enhance UI/UX
- Add new features
- Commit Your Changes
git commit -m "Add amazing feature"
- Push to the Branch
git push origin feature/amazing-feature
- Open a Pull Request
- Model Enhancement: Improve existing models or add new medical condition detection
- UI/UX Improvements: Enhance the web interface and user experience
- Performance Optimization: Optimize inference speed and memory usage
- Documentation: Improve documentation and add tutorials
- Testing: Add comprehensive test coverage
This project is licensed under the MIT License. See the LICENSE file for details.
© 2025 MediCure-AI. All rights reserved.
For questions, support, or collaboration opportunities, please open an issue or contact the development team.