Hunyuan3D 2.1 圖片轉 GLB 工作流程教學
Building an Image-to-GLB Workflow with Hunyuan3D 2.1
Hunyuan3D 2.1 的圖片轉 GLB 工作流程包括本機 Gradio 生成及 FastAPI 整合,可由單張圖片生成網格並匯出 GLB。
Turning a single image into a GLB model
Image-to-3D is useful when a project needs a fast 3D starting point instead of a manually built model from scratch.
Tencent’s Hunyuan3D 2.1 is an open-source image-to-3D system. Given a source image, it can generate a mesh and export a result in GLB format. That makes it relevant for product prototypes, web-based 3D previews, game-prop experiments, and early AR concepts.
The result should be treated as a starting asset, not a finished production model. The model has to infer surfaces that are not visible in the input image, so quality still depends heavily on the source image and the final use case.
Official project:
https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1
Start with the right image
For an initial test, choose an image with:
- One clearly visible object
- A simple or removable background
- Sharp object boundaries
- Even lighting
- Limited reflections and motion blur A clean product image usually produces a more predictable model than a crowded lifestyle photo. Transparent materials, thin wires, hands, dense text, and overlapping objects are more difficult because the system has less reliable visual information to work with. Local setup The official Hunyuan3D 2.1 repository lists Python 3.10 and PyTorch 2.5.1 with CUDA 12.4 as its tested environment. git clone https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1.git cd Hunyuan3D-2.1
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
--index-url https://download.pytorch.org/whl/cu124
pip install -r requirements.txt
The full texture-generation workflow includes additional dependencies. For a first test, it is better to validate that shape generation works before spending time on texture generation and rendering settings.
Run the local interface
Hunyuan3D 2.1 includes a local Gradio interface. After the environment and model files are ready, launch it with:
python3 gradio_app.py \
--model_path tencent/Hunyuan3D-2.1 \
--subfolder hunyuan3d-dit-v2-1 \
--texgen_model_path tencent/Hunyuan3D-2.1 \
--low_vram_mode
Upload a single image, generate the initial model, and export the output as GLB.
The first goal is not to create the perfect asset. It is to confirm that the full path works:
- Input image is loaded correctly.
- The system generates a mesh.
- The GLB file exports successfully.
- The model opens in Blender, a web viewer, or the target engine. Calling the local API For developers integrating the workflow into another application, Hunyuan3D also includes a FastAPI server.
Start the server:
python api_server.py
Then open the local API documentation:
http://localhost:8081/docs
A minimal Python request can look like this:
import base64import requestswith open("input_image.png", "rb") as file: image_data = base64.b64encode(file.read()).decode()payload = { "image": image_data, "texture": True, "seed": 42, "type": "glb"}response = requests.post( "http://localhost:8081/generate", json=payload, timeout=600)response.raise_for_status()with open("output_model.glb", "wb") as file: file.write(response.content)
The seed is useful when comparing changes. Keep it fixed while testing a new image or parameter, then change it only when you want alternative results.
What to check after export
A generated GLB file can look good from the source angle but still have issues elsewhere. Before using it in a project, inspect:
- The overall silhouette
- Hidden and back-facing surfaces
- Texture seams
- Object orientation and scale
- Polygon density
- Whether the file opens correctly in the intended viewer or engine For a quick product preview, the output may already be sufficient. For a game asset, animation pipeline, 3D print, or commercial library, expect additional cleanup in a tool such as Blender. GPU memory is part of the workflow According to the official repository, shape generation needs about 10 GB of VRAM, texture generation about 21 GB, and the combined workflow around 29 GB.
That is why a sensible first test is:
- Use one simple image.
- Test shape generation first.
- Confirm GLB export.
- Add texture generation only after the basic flow is stable. This approach makes it easier to tell whether a problem comes from the source image, model setup, GPU memory, or the texture stage. Final thoughts Image-to-3D is becoming a practical shortcut for early 3D work, but input quality still matters more than most people expect.
A cleaner image with one obvious object will usually save more time than endlessly changing parameters. Once the first GLB file is generated, inspect it in the actual environment where it will be used and treat it as an editable starting point.
Official API reference:
https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1/blob/main/API_DOCUMENTATION.md
Disclosure: I’m building GanAI360, a Chinese-language AI resource site. I also collected a more detailed Hunyuan3D guide covering image-to-3D generation, ComfyUI workflows, model setup, and GLB export here:https://ganai360.com/news/comfyui-hunyuan3d-2-1-workflow/
來源:DEV Community · dev.to