Skip to content

Commit 1bb78a4

Browse files
committed
cog integration
1 parent cf284a3 commit 1bb78a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+187
-1807
lines changed

.github/workflows/push.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Push to Replicate
2+
3+
on:
4+
# Allows manual triggering from GitHub.com
5+
workflow_dispatch:
6+
inputs:
7+
model_name:
8+
description: "Model name to push (default: ndreca/hunyuan3d-2)"
9+
required: false
10+
default: "ndreca/hunyuan3d-2"
11+
# Uncomment the lines below to trigger on every push to main
12+
# push:
13+
# branches:
14+
# - main
15+
16+
jobs:
17+
push_to_replicate:
18+
name: Push to Replicate
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Free disk space
23+
uses: jlumbroso/free-disk-space@v1.3.1
24+
with:
25+
tool-cache: false
26+
docker-images: false
27+
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Cog
32+
uses: replicate/setup-cog@v2
33+
with:
34+
token: ${{ secrets.REPLICATE_API_TOKEN }}
35+
36+
- name: Push to Replicate
37+
run: |
38+
if [ -n "${{ github.event.inputs.model_name }}" ]; then
39+
cog push r8.im/${{ github.event.inputs.model_name }} --separate-weights
40+
else
41+
cog push
42+
fi

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,9 @@ gradio_cache/
166166
# and can be added to the global gitignore or merged into this file. For a more nuclear
167167
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168168
#.idea/
169+
170+
__pycache__
171+
.cog
172+
checkpoints
173+
output
174+
.DS_Store

README.md

Lines changed: 8 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
[中文阅读](README_zh_cn.md)
2-
[日本語で読む](README_ja_jp.md)
1+
# tencent/Hunyuan3D-2 Cog model
32

4-
<p align="center">
5-
<img src="./assets/images/teaser.jpg">
3+
This is an implementation of [tencent/Hunyuan3D-2](https://huggingface.co/spaces/tencent/Hunyuan3D-2) as a Cog model. [Cog packages machine learning models as standard containers.](https://github.com/replicate/cog)
64

7-
</p>
5+
Run a prediction:
6+
7+
cog predict -i image=@assets/demo.png
8+
9+
![demo](/assets/demo.png)
810

911
<div align="center">
1012
<a href=https://3d.hunyuan.tencent.com target="_blank"><img src=https://img.shields.io/badge/Official%20Site-333399.svg?logo=homepage height=22px></a>
@@ -26,11 +28,7 @@
2628
<br>
2729

2830

29-
> Join our **[Wechat](#)** and **[Discord](https://discord.gg/GuaWYwzKbX)** group to discuss and find help from us.
30-
31-
| Wechat Group | Xiaohongshu | X | Discord |
32-
|--------------------------------------------------|-------------------------------------------------------|---------------------------------------------|---------------------------------------------------|
33-
| <img src="assets/qrcode/wechat.png" height=140> | <img src="assets/qrcode/xiaohongshu.png" height=140> | <img src="assets/qrcode/x.png" height=140> | <img src="assets/qrcode/discord.png" height=140> |
31+
> Join our **[Discord](https://discord.gg/GuaWYwzKbX)** group to discuss and find help from us.
3432
3533
---
3634

@@ -73,11 +71,6 @@ including the open-source models and closed-source models in geometry details, c
7371
e.t.c.
7472

7573

76-
77-
<p align="center">
78-
<img src="assets/images/system.jpg">
79-
</p>
80-
8174
## ☯️ **Hunyuan3D 2.0**
8275

8376
### Architecture
@@ -86,10 +79,6 @@ Hunyuan3D 2.0 features a two-stage generation pipeline, starting with the creati
8679
synthesis of a texture map for that mesh. This strategy is effective for decoupling the difficulties of shape and
8780
texture generation and also provides flexibility for texturing either generated or handcrafted meshes.
8881

89-
<p align="left">
90-
<img src="assets/images/arch.jpg">
91-
</p>
92-
9382
### Performance
9483

9584
We have evaluated Hunyuan3D 2.0 with other open-source as well as close-source 3d-generation methods.
@@ -104,12 +93,6 @@ and the condition following ability.
10493
| Top Close-source Model3 | 3.218 | 51.574 | 295.691 | 0.799 |
10594
| Hunyuan3D 2.0 | **3.193** | **49.165** | **282.429** | **0.809** |
10695

107-
Generation results of Hunyuan3D 2.0:
108-
<p align="left">
109-
<img src="assets/images/e2e-1.gif" height=250>
110-
<img src="assets/images/e2e-2.gif" height=250>
111-
</p>
112-
11396
## 🎁 Models Zoo
11497

11598
It takes 11.5 GB VRAM for shape generation and 24.5 GB for shape and texture generation in total.
@@ -121,112 +104,11 @@ It takes 11.5 GB VRAM for shape generation and 24.5 GB for shape and texture gen
121104
| Hunyuan3D-Paint-v2-0 | Texture Generation Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-paint-v2-0) |
122105
| Hunyuan3D-Delight-v2-0 | Image Delight Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-delight-v2-0) |
123106

124-
## 🤗 Get Started with Hunyuan3D 2.0
125-
126-
You may follow the next steps to use Hunyuan3D 2.0 via:
127-
128-
- [Code](#code-usage)
129-
- [Gradio App](#gradio-app)
130-
- [API Server](#api-server)
131-
- [Blender Addon](#blender-addon)
132-
- [Official Site](#official-site)
133-
134-
### Install Requirements
135-
136-
Please install Pytorch via the [official](https://pytorch.org/) site. Then install the other requirements via
137-
138-
```bash
139-
pip install -r requirements.txt
140-
# for texture
141-
cd hy3dgen/texgen/custom_rasterizer
142-
python3 setup.py install
143-
cd ../../..
144-
cd hy3dgen/texgen/differentiable_renderer
145-
python3 setup.py install
146-
```
147-
148-
### Code Usage
149-
150-
We designed a diffusers-like API to use our shape generation model - Hunyuan3D-DiT and texture synthesis model -
151-
Hunyuan3D-Paint.
152-
153-
You could assess **Hunyuan3D-DiT** via:
154-
155-
```python
156-
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
157-
158-
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
159-
mesh = pipeline(image='assets/demo.png')[0]
160-
```
161-
162-
The output mesh is a [trimesh object](https://trimesh.org/trimesh.html), which you could save to glb/obj (or other
163-
format) file.
164-
165-
For **Hunyuan3D-Paint**, do the following:
166-
167-
```python
168-
from hy3dgen.texgen import Hunyuan3DPaintPipeline
169-
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
170-
171-
# let's generate a mesh first
172-
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
173-
mesh = pipeline(image='assets/demo.png')[0]
174-
175-
pipeline = Hunyuan3DPaintPipeline.from_pretrained('tencent/Hunyuan3D-2')
176-
mesh = pipeline(mesh, image='assets/demo.png')
177-
```
178-
179-
Please visit [minimal_demo.py](minimal_demo.py) for more advanced usage, such as **text to 3D** and **texture generation
180-
for handcrafted mesh**.
181-
182-
### Gradio App
183-
184-
You could also host a [Gradio](https://www.gradio.app/) App in your own computer via:
185-
186-
```bash
187-
python3 gradio_app.py
188-
```
189-
190-
### API Server
191-
192-
You could launch an API server locally, which you could post web request for Image/Text to 3D, Texturing existing mesh,
193-
and e.t.c.
194-
195-
```bash
196-
python api_server.py --host 0.0.0.0 --port 8080
197-
```
198-
199-
A demo post request for image to 3D without texture.
200-
201-
```bash
202-
img_b64_str=$(base64 -i assets/demo.png)
203-
curl -X POST "http://localhost:8080/generate" \
204-
-H "Content-Type: application/json" \
205-
-d '{
206-
"image": "'"$img_b64_str"'",
207-
}' \
208-
-o test2.glb
209-
```
210-
211-
### Blender Addon
212-
213-
With an API server launched, you could also directly use Hunyuan3D 2.0 in your blender with
214-
our [Blender Addon](blender_addon.py). Please follow our tutorial to install and use.
215-
216-
https://github.com/user-attachments/assets/8230bfb5-32b1-4e48-91f4-a977c54a4f3e
217107

218108
### Official Site
219109

220110
Don't forget to visit [Hunyuan3D](https://3d.hunyuan.tencent.com) for quick use, if you don't want to host yourself.
221111

222-
## 📑 Open-Source Plan
223-
224-
- [x] Inference Code
225-
- [x] Model Checkpoints
226-
- [x] Technical Report
227-
- [ ] ComfyUI
228-
- [ ] TensorRT Version
229-
230112
## 🔗 BibTeX
231113

232114
If you found this repository helpful, please cite our reports:
@@ -251,16 +133,6 @@ If you found this repository helpful, please cite our reports:
251133
}
252134
```
253135

254-
## Community Resources
255-
256-
Thanks for the contributions of community members, here we have these great extensions of Hunyuan3D 2.0:
257-
258-
- [ComfyUI-3D-Pack](https://github.com/MrForExample/ComfyUI-3D-Pack)
259-
- [ComfyUI-Hunyuan3DWrapper](https://github.com/kijai/ComfyUI-Hunyuan3DWrapper)
260-
- [Hunyuan3D-2-for-windows](https://github.com/sdbds/Hunyuan3D-2-for-windows)
261-
- [📦 A bundle for running on Windows | 整合包](https://github.com/YanWenKun/Hunyuan3D-2-WinPortable)
262-
- [Hunyuan3D-2GP](https://github.com/deepbeepmeep/Hunyuan3D-2GP)
263-
264136
## Acknowledgements
265137

266138
We would like to thank the contributors to

0 commit comments

Comments
 (0)