腾讯混元hunyuan3d生成模型,本地搭建和使用

news2025/4/21 3:01:50

腾讯混元hunyuan3d生成模型,本地搭建和使用

  • 腾讯混元hunyuan3d生成模型,本地搭建和使用
    • 一. 话不多说,我们直接上本地部署的详细步骤
      • 1. 将仓库拉到本地
      • 2. 下载2个模型, 注意这里推荐 先使用conda创建环境后在安装modelscope进行下载模型
        • 2.1 关于第一个模型我们要在 Hunyuan3D-1 中创建文件夹 weights,然后将下载的模型都放进去。
        • 2.2 下载第二个模型Hunyuan3D-1\weights 下面新建文件夹 hunyuanDiT ,然后将下载下来的模型文件都放进去。
    • 二. 创建虚拟环境
      • 文生3D模型测试
      • 运行报错: 1. dust3r的问题
      • 运行报错2. ModuleNotFoundError: No module named 'roma'
      • 在 D:\Hunyuan3D-1 目录下面使用下面的命令进行生成,
      • 生成其他案例
      • 使用 Gradio
        • std模式
        • lite 模式
        • 然后可以通过 http://0.0.0.0:8080 访问演示。需要注意的是,这里的 0.0.0.0 需要是你的服务器 IP 的 X.X.X.X。

腾讯混元hunyuan3d生成模型,本地搭建和使用

腾讯终于出了一个比较厉害的AI,可以根据文本或者图片生成3d模型,下面是它的基本逻辑
在这里插入图片描述

一. 话不多说,我们直接上本地部署的详细步骤

1. 将仓库拉到本地

  • hunyuan3D 仓库 地址
mkdir Hunyuan3D-1
git clone https://github.com/Tencent/Hunyuan3D-1.git

2. 下载2个模型, 注意这里推荐 先使用conda创建环境后在安装modelscope进行下载模型

    1. AI-ModelScope/Hunyuan3D-1
    1. AI-ModelScope/HunyuanDiT-v1.1-Diffusers-Distilled
2.1 关于第一个模型我们要在 Hunyuan3D-1 中创建文件夹 weights,然后将下载的模型都放进去。
mkdir weights
这里推荐使用模型库来下载,而不是git

pip install modelscope

modelscope download --model AI-ModelScope/Hunyuan3D-1 --local_dir ./weights
2.2 下载第二个模型Hunyuan3D-1\weights 下面新建文件夹 hunyuanDiT ,然后将下载下来的模型文件都放进去。
mkdir ./weights/hunyuanDiT
这里推荐使用模型库来下载,而不是git

pip install modelscope

modelscope download --model AI-ModelScope/HunyuanDiT-v1.1-Diffusers-Distilled --local_dir  ./weights/hunyuanDiT

二. 创建虚拟环境

conda create -n hunyuan3d python=3.10
conda activate hunyuan3d

我的 cuda 是 12.1 把那本,使用下面命令安装 torch 等相关库

pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121

进入 D:\Hunyuan3D-1 目录下面,修改 requirements.txt 文件如下,安装下面的库

diffusers==0.31.0
numpy==1.26.4
transformers==4.46.2
rembg==2.0.59
tqdm==4.67.0
omegaconf==2.3.0
matplotlib==3.9.2
opencv-python==4.10.0.84
imageio==2.36.0
jaxtyping==0.2.34
einops==0.8.0
sentencepiece==0.2.0
accelerate==1.1.1
trimesh==4.5.2
PyMCubes==0.1.6
xatlas==0.0.9
libigl==2.5.1
# pytorch3d==0.7.6
git+https://github.com/facebookresearch/pytorch3d@stable
# nvdiffrast==0.3.3
git+https://github.com/NVlabs/nvdiffrast
open3d==0.18.0
ninja==1.11.1.1

执行下面的命令

pip install -r requirements.txt

文生3D模型测试

在 D:\Hunyuan3D-1 目录下面使用下面的命令进行生成。

python main.py  --text_prompt "一颗红色的柳树"  --save_folder ./outputs/liushu/  --max_faces_num 90000  --do_texture_mapping  --do_render

运行报错: 1. dust3r的问题

cd third_party
git clone --recursive https://github.com/naver/dust3r.git


去下载这个模型然后放到third_party/weights中
https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth

cd ../third_party/weights

运行报错2. ModuleNotFoundError: No module named ‘roma’

pip install roma

然后再次运行, 出现下面的命令

(hunyuan3d) PS D:\Hunyuan3D-1>  python main.py  --text_prompt "一颗红色的柳树"  --save_folder ./outputs/liushu/  --max_faces_num 90000  --do_texture_mapping  --do_render
Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:00<00:00, 15.47it/s]
image2views unet model {'Total': 2567463684, 'Trainable': 0}
None pretrained model for dinov2 encoder ...
DEFAULT_RENDERING_KWARGS
{'ray_start': 'auto', 'ray_end': 'auto', 'box_warp': 1.2, 'white_back': True, 'disparity_space_sampling': False, 'clamp_mode': 'softplus', 'sampler_bbox_min': -0.6, 'sampler_bbox_max': 0.6}
SVRMModel has 458.69 M params.
Load model successfully
=====> mv23d model init time: 3.292725086212158
view2mesh model {'Total': 458688965, 'Trainable': 0}
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████| 2/2 [00:01<00:00,  1.22it/s]
Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:06<00:00,  1.13it/s]
You have disabled the safety checker for <class 'diffusers.pipelines.pag.pipeline_pag_hunyuandit.HunyuanDiTPAGPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
text2image transformer model {'Total': 1516534048, 'Trainable': 0}
prompt is: 一颗红色的柳树
100%|██████████████████████████████████████████████████████████████████████████████████| 25/25 [00:18<00:00,  1.34it/s]
[HunYuan3D]-[text to image], cost time: 20.4802s
[HunYuan3D]-[remove background], cost time: 0.4009s
100%|██████████████████████████████████████████████████████████████████████████████████| 50/50 [00:13<00:00,  3.57it/s]
[HunYuan3D]-[image to views], cost time: 19.2197s
./outputs/liushu/
=====> Triplane forward time: 228.2751338481903
reduce face: 181869 -> 90000
=====> generate mesh with vertex shading time: 3.9938809871673584
Using xatlas to perform UV unwrapping, may take a while ...
=====> generate mesh with texture shading time: 16.907540321350098
[HunYuan3D]-[views to mesh], cost time: 249.4986s
[HunYuan3D]-[gif render], cost time: 9.6563s

总共显存消耗23.5G ,耗时 197s 左右。在 D:\Hunyuan3D-1\outputs\liushu 目录下面会有如下的目录:
在这里插入图片描述### 图生3D模型测试
我用了一张实景三维的照片 building.png ,如下:
在这里插入图片描述

在 D:\Hunyuan3D-1 目录下面使用下面的命令进行生成,

python main.py  --image_prompt ./demos/building.png  --save_folder ./outputs/test/  --max_faces_num 90000 --do_texture   --do_render

日志显示:

(hunyuan3d) PS D:\Hunyuan3D-1> python main.py  --image_prompt ./demos/building.png  --save_folder ./outputs/test/  --max_faces_num 90000 --do_texture   --do_render
Downloading data from 'https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx' to file 'C:\Users\13900K.u2net\u2net.onnx'.
100%|###############################################| 176M/176M [00:00<?, ?B/s]
Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:00<00:00,  9.86it/s]
image2views unet model {'Total': 2567463684, 'Trainable': 0}
None pretrained model for dinov2 encoder ...
DEFAULT_RENDERING_KWARGS
{'ray_start': 'auto', 'ray_end': 'auto', 'box_warp': 1.2, 'white_back': True, 'disparity_space_sampling': False, 'clamp_mode': 'softplus', 'sampler_bbox_min': -0.6, 'sampler_bbox_max': 0.6}
SVRMModel has 458.69 M params.
Load model successfully
=====> mv23d model init time: 4.093821048736572
view2mesh model {'Total': 458688965, 'Trainable': 0}
[HunYuan3D]-[remove background], cost time: 0.2740s
100%|██████████████████████████████████████████████████████████████████████████████████| 50/50 [00:13<00:00,  3.65it/s]
[HunYuan3D]-[image to views], cost time: 14.5492s
./outputs/test/
=====> Triplane forward time: 76.13665747642517
reduce face: 116886 -> 90000
D:\Hunyuan3D-1\svrm\ldm\models\svrm.py:198: RuntimeWarning: invalid value encountered in power
  color = [color[0]**color_ratio, color[1]**color_ratio, color[2]**color_ratio]
=====> generate mesh with vertex shading time: 2.1429805755615234
Using xatlas to perform UV unwrapping, may take a while ...
=====> generate mesh with texture shading time: 38.4321174621582
[HunYuan3D]-[views to mesh], cost time: 116.7878s
[HunYuan3D]-[gif render], cost time: 7.3994s

总共显存消耗23.4G ,耗时 135s 左右。在 D:\Hunyuan3D-1\outputs\test 目录下面会有如下的目录
在这里插入图片描述### 点击 mesh.obj 进行查看,是不是很牛X,可以自动生成一幢楼的 3d 模型。

生成其他案例

在这里插入图片描述

使用 Gradio

我们准备了两个版本的多视图生成,std 和 lite。

std模式
# std 
python3 app.py
python3 app.py --save_memory
lite 模式
python3 app.py --use_lite
python3 app.py --use_lite --save_memory
然后可以通过 http://0.0.0.0:8080 访问演示。需要注意的是,这里的 0.0.0.0 需要是你的服务器 IP 的 X.X.X.X。

参考:

  • https://huggingface.co/tencent/Hunyuan3D-1

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2299595.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

flutter image_cropper插件安装后 打包apk 报错命名空间问题

本篇文章主要讲解&#xff0c;Flutter安装完新依赖打包apk报错 A problem occurred configuring project ‘:image_cropper’. 命名空间问题的解决办法及原因说明。 日期&#xff1a;2025年2月15日 作者&#xff1a;任聪聪 一、报错现象&#xff1a; 报文信息&#xff1a; FAI…

2025-2-15-4.5 链表(基础题)

文章目录 4.6 链表&#xff08;基础题&#xff09;206. 反转链表92. 反转链表II24. 两两交换链表中的节点 4.6 链表&#xff08;基础题&#xff09; 有一天我做题忽然发现要把一个数组完全倒着翻过来很费劲&#xff0c;今天看&#xff0c;链表为此而生啊。 206. 反转链表 题目…

免费大模型网站

腾讯元宝 腾讯元宝 秘塔搜索 秘塔搜索 超算互联网 超算互联网回答速度很慢 Chatbot Arena Chatbot Arena 大模型竞技场。

macOS部署DeepSeek-r1

好奇&#xff0c;跟着网友们的操作试了一下 网上方案很多&#xff0c;主要参考的是这篇 DeepSeek 接入 PyCharm&#xff0c;轻松助力编程_pycharm deepseek-CSDN博客 方案是&#xff1a;PyCharm CodeGPT插件 DeepSeek-r1:1.5b 假设已经安装好了PyCharm PyCharm: the Pyth…

java八股文-mysql

1. 索引 1.1 什么是索引 索引(index)是帮助Mysql高效获取数据的数据结构(有序).提高数据的检索效率,降低数据库的IO成本(不需要全表扫描).通过索引列对数据进行排序,降低数据排序成本,降低了CPU的消耗. 1.2 mysql索引使用的B树? 1. 没有使用二叉树&#xff0c;最坏情况o&…

YOLO11环境搭建CUDA12.6

1.安装CUDA和cuDNN 1.1安装CUDA 1.1.1查看当前你的电脑显卡支持的最高CUDA版本,后面的安装不能超过它 通过命令的方式查看 输入nvidia-smi 1.1.2 下载CUDA 官网地址:CUDA Toolkit Archive | NVIDIA Developer 选择cuda_12.6.3 下载完成后,如下: 安装,一直下一步即可:…

OpenEuler学习笔记(三十二):在OpenEuler上搭建项目管理平台

在OpenEuler上搭建一个支持网页和手持访问、且支持用户功能自定义的项目管理平台&#xff0c;可以选择多种开源工具。以下是基于 Redmine 的搭建方案&#xff0c;Redmine 是一个灵活的项目管理工具&#xff0c;支持网页和移动端访问&#xff0c;并且可以通过插件扩展功能。 1.…

LabVIEW中的icon.llb 库

icon.llb 库位于 C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\Platform 目录下&#xff0c;是 LabVIEW 系统中的一个重要库。它的主要功能是与图标相关的操作&#xff0c;提供了一些实用的 VI 用于处理 LabVIEW 图标的显示、修改和设置。通过该库&#x…

React Hooks 的两个坑点

React Hooks 使用注意事项 Area: Hooks Date: February 10, 2025 Important: &#x1f31f;&#x1f31f;&#x1f31f; React Hooks 注意事项 要点&#xff1a; useState 的初始化值 只在第一次渲染时计算&#xff0c;并且这个值不会随着组件重新渲染而更新。useEffect 可…

Oracle启动与关闭(基础操作)

11g读取参数文件的顺序 9i之前&#xff0c;只有静态参数文件pfile文件。 9i开始&#xff0c;引入了动态参数文件spfile文件。 Windows&#xff1a; %ORACLE_HOME%\database SPFILEORCL就是动态参数文件 Linux&#xff1a; $ORACLE_HOME/dbs 11g中&#xff0c;启动数据库。…

新版电脑通过wepe安装系统

官方下载链接 WIN10下载 WIN11下载 微PE 启动盘制作 1&#xff1a;选择启动盘的设备 2&#xff1a;选择对应的U盘设备&#xff0c;点击安装就可以&#xff0c;建议大于8g 3&#xff1a;在上方链接下载需要安装的程序包&#xff0c;放入启动盘&#xff0c;按需 更新系统 …

Jmeter断言、关联、录制脚本

Jmeter断言 断言&#xff1a;让程序自动判断预期结果和实际结果是否一致 提示: Jmeter在请求的返回层面有个自动判断机制&#xff08;响应状态码 2xx:成功&#xff0c;4xx/5xx:失败&#xff09;但是请求成功了&#xff0c;并不代表结果一定正确&#xff0c;因此需要检测机制提…

SpringBoot速成(12)文章分类P15-P20

1.新增文章分类 1.Postman登录不上&#xff0c;可以从头registe->login一个新的成员:注意&#xff0c;跳转多个url时&#xff0c;post/get/patch记得修改成controller类中对应方法上写的 2.postman运行成功&#xff1a; 但表中不更新&#xff1a;细节有问题&#xff1a; c是…

RedHat8安装postgresql15和 postgis3.4.4记录及遇到的问题总结

安装包对照版本参考 UsersWikiPostgreSQLPostGIS – PostGIS 如果Red Hat系统上有旧版本的PostgreSQL需要卸载 在较新的Red Hat版本&#xff0c;使用dnf包管理器卸载&#xff1a;sudo dnf remove postgresql-server postgresql 旧版本&#xff0c;使用yum包管理器卸载 sudo y…

深入解析计算机网络请求头:常见类型与安全性影响

目录 1. Host 2. User-Agent 3. Cookie 4. Referer&#xff08;或 Referrer&#xff09; 5. Authorization 6. Content-Type 7. Content-Length 8. Origin 9. X-Forwarded-For (XFF) 10. Upgrade-Insecure-Requests 11. X-Frame-Options 12. Cache-Control 13. Ac…

VisoMaster整合包及汉化

VisoMaster是个图片及视频换脸工具&#xff0c;速度快&#xff0c;性能十分强大。 VisoMaster安装有2种方式&#xff0c;根据官网指引安装也十分简单&#xff0c;在此就不重复&#xff0c;只说说安装过程中要注意的事项&#xff1a; 1、自动安装&#xff1a;需要在网络十分畅…

从安装软件到flask框架搭建可视化大屏(二)——创建一个flask页面,搭建可视化大屏,零基础也可以学会

附录&#xff1a;所有文件的完整代码 models.py # models/models.py from flask_sqlalchemy import SQLAlchemydb SQLAlchemy()class User(db.Model):__tablename__ user # 显式指定表名为 userid db.Column(db.Integer, primary_keyTrue)username db.Column(db.String(…

[JVM篇]垃圾回收器

垃圾回收器 Serial Seral Old PartNew CMS(Concurrent Mark Sweep) Parallel Scavenge Parallel Old G1 ZGC

DeepSeek专题:DeepSeek-V1核心知识点速览

AIGCmagic社区知识星球是国内首个以AIGC全栈技术与商业变现为主线的学习交流平台&#xff0c;涉及AI绘画、AI视频、大模型、AI多模态、数字人以及全行业AIGC赋能等100应用方向。星球内部包含海量学习资源、专业问答、前沿资讯、内推招聘、AI课程、AIGC模型、AIGC数据集和源码等…

SpringBoot+shardingsphere实现按月分表功能

SpringBootshardingsphere实现按月分表功能 文章目录 前言 ShardingSphere 是一套开源的分布式数据库中间件解决方案&#xff0c;旨在简化数据库分片、读写分离、分布式事务等复杂场景的管理。它由 Apache 软件基金会支持&#xff0c;广泛应用于需要处理大规模数据的系统中 一…