Spaces:
Runtime error
Runtime error
File size: 6,159 Bytes
26f8b9a |
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# Deployment Guide - New HF Space
## Step 1: Create New HF Space
1. Go to https://huggingface.co/new-space
2. Fill in details:
- **Space name**: `game-asset-generator-pro-v2` (or your choice)
- **License**: MIT
- **SDK**: Gradio
- **Hardware**: L4 GPU (24GB VRAM)
- **Visibility**: Public or Private
3. Click "Create Space"
## Step 2: Clone the Space Repository
```powershell
# Clone your new space
git clone https://huggingface.co/spaces/YOUR_USERNAME/game-asset-generator-pro-v2
cd game-asset-generator-pro-v2
```
## Step 3: Copy Files
```powershell
# Copy all files from huggingface-space-v2
Copy-Item -Recurse D:\KIRO\Projects\XStudios\huggingface-space-v2\* .
# Verify files
Get-ChildItem -Recurse
```
## Step 4: Configure Space
Create `README.md` header (HF Space metadata):
```yaml
---
title: 3D Asset Generator Pro V2
emoji: ๐ฎ
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
hardware: l4
---
```
## Step 5: Push to HF Space
```powershell
# Initialize git (if not already)
git init
# Add all files
git add .
# Commit
git commit -m "Initial deployment - Streamlined architecture"
# Add remote (if not already added)
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/game-asset-generator-pro-v2
# Push
git push -u origin main
```
## Step 6: Monitor Deployment
1. Go to your Space URL: `https://huggingface.co/spaces/YOUR_USERNAME/game-asset-generator-pro-v2`
2. Watch the build logs
3. Wait for "Running" status (~5-10 minutes)
## Step 7: Test the Space
### Basic Test
1. Enter prompt: "medieval knight"
2. Select quality: "Fast"
3. Click "Generate Asset"
4. Verify 3D model appears
### Full Test Suite
- [ ] All quality presets work
- [ ] Caching works (same prompt twice)
- [ ] Error handling works (invalid inputs)
- [ ] Blender optimization works
- [ ] Rate limiting works
- [ ] UI is responsive
## Troubleshooting
### Build Fails
**Check logs for:**
- Missing dependencies โ Update `requirements.txt`
- Import errors โ Check module structure
- Blender not found โ Verify Dockerfile
**Common fixes:**
```powershell
# Update requirements
pip freeze > requirements.txt
# Test imports locally
python -c "from core import AssetPipeline"
```
### Runtime Errors
**Check Space logs:**
1. Click "Logs" tab in HF Space
2. Look for error messages
3. Check GPU memory usage
**Common issues:**
- OOM errors โ Reduce quality preset
- Timeout errors โ Increase GPU duration
- API errors โ Check Hunyuan3D Space status
### Blender Not Working
**Verify Blender installation:**
```powershell
# In Space terminal (if available)
which blender
blender --version
```
**If missing:**
- Update Dockerfile to install Blender
- Or disable Blender optimization (will skip post-processing)
## Configuration Options
### Environment Variables
Add to Space settings:
- `BLENDER_PATH=/usr/bin/blender`
- `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`
### Hardware Settings
**Recommended:**
- **GPU**: L4 (24GB VRAM) - Optimal for FLUX + Hunyuan3D
- **CPU**: 8 cores
- **RAM**: 32GB
- **Storage**: 50GB
**Minimum:**
- **GPU**: T4 (16GB VRAM) - May have OOM issues
- **CPU**: 4 cores
- **RAM**: 16GB
- **Storage**: 20GB
## Performance Tuning
### If Generation is Slow
1. **Reduce quality presets:**
- Edit `core/config.py`
- Lower `flux_steps` and `hunyuan_steps`
2. **Disable Blender optimization:**
- Comment out Blender processing in `core/pipeline.py`
3. **Increase GPU duration:**
- Edit `@spaces.GPU(duration=X)` decorators
- Increase from 35s/90s to higher values
### If OOM Errors Occur
1. **Enable CPU offload:**
- Edit `generators/flux.py`
- Add `pipe.enable_sequential_cpu_offload()`
2. **Reduce batch size:**
- Lower texture resolution in presets
- Reduce octree resolution
3. **Clear cache more frequently:**
- Edit `utils/cache.py`
- Reduce `CACHE_EXPIRY_HOURS`
## Monitoring
### Check Space Health
**Metrics to monitor:**
- Generation success rate
- Average generation time
- GPU memory usage
- Cache hit rate
- Error rate
**HF Space dashboard shows:**
- Total requests
- Active users
- GPU usage
- Build status
### User Feedback
**Collect feedback on:**
- Generation quality
- Speed/performance
- UI usability
- Error messages
- Feature requests
## Maintenance
### Regular Tasks
**Daily:**
- Check error logs
- Monitor GPU usage
- Verify cache is working
**Weekly:**
- Clean old cache files
- Update dependencies
- Review user feedback
**Monthly:**
- Update models (FLUX, Hunyuan3D)
- Optimize performance
- Add new features
### Updates
**To update the Space:**
```powershell
# Make changes locally
# Test changes
python app.py
# Commit and push
git add .
git commit -m "Update: description of changes"
git push
```
## Comparison with Old Space
| Feature | Old Space | New Space | Status |
|---------|-----------|-----------|--------|
| Code Size | 2,481 lines | 960 lines | โ
61% reduction |
| Architecture | Monolithic | Modular | โ
Improved |
| Type Safety | None | Full | โ
Added |
| Error Handling | Basic | Comprehensive | โ
Improved |
| Dependencies | 20+ | 10 | โ
50% reduction |
| Maintainability | Low | High | โ
Much better |
## Success Criteria
**Space is successful if:**
- โ
Builds without errors
- โ
Generates assets successfully
- โ
No OOM errors
- โ
Cache works (60% quota savings)
- โ
UI is responsive
- โ
Error messages are clear
- โ
Performance is good (<90s for High quality)
## Next Steps
After successful deployment:
1. Share Space URL with team
2. Collect user feedback
3. Monitor performance for 24 hours
4. Optimize based on real usage
5. Consider migrating old Space if all goes well
## Support
**If you need help:**
1. Check HF Space logs
2. Review error messages
3. Test locally first
4. Check GPU memory with `nvidia-smi`
5. Review MIGRATION_GUIDE.md
**Common resources:**
- HF Spaces docs: https://huggingface.co/docs/hub/spaces
- Gradio docs: https://gradio.app/docs
- FLUX docs: https://huggingface.co/black-forest-labs/FLUX.1-dev
- Hunyuan3D docs: https://huggingface.co/tencent/Hunyuan3D-2.1
|