anemia-screening / DEPLOYMENT_GUIDE.md
medtechdev's picture
Upload 5 files
cb47ee6 verified
|
Raw
History Blame Contribute Delete
3.02 kB

A newer version of the Gradio SDK is available: 6.24.0

Upgrade

πŸš€ DEPLOYMENT GUIDE

Deploy to Hugging Face Spaces (FREE)

Step 1: Create Hugging Face Account

  1. Go to https://huggingface.co
  2. Sign up (free)
  3. Verify email

Step 2: Create New Space

  1. Click your profile β†’ "New Space"
  2. Settings:
    • Name: anemia-screening (or your choice)
    • License: MIT
    • SDK: Gradio
    • Hardware: CPU Basic (free) β€” upgrade to GPU if slow
    • Visibility: Public (or Private)
  3. Click "Create Space"

Step 3: Upload Files

Upload these files to your Space:

your-space/
β”œβ”€β”€ app.py                  # Main application (provided)
β”œβ”€β”€ requirements.txt        # Dependencies (provided)
β”œβ”€β”€ README.md              # Space config (provided)
β”œβ”€β”€ model.pkl              # YOUR trained model from Colab
└── best.pt                # YOUR YOLO weights

Option A: Via Web Interface

  • Click "Files" tab β†’ "Add file" β†’ Upload each file

Option B: Via Git

git clone https://huggingface.co/spaces/YOUR_USERNAME/anemia-screening
cd anemia-screening
# Copy your files here
git add .
git commit -m "Initial deployment"
git push

Step 4: Wait for Build

  • Space will automatically install dependencies and start
  • Takes 2-5 minutes
  • Check "Logs" tab if errors occur

Step 5: Test

  • Once running, test with a sample image
  • Share the URL with others

Files You Need from Colab

After Colab finishes, download from your GDrive outputs/ folder:

File What it is
model.pkl Trained ML model

You already have:

File What it is
best.pt YOLO segmentation weights

Common Issues

"Model not found"

  • Ensure model.pkl and best.pt are in the root of your Space (not in a subfolder)

"Out of memory"

  • Upgrade to GPU hardware (still free tier available)
  • Or reduce image size in app.py

"Module not found"

  • Check requirements.txt has all dependencies
  • Restart the Space

YOLO errors

  • Ensure best.pt is a segmentation model (not detection-only)
  • Check ultralytics version compatibility

Custom Domain (Optional)

Hugging Face provides URL like: https://huggingface.co/spaces/YOUR_USERNAME/anemia-screening

For custom domain (e.g., anemia.yourdomain.com):

  1. Go to Space Settings
  2. Add custom domain
  3. Configure DNS CNAME record

Data Collection

Collected data saves to collected_data.csv in the Space.

To download:

  1. Go to "Files" tab
  2. Click collected_data.csv
  3. Download

For production, connect to Google Sheets or a database instead.


Updating the Model

When you retrain with more data:

  1. Download new model.pkl from Colab
  2. Upload to Space (replace old file)
  3. Space auto-restarts

Cost

Tier Cost Specs
CPU Basic FREE 2 vCPU, 16GB RAM
CPU Upgrade $0.03/hr 8 vCPU, 32GB RAM
GPU T4 $0.40/hr Good for heavy YOLO usage

For most use cases, FREE tier is sufficient.