Spaces:
Running
Running
File size: 3,017 Bytes
cb47ee6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # π 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**
```bash
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**.
|