Spaces:
Running
on
Zero
Running
on
Zero
Configure Model Hub repo IDs and add setup guide
Browse files- MODEL_HUB_SETUP.md +103 -0
- app.py +3 -2
MODEL_HUB_SETUP.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Setting Up Model Hub for Checkpoints
|
| 2 |
+
|
| 3 |
+
## Step-by-Step Guide
|
| 4 |
+
|
| 5 |
+
### Step 1: Create Model Hub Repository
|
| 6 |
+
|
| 7 |
+
1. **Go to**: https://huggingface.co/new
|
| 8 |
+
2. **Select**: "Model" (not Space or Dataset)
|
| 9 |
+
3. **Fill in**:
|
| 10 |
+
- **Repository name**: `starflow-3b-checkpoint`
|
| 11 |
+
- **Owner**: `GlobalStudio` (or your username)
|
| 12 |
+
- **Visibility**: Private (recommended) or Public
|
| 13 |
+
4. **Click**: "Create repository"
|
| 14 |
+
|
| 15 |
+
### Step 2: Upload Checkpoint to Model Hub
|
| 16 |
+
|
| 17 |
+
1. **Go to your Model repository**:
|
| 18 |
+
https://huggingface.co/GlobalStudio/starflow-3b-checkpoint
|
| 19 |
+
|
| 20 |
+
2. **Click**: "Files" tab
|
| 21 |
+
|
| 22 |
+
3. **Click**: "Add file" β "Upload files"
|
| 23 |
+
|
| 24 |
+
4. **Upload**: `starflow_3B_t2i_256x256.pth` (14GB)
|
| 25 |
+
- Drag and drop or browse
|
| 26 |
+
- Wait for upload (30-60 minutes)
|
| 27 |
+
- β
No storage limit issues in Model Hub!
|
| 28 |
+
|
| 29 |
+
### Step 3: Update app.py (Already Done!)
|
| 30 |
+
|
| 31 |
+
The app is already configured! Just make sure the repo ID matches:
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
IMAGE_CHECKPOINT_REPO = "GlobalStudio/starflow-3b-checkpoint"
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
If your repo name is different, update this line in `app.py`.
|
| 38 |
+
|
| 39 |
+
### Step 4: Test Your Space
|
| 40 |
+
|
| 41 |
+
1. **Go to your Space**: https://huggingface.co/spaces/GlobalStudio/starflow
|
| 42 |
+
2. **Wait for rebuild** (if app.py was updated)
|
| 43 |
+
3. **Open the Gradio interface**
|
| 44 |
+
4. **Enter a prompt** (no need to upload checkpoint!)
|
| 45 |
+
5. **Click "Generate Image"**
|
| 46 |
+
6. **First time**: Will download checkpoint (one-time, ~5-10 minutes)
|
| 47 |
+
7. **After that**: Uses cached checkpoint (fast!)
|
| 48 |
+
|
| 49 |
+
## How It Works
|
| 50 |
+
|
| 51 |
+
1. **First Request**:
|
| 52 |
+
- App checks for local checkpoint β Not found
|
| 53 |
+
- Downloads from Model Hub β `/tmp/checkpoints/`
|
| 54 |
+
- Caches it for future use
|
| 55 |
+
|
| 56 |
+
2. **Subsequent Requests**:
|
| 57 |
+
- Uses cached checkpoint β Fast!
|
| 58 |
+
- No download needed
|
| 59 |
+
|
| 60 |
+
3. **Cache Location**: `/tmp/checkpoints/` (persists in Space)
|
| 61 |
+
|
| 62 |
+
## Benefits
|
| 63 |
+
|
| 64 |
+
β
**No storage limit** - Model Hub designed for large files
|
| 65 |
+
β
**Free** - No cost for Model Hub storage
|
| 66 |
+
β
**Automatic caching** - Downloads once, uses forever
|
| 67 |
+
β
**Version control** - Can update checkpoints easily
|
| 68 |
+
β
**Shareable** - Can use across multiple Spaces
|
| 69 |
+
|
| 70 |
+
## Troubleshooting
|
| 71 |
+
|
| 72 |
+
### Issue: "Repository not found"
|
| 73 |
+
- **Solution**: Make sure repo ID matches exactly: `"username/repo-name"`
|
| 74 |
+
- Check: https://huggingface.co/GlobalStudio/starflow-3b-checkpoint exists
|
| 75 |
+
|
| 76 |
+
### Issue: "Download failed"
|
| 77 |
+
- **Solution**: Check internet connection, repo visibility (private repos need auth)
|
| 78 |
+
- For private repos, set HF_TOKEN in Space settings
|
| 79 |
+
|
| 80 |
+
### Issue: "Checkpoint not found"
|
| 81 |
+
- **Solution**: Verify filename matches exactly: `starflow_3B_t2i_256x256.pth`
|
| 82 |
+
- Check Model Hub Files tab to confirm filename
|
| 83 |
+
|
| 84 |
+
## For Video Model (Optional)
|
| 85 |
+
|
| 86 |
+
If you also have the video checkpoint:
|
| 87 |
+
|
| 88 |
+
1. **Create another Model repo**: `starflow-v-7b-checkpoint`
|
| 89 |
+
2. **Upload**: `starflow-v_7B_t2v_caus_480p_v3.pth`
|
| 90 |
+
3. **Update app.py**:
|
| 91 |
+
```python
|
| 92 |
+
VIDEO_CHECKPOINT_REPO = "GlobalStudio/starflow-v-7b-checkpoint"
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
## Summary
|
| 96 |
+
|
| 97 |
+
1. β
Create Model Hub repo
|
| 98 |
+
2. β
Upload checkpoint (14GB, no limit!)
|
| 99 |
+
3. β
App already configured
|
| 100 |
+
4. β
Test and enjoy!
|
| 101 |
+
|
| 102 |
+
The app will automatically download and cache the checkpoint on first use! π
|
| 103 |
+
|
app.py
CHANGED
|
@@ -29,8 +29,9 @@ DEFAULT_VIDEO_CHECKPOINT = "ckpts/starflow-v_7B_t2v_caus_480p_v3.pth"
|
|
| 29 |
|
| 30 |
# Model Hub repositories (if using Hugging Face Model Hub)
|
| 31 |
# Set these to your Model Hub repo IDs if you upload checkpoints there
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
def get_checkpoint_path(checkpoint_file, default_local_path, repo_id=None, filename=None):
|
| 36 |
"""Get checkpoint path, downloading from Hub if needed."""
|
|
|
|
| 29 |
|
| 30 |
# Model Hub repositories (if using Hugging Face Model Hub)
|
| 31 |
# Set these to your Model Hub repo IDs if you upload checkpoints there
|
| 32 |
+
# Format: "username/repo-name"
|
| 33 |
+
IMAGE_CHECKPOINT_REPO = "GlobalStudio/starflow-3b-checkpoint" # Update this after creating Model Hub repo
|
| 34 |
+
VIDEO_CHECKPOINT_REPO = "GlobalStudio/starflow-v-7b-checkpoint" # Update this after creating Model Hub repo
|
| 35 |
|
| 36 |
def get_checkpoint_path(checkpoint_file, default_local_path, repo_id=None, filename=None):
|
| 37 |
"""Get checkpoint path, downloading from Hub if needed."""
|