Hunyuan3D-2: herramienta de código abierto de Tencent para la generación de modelos 3D de alta resolución

Introducción general

Hunyuan3D-2 是腾讯开发的一个开源项目,旨在通过文字或图像生成高分辨率的3D模型。它由两个核心部分组成:形状生成模型(Hunyuan3D-DiT)和纹理生成模型(Hunyuan3D-Paint)。用户可以输入文字描述或上传图片,生成带有细节纹理的3D数字资产。这个工具在 GitHub 上免费提供代码和预训练模型,最新版本于2025年3月18日更新。它支持多种型号,包括快速版和迷你版,适合不同设备使用。Hunyuan3D-2 被广泛应用于游戏开发、数字艺术和研究领域。

Hunyuan3D-2:腾讯开源的高分辨率3D模型生成工具

 

Lista de funciones

  • 支持从文字生成3D模型,用户输入描述即可生成对应几何形状。
  • 支持从图像生成3D模型,上传图片后生成带纹理的3D资产。
  • 提供高分辨率输出,模型细节清晰,纹理色彩鲜艳。
  • 包含形状生成模型(Hunyuan3D-DiT),负责生成基础几何结构。
  • 包含纹理生成模型(Hunyuan3D-Paint),为模型添加高分辨率纹理。
  • 支持多视图生成(Hunyuan3D-2mv),从多个角度优化模型。
  • 提供迷你版模型(Hunyuan3D-2mini),参数量仅0.6亿,运行更快。
  • 支持快速版模型(Fast),推理时间减半,效率更高。
  • 可集成Blender,通过插件直接生成和编辑3D模型。
  • 开源代码和模型,用户可自由下载和修改。

 

Utilizar la ayuda

Hunyuan3D-2 是一个功能强大的工具,需要一定的硬件和编程基础。以下是详细的安装和使用指南,帮助用户快速上手。

Proceso de instalación

  1. Preparación de entornos de hardware y software
    • 需要 NVIDIA GPU,支持 CUDA,显存至少 6GB(迷你版)或 12GB(标准版)。
    • 安装 Python 3.9 或以上版本。
    • Instala Git para descargar código.
  2. Descargar código y modelos
    • Se ejecuta en el terminal:
      git clone https://github.com/Tencent/Hunyuan3D-2.git
      cd Hunyuan3D-2
      
    • 从 Hugging Face 下载预训练模型:
      huggingface-cli download tencent/Hunyuan3D-2 --local-dir ./weights
      
  3. Instalación de dependencias
    • 安装基本依赖:
      pip install -r requirements.txt
      
    • 为纹理生成安装额外模块:
      cd hy3dgen/texgen/custom_rasterizer
      python3 setup.py install
      cd ../../..
      cd hy3dgen/texgen/differentiable_renderer
      python3 setup.py install
      
    • 可选安装 Flash Attention 加速:
      pip install ninja
      pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3
      
  4. Verificar la instalación
    • Ejecute el código de ejemplo:
      python minimal_demo.py
      
    • 如果成功输出模型,说明安装完成。

Funciones principales

1. 从图像生成3D模型

  • mover::
    • 准备一张图片(如 demo.png),放在 assets Carpeta.
    • 生成基础形状:
      from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
      from PIL import Image
      pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
      image = Image.open('assets/demo.png')
      mesh = pipeline(image=image, num_inference_steps=30)[0]
      mesh.export('output.glb')
      
    • 添加纹理:
      from hy3dgen.texgen import Hunyuan3DPaintPipeline
      pipeline = Hunyuan3DPaintPipeline.from_pretrained('tencent/Hunyuan3D-2')
      mesh = pipeline(mesh, image=image)
      mesh.export('textured.glb')
      
  • al final:生成带纹理的3D模型,保存为 .glb Documentación.

2. 从文字生成3D模型

  • mover::
    • 安装文字到图像模块(HunyuanDiT):
      huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled --local-dir ./weights/hunyuanDiT
      
    • Ejecuta el código:
      from hy3dgen.text2image import HunyuanDiTPipeline
      from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
      t2i = HunyuanDiTPipeline('Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled')
      i23d = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
      image = t2i('a cute rabbit')
      mesh = i23d(image, num_inference_steps=30)[0]
      mesh.export('rabbit.glb')
      
  • al final:根据文字生成3D模型。

3. 使用Gradio界面

  • mover::
    • 运行Gradio应用:
      python3 gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0 --texgen_model_path tencent/Hunyuan3D-2
      
    • Abra su navegador y visite la dirección local indicada.
    • 上传图片或输入文字,点击生成。
  • al final:通过网页界面生成模型,无需编写代码。

4. 使用API服务

  • mover::
    • Inicie el servidor API:
      python api_server.py --host 0.0.0.0 --port 8080
      
    • 发送请求生成模型:
      img_b64_str=$(base64 -i assets/demo.png)
      curl -X POST "http://localhost:8080/generate" \
      -H "Content-Type: application/json" \
      -d '{"image": "'"$img_b64_str"'"}' \
      -o test.glb
      
  • al final:通过API生成3D模型。

5. 使用Blender插件

  • montaje::
    • descargando blender_addon.py Documentación.
    • 打开Blender,在“编辑 > 偏好设置 > 插件”中安装并启用。
  • plataforma::
    • 启动API服务器(见上)。
    • 在Blender侧边栏找到“Hunyuan3D-2”。
    • 输入文字或上传图片,点击生成。
  • al final:直接在Blender中生成并编辑模型。

Función destacada Operación

多视图生成(Hunyuan3D-2mv)

  • Usa el comando:
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2mv', subfolder='hunyuan3d-dit-v2-mv')
mesh = pipeline(image=Image.open('assets/demo.png'))[0]
mesh.export('mv_model.glb')
  • 适合需要多角度精确建模的场景。

快速生成(Hunyuan3D-2mini)

  • Usa el comando:
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2mini', subfolder='hunyuan3d-dit-v2-mini')
mesh = pipeline(image=Image.open('assets/demo.png'))[0]
mesh.export('mini_model.glb')
  • 速度快,适合低配置设备。

advertencia

  • 确保GPU驱动和CUDA版本兼容,避免运行错误。
  • adaptar num_inference_steps 参数可优化生成质量。
  • 如遇问题,可在 GitHub Issues 或 Discord(https://discord.gg/dNBrdrGGMa)寻求帮助。

 

escenario de aplicación

  1. desarrollo de juegos
    开发者可以用它快速生成游戏中的角色或道具模型,减少人工建模时间。
  2. arte digital
    艺术家通过文字或图片生成3D作品,用于创作或NFT制作。
  3. 产品设计
    设计师上传产品图片,生成3D模型,用于展示或测试原型。
  4. Investigación educativa
    学生和研究人员用它探索AI生成3D的技术,验证扩散模型的效果。

 

CONTROL DE CALIDAD

  1. ¿Cuáles son los requisitos mínimos de hardware?
    迷你版需要6GB显存,标准版需要12GB,推荐NVIDIA GPU。
  2. ¿Está disponible en el mercado?
    开源版本限非商业用途,商用需联系 <hunyuan3d@tencent.com> 授权。
  3. 生成一个模型要多久?
    快速版约30秒,标准版1-2分钟,取决于硬件和设置。
© declaración de copyright

Artículos relacionados

Sin comentarios

Debe iniciar sesión para participar en los comentarios.
Acceder ahora
ninguno
Sin comentarios...