Xernive's picture
fix: revert to API client with better error handling (Hunyuan3D not pip-installable)
26f8b9a

A newer version of the Gradio SDK is available: 6.1.0

Upgrade

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

# 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

# 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):

---
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

# 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:

# 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:

# 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:

# 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: