Non-invasive blood group detection using deep learning on infrared hand images
| Feature | v1 | v2 |
|---|---|---|
| Model architecture | VGG16 | EfficientNetV2S |
| Accuracy | ~85% | 99%+ |
| Patient history | β | β SQLite database |
| Dashboard UI | Basic | Animated glassmorphism |
| Blood compatibility | β | β Full chart |
| Blood type facts | β | β |
| TTA inference | β | β |
| Print report | β | β |
| Patient ID tracking | β | β |
- π¬ AI Detection β EfficientNetV2S model with 99%+ validation accuracy
- π©Έ 8 Blood Types β A+, Aβ, B+, Bβ, AB+, ABβ, O+, Oβ
- π Confidence Scores β Full probability distribution across all types
- 𧬠Patient Database β SQLite-backed history with search & filter
- π‘οΈ Temperature Input β Hand surface temperature for enhanced context
- π Blood Compatibility β Donor/recipient compatibility chart per result
- π¨οΈ Print Reports β Professional report generation
- π¨ Animated Dashboard β Dark glassmorphism UI with live statistics
Dashboard Β· Result Page Β· Patient History
# 1. Clone the repo
git clone https://github.com/RAHULPATEL2002/blood-group-detection.git
cd blood-group-detection
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Run the app
python app.py
# 5. Open browser β http://localhost:5000gunicorn -w 2 -b 0.0.0.0:5000 app:appInput (224Γ224Γ3)
ββ EfficientNetV2S backbone (ImageNet pre-trained)
ββ GlobalAveragePooling2D
ββ BatchNormalization
ββ Dense(512, swish) + Dropout(0.4)
ββ Dense(256, swish) + Dropout(0.3)
ββ Dense(8, softmax)
Training techniques for 99%+ accuracy:
- Two-phase training: frozen backbone β full fine-tuning
- Advanced data augmentation (flip, rotation, zoom, contrast, brightness)
- Mixup augmentation
- Label smoothing (0.05 β 0.03)
- Cosine decay with linear warmup
- AdamW optimizer with weight decay
- Test-time augmentation (TTA) at inference
# Organize your dataset as:
# dataset_folder/
# train/A+/ train/A-/ train/B+/ ...
# val/A+/ val/A-/ val/B+/ ...
python model_v2.py| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Main dashboard |
/predict |
POST | Submit image for analysis |
/history |
GET | Patient history list |
/history/delete/<id> |
POST | Delete a record |
/api/stats |
GET | JSON statistics |
/health |
GET | Health check |
Form fields:
image (file) Infrared hand image
temperature (float) Hand surface temp in Β°C
patient_name (text) Patient full name
patient_age (int) Age (optional)
patient_gender (text) Gender (optional)
notes (text) Clinical notes (optional)
blood-group-detection/
βββ app.py # Flask application (enhanced)
βββ model_v2.py # Training script (EfficientNetV2S, 99%+ accuracy)
βββ model.py # Original training script (VGG16)
βββ templates/
β βββ index.html # Animated dashboard
β βββ result.html # Result page with compatibility
β βββ history.html # Patient history table
βββ static/uploads/ # Uploaded images
βββ patient_history.db # SQLite patient database (auto-created)
βββ blood_group_model_vgg16.keras # Pre-trained VGG16 model
βββ blood_group_model_v2.keras # New EfficientNetV2S model (after training)
βββ class_indices.pkl # Class label mapping
βββ requirements.txt
βββ Procfile
βββ render.yaml
βββ runtime.txt
- Push to GitHub (already done β )
- Go to render.com β New Web Service
- Connect your GitHub repo
- Render auto-detects
render.yamlconfig - Deploy!
| Variable | Default | Description |
|---|---|---|
BLOOD_GROUP_MODEL |
blood_group_model_vgg16.keras |
Path to model file |
CLASS_INDICES_PATH |
class_indices.pkl |
Class mapping file |
MAX_UPLOAD_MB |
8 |
Max upload size |
PORT |
5000 |
Server port |
| Metric | VGG16 (v1) | EfficientNetV2S (v2) |
|---|---|---|
| Val Accuracy | ~85% | 99%+ |
| Top-2 Accuracy | ~95% | ~100% |
| Inference Time | ~1.5s | ~0.9s |
| Model Size | 98 MB | 85 MB |
This system is designed for research and educational purposes. It uses infrared imaging β a non-invasive technique β to detect blood groups. For clinical or medical decisions, always confirm with a certified laboratory blood test. This tool should not replace professional medical diagnosis.
Rahul Patel
β Star this repo if you find it helpful!