Spaces:
Runtime error
Runtime error
Fix HF Spaces: app.py execution, add packages.txt and spaces library
Browse files- .dockerignore +46 -0
- DEPLOYMENT.md +208 -0
- FIXES_APPLIED.md +178 -0
- README.md +7 -2
- app.py +19 -6
- packages.txt +6 -0
- requirements.txt +3 -0
.dockerignore
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Git files
|
| 2 |
+
.git/
|
| 3 |
+
.gitignore
|
| 4 |
+
.gitattributes
|
| 5 |
+
|
| 6 |
+
# Python cache
|
| 7 |
+
__pycache__/
|
| 8 |
+
*.py[cod]
|
| 9 |
+
*$py.class
|
| 10 |
+
*.so
|
| 11 |
+
|
| 12 |
+
# Virtual environments
|
| 13 |
+
venv/
|
| 14 |
+
env/
|
| 15 |
+
ENV/
|
| 16 |
+
|
| 17 |
+
# IDE
|
| 18 |
+
.vscode/
|
| 19 |
+
.idea/
|
| 20 |
+
*.swp
|
| 21 |
+
*.swo
|
| 22 |
+
|
| 23 |
+
# macOS
|
| 24 |
+
.DS_Store
|
| 25 |
+
|
| 26 |
+
# Build artifacts
|
| 27 |
+
build/
|
| 28 |
+
dist/
|
| 29 |
+
*.egg-info/
|
| 30 |
+
|
| 31 |
+
# Cache directories
|
| 32 |
+
gradio_cache/
|
| 33 |
+
.cache/
|
| 34 |
+
|
| 35 |
+
# Output folders (will be regenerated)
|
| 36 |
+
hy3dshape/output_folder/
|
| 37 |
+
|
| 38 |
+
# Test files
|
| 39 |
+
demo.glb
|
| 40 |
+
demo_textured.glb
|
| 41 |
+
demo_textured.jpg
|
| 42 |
+
demo_textured.mtl
|
| 43 |
+
demo_textured_metallic.jpg
|
| 44 |
+
demo_textured_roughness.jpg
|
| 45 |
+
demo_untextured.glb
|
| 46 |
+
white_mesh_remesh.obj
|
DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Spaces Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
This guide helps you deploy Hunyuan3D-2.1 to Hugging Face Spaces.
|
| 5 |
+
|
| 6 |
+
## Files Created for HF Deployment
|
| 7 |
+
|
| 8 |
+
1. **app.py** - Main entry point that HF Spaces will execute
|
| 9 |
+
2. **packages.txt** - System-level dependencies (apt packages)
|
| 10 |
+
3. **.dockerignore** - Excludes unnecessary files from Docker build
|
| 11 |
+
4. **requirements.txt** - Updated with `spaces` library for ZeroGPU
|
| 12 |
+
|
| 13 |
+
## Pre-Deployment Checklist
|
| 14 |
+
|
| 15 |
+
### 1. Install Git LFS (Required for Large Files)
|
| 16 |
+
```bash
|
| 17 |
+
# On macOS
|
| 18 |
+
brew install git-lfs
|
| 19 |
+
|
| 20 |
+
# On Linux
|
| 21 |
+
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
|
| 22 |
+
sudo apt-get install git-lfs
|
| 23 |
+
|
| 24 |
+
# Initialize Git LFS
|
| 25 |
+
git lfs install
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
### 2. Verify Files
|
| 29 |
+
Make sure these files exist:
|
| 30 |
+
- β
app.py
|
| 31 |
+
- β
requirements.txt
|
| 32 |
+
- β
packages.txt
|
| 33 |
+
- β
README.md (with HF metadata)
|
| 34 |
+
- β
.gitattributes (for LFS)
|
| 35 |
+
- β
.dockerignore
|
| 36 |
+
|
| 37 |
+
## Deployment Steps
|
| 38 |
+
|
| 39 |
+
### Step 1: Stage All Files
|
| 40 |
+
```bash
|
| 41 |
+
cd /Users/hoangminh.ho/Works/research/Hunyuan-MT
|
| 42 |
+
git add .
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Step 2: Commit Changes
|
| 46 |
+
```bash
|
| 47 |
+
git commit -m "Deploy to HF Spaces: Add app.py, packages.txt, update requirements and README"
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Step 3: Push to Hugging Face
|
| 51 |
+
```bash
|
| 52 |
+
git push hf main
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
## Expected Build Process
|
| 56 |
+
|
| 57 |
+
When you push to HF Spaces, it will:
|
| 58 |
+
|
| 59 |
+
1. **Install System Packages** (from packages.txt)
|
| 60 |
+
- ffmpeg
|
| 61 |
+
- build-essential
|
| 62 |
+
- OpenCV dependencies
|
| 63 |
+
|
| 64 |
+
2. **Install Python Dependencies** (from requirements.txt)
|
| 65 |
+
- PyTorch with CUDA 12.4
|
| 66 |
+
- Gradio 5.33.0
|
| 67 |
+
- All model dependencies
|
| 68 |
+
- This can take 15-30 minutes
|
| 69 |
+
|
| 70 |
+
3. **Build Custom Extensions**
|
| 71 |
+
- Compile mesh painter
|
| 72 |
+
- Install custom rasterizer wheel
|
| 73 |
+
|
| 74 |
+
4. **Download Models** (on first run)
|
| 75 |
+
- Hunyuan3D-Shape model (~3.3GB)
|
| 76 |
+
- Hunyuan3D-Paint model (~2GB)
|
| 77 |
+
|
| 78 |
+
## Monitoring Deployment
|
| 79 |
+
|
| 80 |
+
1. **Check Build Logs:**
|
| 81 |
+
- Go to: https://huggingface.co/spaces/minhho/Hunyuan-MT
|
| 82 |
+
- Click "Building" or "Logs" tab
|
| 83 |
+
|
| 84 |
+
2. **Common Build Issues:**
|
| 85 |
+
|
| 86 |
+
**Issue**: Build timeout
|
| 87 |
+
- **Solution**: Go to Settings β Set timeout to 60 minutes
|
| 88 |
+
|
| 89 |
+
**Issue**: Out of memory during build
|
| 90 |
+
- **Solution**: This is usually temporary, HF will retry
|
| 91 |
+
|
| 92 |
+
**Issue**: CUDA version mismatch
|
| 93 |
+
- **Solution**: Already configured for CUDA 12.x in requirements.txt
|
| 94 |
+
|
| 95 |
+
**Issue**: Custom rasterizer fails to install
|
| 96 |
+
- **Solution**: The .whl file is already included for Python 3.10
|
| 97 |
+
|
| 98 |
+
## Post-Deployment
|
| 99 |
+
|
| 100 |
+
### Testing the Space
|
| 101 |
+
1. Wait for "Running" status
|
| 102 |
+
2. Upload an image
|
| 103 |
+
3. Click "Generate 3D"
|
| 104 |
+
4. Wait 30-60 seconds for generation
|
| 105 |
+
|
| 106 |
+
### Expected Performance
|
| 107 |
+
- **Shape Generation**: 20-30 seconds on A100
|
| 108 |
+
- **Texture Generation**: 30-40 seconds on A100
|
| 109 |
+
- **Total**: ~60-90 seconds per image
|
| 110 |
+
|
| 111 |
+
## Troubleshooting
|
| 112 |
+
|
| 113 |
+
### Space Won't Start
|
| 114 |
+
|
| 115 |
+
**Check:**
|
| 116 |
+
1. Build completed successfully (green checkmark)
|
| 117 |
+
2. No errors in logs
|
| 118 |
+
3. GPU is assigned (Settings β Hardware)
|
| 119 |
+
|
| 120 |
+
**Common Fixes:**
|
| 121 |
+
```bash
|
| 122 |
+
# If app doesn't start, check logs for:
|
| 123 |
+
# - Missing dependencies β Update requirements.txt
|
| 124 |
+
# - Import errors β Check Python path in app.py
|
| 125 |
+
# - CUDA errors β Verify GPU is allocated
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
### Model Loading Issues
|
| 129 |
+
|
| 130 |
+
If models fail to download:
|
| 131 |
+
1. Check internet connectivity in Space
|
| 132 |
+
2. Verify model path: `tencent/Hunyuan3D-2.1`
|
| 133 |
+
3. Check HF authentication (if model is gated)
|
| 134 |
+
|
| 135 |
+
### Performance Issues
|
| 136 |
+
|
| 137 |
+
If generation is slow:
|
| 138 |
+
1. Verify A100 GPU is assigned
|
| 139 |
+
2. Enable `--low_vram_mode` (already set in app.py)
|
| 140 |
+
3. Check ZeroGPU is working (logs should show "zero.startup()")
|
| 141 |
+
|
| 142 |
+
## Configuration Options
|
| 143 |
+
|
| 144 |
+
You can modify `app.py` to change settings:
|
| 145 |
+
|
| 146 |
+
```python
|
| 147 |
+
sys.argv = [
|
| 148 |
+
'app.py',
|
| 149 |
+
'--model_path', 'tencent/Hunyuan3D-2.1', # Model repository
|
| 150 |
+
'--subfolder', 'hunyuan3d-dit-v2-1', # Model subfolder
|
| 151 |
+
'--texgen_model_path', 'tencent/Hunyuan3D-2.1', # Texture model
|
| 152 |
+
'--port', '7860', # Port (don't change)
|
| 153 |
+
'--host', '0.0.0.0', # Host (don't change)
|
| 154 |
+
'--device', 'cuda', # Use CUDA
|
| 155 |
+
'--mc_algo', 'mc', # Marching cubes algo
|
| 156 |
+
'--cache-path', '/tmp/hunyuan3d_cache', # Cache location
|
| 157 |
+
'--low_vram_mode' # Enable VRAM optimization
|
| 158 |
+
]
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
## Hardware Requirements
|
| 162 |
+
|
| 163 |
+
### Minimum (Shape Only)
|
| 164 |
+
- GPU: T4 (16GB VRAM)
|
| 165 |
+
- RAM: 8GB
|
| 166 |
+
- Storage: 10GB
|
| 167 |
+
|
| 168 |
+
### Recommended (Shape + Texture)
|
| 169 |
+
- GPU: A100 (40GB VRAM)
|
| 170 |
+
- RAM: 16GB
|
| 171 |
+
- Storage: 20GB
|
| 172 |
+
|
| 173 |
+
## Support
|
| 174 |
+
|
| 175 |
+
If you encounter issues:
|
| 176 |
+
|
| 177 |
+
1. **Check HF Discussions**: https://huggingface.co/spaces/minhho/Hunyuan-MT/discussions
|
| 178 |
+
2. **Review Official Docs**: https://huggingface.co/docs/hub/spaces
|
| 179 |
+
3. **GitHub Issues**: Report bugs to the original repository
|
| 180 |
+
|
| 181 |
+
## Additional Notes
|
| 182 |
+
|
| 183 |
+
- **First run will be slow** due to model downloads
|
| 184 |
+
- **Subsequent runs will be faster** (models cached)
|
| 185 |
+
- **ZeroGPU**: Automatically manages GPU allocation
|
| 186 |
+
- **Persistent storage**: Use `/data` for persistent cache (requires persistent storage upgrade)
|
| 187 |
+
|
| 188 |
+
## Success Indicators
|
| 189 |
+
|
| 190 |
+
β
Space shows "Running" status
|
| 191 |
+
β
No errors in logs
|
| 192 |
+
β
Models downloaded successfully
|
| 193 |
+
β
Test image generates 3D mesh
|
| 194 |
+
β
Download buttons work
|
| 195 |
+
β
3D viewer displays correctly
|
| 196 |
+
|
| 197 |
+
## Update Procedure
|
| 198 |
+
|
| 199 |
+
To update your Space:
|
| 200 |
+
|
| 201 |
+
```bash
|
| 202 |
+
# Make changes locally
|
| 203 |
+
git add .
|
| 204 |
+
git commit -m "Update: description of changes"
|
| 205 |
+
git push hf main
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
HF Spaces will automatically rebuild and redeploy.
|
FIXES_APPLIED.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Spaces Deployment - Changes Summary
|
| 2 |
+
|
| 3 |
+
## Problem
|
| 4 |
+
After pushing to HF Spaces, the Space was not building or running properly.
|
| 5 |
+
|
| 6 |
+
## Root Causes Identified
|
| 7 |
+
|
| 8 |
+
1. **app.py was not executable** - It imported from gradio_app but didn't actually run anything
|
| 9 |
+
2. **Missing system dependencies** - No packages.txt file for apt packages
|
| 10 |
+
3. **Missing spaces library** - Required for ZeroGPU support on HF Spaces
|
| 11 |
+
4. **Incorrect README metadata** - Invalid field `python_version` in YAML header
|
| 12 |
+
|
| 13 |
+
## Fixes Applied
|
| 14 |
+
|
| 15 |
+
### 1. β
Fixed app.py
|
| 16 |
+
**Before:**
|
| 17 |
+
```python
|
| 18 |
+
from gradio_app import *
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
pass # Did nothing!
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
**After:**
|
| 24 |
+
```python
|
| 25 |
+
# Set up command-line arguments for HF Space
|
| 26 |
+
sys.argv = ['app.py', '--model_path', 'tencent/Hunyuan3D-2.1', ...]
|
| 27 |
+
|
| 28 |
+
# Actually import and run gradio_app
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
import gradio_app # This executes the main code
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
### 2. β
Created packages.txt
|
| 34 |
+
Added system dependencies required for building:
|
| 35 |
+
- ffmpeg
|
| 36 |
+
- libsm6, libxext6, libxrender-dev (for OpenCV)
|
| 37 |
+
- libgomp1 (for parallel processing)
|
| 38 |
+
- build-essential (for compiling C++ extensions)
|
| 39 |
+
|
| 40 |
+
### 3. β
Updated requirements.txt
|
| 41 |
+
Added:
|
| 42 |
+
```
|
| 43 |
+
spaces>=0.28.3 # Required for ZeroGPU support
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### 4. β
Fixed README.md
|
| 47 |
+
- Removed invalid `python_version: 3.10` field
|
| 48 |
+
- Added `license: other` field
|
| 49 |
+
- Added system requirements in description
|
| 50 |
+
|
| 51 |
+
### 5. β
Created .dockerignore
|
| 52 |
+
Optimizes build by excluding:
|
| 53 |
+
- Git files
|
| 54 |
+
- Python cache
|
| 55 |
+
- Build artifacts
|
| 56 |
+
- Test outputs
|
| 57 |
+
|
| 58 |
+
### 6. β
Created DEPLOYMENT.md
|
| 59 |
+
Complete deployment guide with:
|
| 60 |
+
- Pre-deployment checklist
|
| 61 |
+
- Step-by-step instructions
|
| 62 |
+
- Troubleshooting guide
|
| 63 |
+
- Configuration options
|
| 64 |
+
|
| 65 |
+
## Files Modified
|
| 66 |
+
- βοΈ app.py - Fixed to actually run the application
|
| 67 |
+
- βοΈ requirements.txt - Added spaces library
|
| 68 |
+
- βοΈ README.md - Fixed metadata and added requirements
|
| 69 |
+
|
| 70 |
+
## Files Created
|
| 71 |
+
- π packages.txt - System dependencies
|
| 72 |
+
- π .dockerignore - Build optimization
|
| 73 |
+
- π DEPLOYMENT.md - Deployment guide
|
| 74 |
+
|
| 75 |
+
## Next Steps
|
| 76 |
+
|
| 77 |
+
### 1. Commit and Push
|
| 78 |
+
```bash
|
| 79 |
+
# If Git LFS is not installed yet:
|
| 80 |
+
brew install git-lfs
|
| 81 |
+
git lfs install
|
| 82 |
+
|
| 83 |
+
# Stage all changes
|
| 84 |
+
git add .
|
| 85 |
+
|
| 86 |
+
# Commit
|
| 87 |
+
git commit -m "Fix HF Spaces deployment: app.py, packages.txt, spaces library"
|
| 88 |
+
|
| 89 |
+
# Push to HF Space
|
| 90 |
+
git push hf main
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
### 2. Monitor Build
|
| 94 |
+
1. Go to: https://huggingface.co/spaces/minhho/Hunyuan-MT
|
| 95 |
+
2. Click "Building" to watch logs
|
| 96 |
+
3. Wait 15-30 minutes for first build
|
| 97 |
+
|
| 98 |
+
### 3. Expected Build Timeline
|
| 99 |
+
- Installing system packages: 2-3 min
|
| 100 |
+
- Installing Python dependencies: 15-20 min
|
| 101 |
+
- Building custom extensions: 3-5 min
|
| 102 |
+
- First run (downloading models): 5-10 min
|
| 103 |
+
|
| 104 |
+
## What Should Happen Now
|
| 105 |
+
|
| 106 |
+
### Build Phase (15-30 minutes)
|
| 107 |
+
β
Install apt packages from packages.txt
|
| 108 |
+
β
Install Python packages from requirements.txt
|
| 109 |
+
β
Compile C++ extensions (mesh painter)
|
| 110 |
+
β
Install custom rasterizer wheel
|
| 111 |
+
|
| 112 |
+
### Runtime Phase (First Run)
|
| 113 |
+
β
Download Hunyuan3D-Shape model (~3.3GB)
|
| 114 |
+
β
Download Hunyuan3D-Paint model (~2GB)
|
| 115 |
+
β
Initialize ZeroGPU
|
| 116 |
+
β
Start Gradio interface on port 7860
|
| 117 |
+
|
| 118 |
+
### After Deployment
|
| 119 |
+
β
Space shows "Running" status
|
| 120 |
+
β
Interface loads with example images
|
| 121 |
+
β
Users can upload images and generate 3D models
|
| 122 |
+
|
| 123 |
+
## Troubleshooting
|
| 124 |
+
|
| 125 |
+
### If Build Fails
|
| 126 |
+
**Check logs for:**
|
| 127 |
+
- Missing dependencies β Add to requirements.txt or packages.txt
|
| 128 |
+
- Compilation errors β Check build-essential is installed
|
| 129 |
+
- Timeout β Increase build timeout in Settings
|
| 130 |
+
|
| 131 |
+
### If Space Won't Start
|
| 132 |
+
**Check:**
|
| 133 |
+
- Build completed (green checkmark)
|
| 134 |
+
- GPU allocated (Settings β Hardware β A100)
|
| 135 |
+
- No errors in application logs
|
| 136 |
+
|
| 137 |
+
### If Generation Fails
|
| 138 |
+
**Verify:**
|
| 139 |
+
- Models downloaded successfully
|
| 140 |
+
- CUDA is available
|
| 141 |
+
- Sufficient VRAM (A100 recommended)
|
| 142 |
+
|
| 143 |
+
## Configuration
|
| 144 |
+
|
| 145 |
+
The app.py now uses these default settings for HF Spaces:
|
| 146 |
+
- Model: tencent/Hunyuan3D-2.1
|
| 147 |
+
- GPU: CUDA
|
| 148 |
+
- VRAM Mode: Low (optimized)
|
| 149 |
+
- Cache: /tmp/hunyuan3d_cache
|
| 150 |
+
- Port: 7860 (required for HF)
|
| 151 |
+
|
| 152 |
+
## Performance Expectations
|
| 153 |
+
|
| 154 |
+
On A100 GPU:
|
| 155 |
+
- Shape generation: 20-30 seconds
|
| 156 |
+
- Texture generation: 30-40 seconds
|
| 157 |
+
- Total per image: ~60-90 seconds
|
| 158 |
+
|
| 159 |
+
## Success Criteria
|
| 160 |
+
|
| 161 |
+
β
Build completes without errors
|
| 162 |
+
β
Space status shows "Running"
|
| 163 |
+
β
Models download successfully
|
| 164 |
+
β
Test image generates 3D mesh
|
| 165 |
+
β
3D viewer displays correctly
|
| 166 |
+
β
Download buttons work
|
| 167 |
+
|
| 168 |
+
## Additional Resources
|
| 169 |
+
|
| 170 |
+
- HF Spaces Docs: https://huggingface.co/docs/hub/spaces
|
| 171 |
+
- Gradio Docs: https://gradio.app/docs/
|
| 172 |
+
- ZeroGPU Docs: https://huggingface.co/docs/hub/spaces-gpus
|
| 173 |
+
|
| 174 |
+
---
|
| 175 |
+
|
| 176 |
+
**Created:** October 8, 2025
|
| 177 |
+
**Status:** Ready for deployment
|
| 178 |
+
**Next Action:** Commit and push to HF Space
|
README.md
CHANGED
|
@@ -7,9 +7,8 @@ sdk: gradio
|
|
| 7 |
sdk_version: 5.33.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
python_version: 3.10
|
| 11 |
suggested_hardware: a100-large
|
| 12 |
-
|
| 13 |
tags:
|
| 14 |
- 3D
|
| 15 |
- text-to-3D
|
|
@@ -17,10 +16,16 @@ tags:
|
|
| 17 |
- mesh-generation
|
| 18 |
- PBR
|
| 19 |
- texture-synthesis
|
|
|
|
| 20 |
---
|
| 21 |
|
| 22 |
# Hunyuan3D-2.1: Image-to-3D Generation
|
| 23 |
|
| 24 |
Production-ready 3D asset generation with Physically-Based Rendering (PBR) textures.
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 7 |
sdk_version: 5.33.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
suggested_hardware: a100-large
|
| 11 |
+
license: other
|
| 12 |
tags:
|
| 13 |
- 3D
|
| 14 |
- text-to-3D
|
|
|
|
| 16 |
- mesh-generation
|
| 17 |
- PBR
|
| 18 |
- texture-synthesis
|
| 19 |
+
short_description: Image-to-3D Generation with PBR Materials
|
| 20 |
---
|
| 21 |
|
| 22 |
# Hunyuan3D-2.1: Image-to-3D Generation
|
| 23 |
|
| 24 |
Production-ready 3D asset generation with Physically-Based Rendering (PBR) textures.
|
| 25 |
|
| 26 |
+
**β οΈ System Requirements:**
|
| 27 |
+
- Python 3.10
|
| 28 |
+
- CUDA 12.x GPU (A100 recommended, 29GB VRAM for full functionality)
|
| 29 |
+
- ~20GB storage for models and dependencies
|
| 30 |
+
|
| 31 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,13 +1,26 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
Hugging Face Space entry point for Hunyuan3D-2.1
|
| 4 |
-
This file
|
| 5 |
"""
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
if __name__ == "__main__":
|
| 11 |
-
|
| 12 |
-
# This file serves as the HF Space entry point
|
| 13 |
-
pass
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
Hugging Face Space entry point for Hunyuan3D-2.1
|
| 4 |
+
This file sets up and runs the main gradio application.
|
| 5 |
"""
|
| 6 |
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
# Set default arguments for HF Space deployment
|
| 11 |
+
sys.argv = [
|
| 12 |
+
'app.py',
|
| 13 |
+
'--model_path', 'tencent/Hunyuan3D-2.1',
|
| 14 |
+
'--subfolder', 'hunyuan3d-dit-v2-1',
|
| 15 |
+
'--texgen_model_path', 'tencent/Hunyuan3D-2.1',
|
| 16 |
+
'--port', '7860',
|
| 17 |
+
'--host', '0.0.0.0',
|
| 18 |
+
'--device', 'cuda',
|
| 19 |
+
'--mc_algo', 'mc',
|
| 20 |
+
'--cache-path', '/tmp/hunyuan3d_cache',
|
| 21 |
+
'--low_vram_mode'
|
| 22 |
+
]
|
| 23 |
|
| 24 |
+
# Import and run the main gradio app
|
| 25 |
if __name__ == "__main__":
|
| 26 |
+
import gradio_app
|
|
|
|
|
|
packages.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
| 2 |
+
libsm6
|
| 3 |
+
libxext6
|
| 4 |
+
libxrender-dev
|
| 5 |
+
libgomp1
|
| 6 |
+
build-essential
|
requirements.txt
CHANGED
|
@@ -4,6 +4,9 @@
|
|
| 4 |
|
| 5 |
--extra-index-url https://download.blender.org/pypi/
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Build Tools
|
| 8 |
ninja==1.11.1.1
|
| 9 |
pybind11==2.13.4
|
|
|
|
| 4 |
|
| 5 |
--extra-index-url https://download.blender.org/pypi/
|
| 6 |
|
| 7 |
+
# Hugging Face Spaces Support
|
| 8 |
+
spaces>=0.28.3
|
| 9 |
+
|
| 10 |
# Build Tools
|
| 11 |
ninja==1.11.1.1
|
| 12 |
pybind11==2.13.4
|