nilotpaldhar2004/fingerprint-blood-group
๐ฉธ FingerPrint2BloodGroup
Research Demo โ Predicting blood group from fingerprint images using Transfer Learning (ResNet-50).
   
โ ๏ธ Disclaimer
This project is a research and portfolio demonstration only. Current validation accuracy is ~87.22% (test: 87.00%) โ while this is strong performance, this model is not suitable for clinical or diagnostic use. Do not make any medical decisions based on its output.
๐ง What It Does
Upload a fingerprint image โ the model predicts the corresponding blood group along with:
- Predicted class with confidence score
- Class probability bar chart (all 8 blood groups)
- Grad-CAM heatmap showing which regions of the fingerprint the model focused on
๐๏ธ Model Architecture
๐ Training Results
Training set: 4200 samples | Val: 900 | Test: 900 | Batch: 32 | Early stop: epoch 86/100
๐๏ธ Project Structure
fingerprint-blood-group/
โ
โโโ main.py # FastAPI backend + Grad-CAM logic
โโโ static/
โ โโโ index.html # Frontend UI
โโโ blood_group_resnet50_best.pth # Trained model weights
โโโ blood_group_classes.npy # Label encoder classes
โโโ requirements.txt
โโโ Dockerfile
โโโ .gitignore
โโโ .github/
โโโ workflows/
โโโ deploy_to_hf.yml # GitHub Actions โ HF Space auto-deploy๐ Local Setup
# Clone
git clone https://github.com/YOUR_GITHUB_USERNAME/fingerprint-blood-group.git
cd fingerprint-blood-group
# Install dependencies
pip install -r requirements.txt
# Place model files in root directory:
# blood_group_resnet50_best.pth
# blood_group_classes.npy
# Run
uvicorn main:app --reload --port 8000
# Open browser
# http://localhost:8000๐ณ Docker
docker build -t fingerprint-blood-group .
docker run -p 7860:7860 fingerprint-blood-group
# Open: http://localhost:7860โ๏ธ Deploy to HuggingFace Space
- Create a new Space on HuggingFace:
fingerprint-blood-groupwith Docker SDK - Add these GitHub Secrets to your repository:
HF_TOKENโ your HuggingFace write tokenHF_USERNAMEโ your HuggingFace username- Push to
mainbranch โ GitHub Actions handles the rest automatically
Important: Model weight files (.pth,.npy) are in.gitignore. Upload them manually to your HF Space via the web UI or use Git LFS.
๐ ๏ธ Tech Stack
- Backend: FastAPI, PyTorch, torchvision, OpenCV
- Frontend: Vanilla HTML/CSS/JS (no framework)
- Explainability: Grad-CAM on
layer4[-1]of ResNet-50 - Deployment: Docker ยท HuggingFace Spaces ยท GitHub Actions
๐ค Author
Nilotpal โ CS | AI/ML HuggingFace ยท GitHub
๐ License
MIT License โ free to use for educational and research purposes.
