CoolFace
Apppublic

nilotpaldhar2004/fingerprint-blood-group

sourceHugging Faceupdated 13d agoView on Hugging Face
0likes
App README

๐Ÿฉธ FingerPrint2BloodGroup

Research Demo โ€” Predicting blood group from fingerprint images using Transfer Learning (ResNet-50).

![HuggingFace Space](https://huggingface.co/spaces/nilotpaldhar2004/fingerprint-blood-group) ![Python](https://www.python.org/) ![FastAPI](https://fastapi.tiangolo.com/) ![PyTorch](https://pytorch.org/)


โš ๏ธ 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

ComponentDetail
BackboneResNet-50 (ImageNet pretrained)
BackboneFrozen (feature extractor only)
FC Head2048 โ†’ 1024 โ†’ 512 โ†’ 128 โ†’ 8
ActivationsReLU + Dropout (0.3, 0.2)
LossCrossEntropyLoss
OptimizerAdam (lr=0.0001)
Input size448 ร— 448 ร— 3
FC Head2048 โ†’ 1024 โ†’ BN โ†’ 512 โ†’ 128 โ†’ 64 โ†’ 8
Dropout0.4, 0.2, 0.1

๐Ÿ“Š Training Results

EpochVal Accuracy
134.67%
1067.11%
2284.00%
3185.78%
7486.11%
8587.22% โญ

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

bash
# 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

bash
docker build -t fingerprint-blood-group .
docker run -p 7860:7860 fingerprint-blood-group
# Open: http://localhost:7860

โ˜๏ธ Deploy to HuggingFace Space

  1. 1.Create a new Space on HuggingFace: fingerprint-blood-group with Docker SDK
  2. 2.Add these GitHub Secrets to your repository:
  3. 3.HF_TOKEN โ†’ your HuggingFace write token
  4. 4.HF_USERNAME โ†’ your HuggingFace username
  5. 5.Push to main branch โ€” 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.