Spaces:
Running
Running
A newer version of the Gradio SDK is available: 6.24.0
π DEPLOYMENT GUIDE
Deploy to Hugging Face Spaces (FREE)
Step 1: Create Hugging Face Account
- Go to https://huggingface.co
- Sign up (free)
- Verify email
Step 2: Create New Space
- Click your profile β "New Space"
- Settings:
- Name:
anemia-screening(or your choice) - License: MIT
- SDK: Gradio
- Hardware: CPU Basic (free) β upgrade to GPU if slow
- Visibility: Public (or Private)
- Name:
- 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.pklandbest.ptare 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.txthas all dependencies - Restart the Space
YOLO errors
- Ensure
best.ptis 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):
- Go to Space Settings
- Add custom domain
- Configure DNS CNAME record
Data Collection
Collected data saves to collected_data.csv in the Space.
To download:
- Go to "Files" tab
- Click
collected_data.csv - Download
For production, connect to Google Sheets or a database instead.
Updating the Model
When you retrain with more data:
- Download new
model.pklfrom Colab - Upload to Space (replace old file)
- 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.