Ultra-quality single-image-to-3D-mesh generation based on Tencent Hunyuan3D-2.1
Geometry-only pipeline — generates smooth, clean, optimized 3D meshes from a single input image. All texture-related components have been removed to focus entirely on mesh quality.
Image → Background Removal → DINOv2 Conditioning → DiT Diffusion
→ ShapeVAE Decode → Marching Cubes → Post-Processing → Export
| Component | Description | Source |
|---|---|---|
| ImageConditioner | DINOv2-Giant feature extraction at 518×518 | Adapted from Hunyuan3D |
| Hunyuan3DDiT | Dual-stream + single-stream flow-matching DiT | Adapted from Hunyuan3D |
| ShapeVAE | Latent → SDF → Marching Cubes mesh extraction | Adapted from Hunyuan3D |
| PostProcessingPipeline | 8-step mesh repair, smoothing, decimation | New |
| Exporters | GLB, OBJ, STL, PLY format export | New |
git clone legendsaurav/MODEL_GENERATOR_V2 MODEL_GENERATOR_V2
cd MODEL_GENERATOR_V2
pip install -r requirements.txt
pip install -e .
# Basic generation
python generate.py --image input.png --output output.glb
# With quality preset
python generate.py --image input.png --preset ultra --output output.glb
# Custom parameters
python generate.py --image input.png --steps 75 --resolution 448 \
--format obj --output output.obj
# Multi-format export
python generate.py --image input.png --preset ultra \
--format glb obj stl ply --output-dir ./outputs
# Full options
python generate.py \
--image input.png \
--preset ultra \
--steps 100 \
--resolution 512 \
--format glb obj stl ply \
--output-dir ./outputs \
--seed 42 \
--device cuda:0 \
--fp16 \
--target-faces 150000
from MODEL_GENERATOR_V2.generation import GeometryPipeline
from MODEL_GENERATOR_V2.postprocessing import PostProcessingPipeline
from MODEL_GENERATOR_V2.exporters import get_exporter
from MODEL_GENERATOR_V2.configs.presets import get_preset_config
# Load pipeline
config = get_preset_config('ultra')
pipeline = GeometryPipeline.from_pretrained(
model_path='tencent/Hunyuan3D-2',
preset='ultra',
)
# Generate raw mesh
mesh = pipeline('input.png')
# Post-process
postprocessor = PostProcessingPipeline(config.postprocessing)
mesh = postprocessor(mesh)
# Export to multiple formats
for fmt in ['glb', 'obj', 'stl', 'ply']:
exporter = get_exporter(fmt)
exporter.export(mesh, f'output.{fmt}')
| Preset | Steps | Resolution | Target Faces | Smoothing | Approx. Time | VRAM |
|---|---|---|---|---|---|---|
| FAST | 25 | 256 | 50K | 3 iterations | ~15s | ~6GB |
| BALANCED | 50 | 384 | 100K | 5 iterations | ~45s | ~10GB |
| ULTRA | 100 | 512 | 200K | 10 iterations | ~120s | ~16GB |
The 8-step post-processing chain significantly improves raw generation output:
MODEL_GENERATOR_V2/
├── configs/ # Configuration dataclasses and quality presets
├── core/ # ML models (DiT, VAE, conditioner, scheduler)
│ └── vae/ # ShapeVAE, attention blocks, surface extractor
├── preprocessing/ # Background removal, image processing
├── generation/ # Pipeline orchestration, diffusion runner, model loading
├── postprocessing/ # Mesh repair, smoothing, subdivision, decimation, validation
├── exporters/ # GLB, OBJ, STL, PLY exporters
├── utils/ # Logging, timing, device management, memory
├── tests/ # Unit, integration, and inference tests
├── outputs/ # Generated mesh output directory
├── generate.py # CLI entry point
├── requirements.txt # Python dependencies
└── setup.py # Package installation
System Requirements (Linux only): You may need to install OpenGL libraries for pymeshlab to work correctly.
sudo apt-get update && sudo apt-get install -y libgl1 libglx-mesa0
Core ML: torch, transformers, diffusers, accelerate, einops, safetensors
3D Processing: trimesh, pymeshlab, scikit-image
Image Processing: Pillow, opencv-python, rembg
Config: omegaconf, pyyaml
Removed from Hunyuan3D: xatlas, gradio, fastapi, Real-ESRGAN, custom rasterizer, differentiable renderer, Blender
# Unit tests (no GPU required)
pytest tests/unit/ -v
# Integration tests (no GPU required)
pytest tests/integration/ -v
# All tests with coverage
pytest tests/ -v --cov=MODEL_GENERATOR_V2
# Inference tests (requires GPU + model weights)
pytest tests/inference/ -v
The system loads pretrained weights from HuggingFace:
tencent/Hunyuan3D-2tencent/Hunyuan3D-2.1Key weight subfolders:
hunyuan3d-dit-v2-0 — DiT model weightshunyuan3d-vae-v2-0-withencoder — ShapeVAE weightsBased on Tencent Hunyuan3D-2, licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT.
7 commits
Python
100.0%
Ultra-quality single-image-to-3D-mesh generation based on Tencent Hunyuan3D-2.1
Geometry-only pipeline — generates smooth, clean, optimized 3D meshes from a single input image. All texture-related components have been removed to focus entirely on mesh quality.
Image → Background Removal → DINOv2 Conditioning → DiT Diffusion
→ ShapeVAE Decode → Marching Cubes → Post-Processing → Export
| Component | Description | Source |
|---|---|---|
| ImageConditioner | DINOv2-Giant feature extraction at 518×518 | Adapted from Hunyuan3D |
| Hunyuan3DDiT | Dual-stream + single-stream flow-matching DiT | Adapted from Hunyuan3D |
| ShapeVAE | Latent → SDF → Marching Cubes mesh extraction | Adapted from Hunyuan3D |
| PostProcessingPipeline | 8-step mesh repair, smoothing, decimation | New |
| Exporters | GLB, OBJ, STL, PLY format export | New |
git clone legendsaurav/MODEL_GENERATOR_V2 MODEL_GENERATOR_V2
cd MODEL_GENERATOR_V2
pip install -r requirements.txt
pip install -e .
# Basic generation
python generate.py --image input.png --output output.glb
# With quality preset
python generate.py --image input.png --preset ultra --output output.glb
# Custom parameters
python generate.py --image input.png --steps 75 --resolution 448 \
--format obj --output output.obj
# Multi-format export
python generate.py --image input.png --preset ultra \
--format glb obj stl ply --output-dir ./outputs
# Full options
python generate.py \
--image input.png \
--preset ultra \
--steps 100 \
--resolution 512 \
--format glb obj stl ply \
--output-dir ./outputs \
--seed 42 \
--device cuda:0 \
--fp16 \
--target-faces 150000
from MODEL_GENERATOR_V2.generation import GeometryPipeline
from MODEL_GENERATOR_V2.postprocessing import PostProcessingPipeline
from MODEL_GENERATOR_V2.exporters import get_exporter
from MODEL_GENERATOR_V2.configs.presets import get_preset_config
# Load pipeline
config = get_preset_config('ultra')
pipeline = GeometryPipeline.from_pretrained(
model_path='tencent/Hunyuan3D-2',
preset='ultra',
)
# Generate raw mesh
mesh = pipeline('input.png')
# Post-process
postprocessor = PostProcessingPipeline(config.postprocessing)
mesh = postprocessor(mesh)
# Export to multiple formats
for fmt in ['glb', 'obj', 'stl', 'ply']:
exporter = get_exporter(fmt)
exporter.export(mesh, f'output.{fmt}')
| Preset | Steps | Resolution | Target Faces | Smoothing | Approx. Time | VRAM |
|---|---|---|---|---|---|---|
| FAST | 25 | 256 | 50K | 3 iterations | ~15s | ~6GB |
| BALANCED | 50 | 384 | 100K | 5 iterations | ~45s | ~10GB |
| ULTRA | 100 | 512 | 200K | 10 iterations | ~120s | ~16GB |
The 8-step post-processing chain significantly improves raw generation output:
MODEL_GENERATOR_V2/
├── configs/ # Configuration dataclasses and quality presets
├── core/ # ML models (DiT, VAE, conditioner, scheduler)
│ └── vae/ # ShapeVAE, attention blocks, surface extractor
├── preprocessing/ # Background removal, image processing
├── generation/ # Pipeline orchestration, diffusion runner, model loading
├── postprocessing/ # Mesh repair, smoothing, subdivision, decimation, validation
├── exporters/ # GLB, OBJ, STL, PLY exporters
├── utils/ # Logging, timing, device management, memory
├── tests/ # Unit, integration, and inference tests
├── outputs/ # Generated mesh output directory
├── generate.py # CLI entry point
├── requirements.txt # Python dependencies
└── setup.py # Package installation
System Requirements (Linux only): You may need to install OpenGL libraries for pymeshlab to work correctly.
sudo apt-get update && sudo apt-get install -y libgl1 libglx-mesa0
Core ML: torch, transformers, diffusers, accelerate, einops, safetensors
3D Processing: trimesh, pymeshlab, scikit-image
Image Processing: Pillow, opencv-python, rembg
Config: omegaconf, pyyaml
Removed from Hunyuan3D: xatlas, gradio, fastapi, Real-ESRGAN, custom rasterizer, differentiable renderer, Blender
# Unit tests (no GPU required)
pytest tests/unit/ -v
# Integration tests (no GPU required)
pytest tests/integration/ -v
# All tests with coverage
pytest tests/ -v --cov=MODEL_GENERATOR_V2
# Inference tests (requires GPU + model weights)
pytest tests/inference/ -v
The system loads pretrained weights from HuggingFace:
tencent/Hunyuan3D-2tencent/Hunyuan3D-2.1Key weight subfolders:
hunyuan3d-dit-v2-0 — DiT model weightshunyuan3d-vae-v2-0-withencoder — ShapeVAE weightsBased on Tencent Hunyuan3D-2, licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT.
7 commits
Python
100.0%