網(wǎng)站產(chǎn)品頁(yè)面/注冊(cè)安全工程師
TRELLIS 是一個(gè)大型 3D 資產(chǎn)生成模型。它接收文本或圖像提示,并生成各種格式的高質(zhì)量 3D 資產(chǎn),例如 Radiance Fields、3D Gaussians 和網(wǎng)格。TRELLIS 的基石是統(tǒng)一的結(jié)構(gòu)化 LATent (SLAT) 表示,它允許解碼為不同的輸出格式,并為 SLAT 量身定制的整流變壓器作為強(qiáng)大的支柱。我們?cè)?500K 不同對(duì)象的大型 3D 資產(chǎn)數(shù)據(jù)集上提供具有多達(dá) 20 億個(gè)參數(shù)的大規(guī)模預(yù)訓(xùn)練模型。TRELLIS 顯著超越了現(xiàn)有方法,包括最近類似比例的方法,并展示了以前型號(hào)所沒(méi)有的靈活輸出格式選擇和本地 3D 編輯功能。
6100 Stars 388 Forks 67 Issues 5 貢獻(xiàn)者 MIT License Python 語(yǔ)言
代碼: https://github.com/microsoft/TRELLIS
主頁(yè): TRELLIS: Structured 3D Latents for Scalable and Versatile 3D Generation
更多AI開(kāi)源軟件:AI開(kāi)源 - 小眾AI
?
主要功能
- **高質(zhì)量**:它以高質(zhì)量生成具有復(fù)雜形狀和紋理細(xì)節(jié)的各種 3D 資產(chǎn)。
- **多功能性**:它接受文本或圖像提示,可以生成各種最終的 3D 表示,包括但不限于*輻射場(chǎng)*、*3D 高斯*和*網(wǎng)格*,以適應(yīng)不同的下游要求。
- **靈活編輯**:它允許輕松編輯生成的 3D 資產(chǎn),例如生成同一對(duì)象的變體或?qū)?3D 資產(chǎn)進(jìn)行本地編輯。
📦 安裝和使用
先決條件
-
**系統(tǒng)**:代碼目前僅在 **Linux** 上進(jìn)行測(cè)試。對(duì)于 Windows 設(shè)置,您可以參考 #3(未完全測(cè)試)。
-
**硬件**:需要至少具有 16GB 內(nèi)存的 NVIDIA GPU。該代碼已在 NVIDIA A100 和 A6000 GPU 上得到驗(yàn)證。
-
軟件:
- 需要 CUDA 工具包來(lái)編譯某些子模塊。該代碼已使用 CUDA 版本 11.8 和 12.2 進(jìn)行了測(cè)試。
- 建議使用 Conda 來(lái)管理依賴項(xiàng)。
- 需要 Python 版本 3.8 或更高版本。
安裝步驟
-
克隆存儲(chǔ)庫(kù):
git clone --recurse-submodules https://github.com/microsoft/TRELLIS.git cd TRELLIS
-
安裝依賴項(xiàng):
**在運(yùn)行以下命令之前,需要注意一些事項(xiàng):**- 通過(guò)添加 ,將創(chuàng)建一個(gè)名為 的新 conda 環(huán)境。如果要使用現(xiàn)有的 conda 環(huán)境,請(qǐng)刪除此標(biāo)記。--new-envtrellis?
- 默認(rèn)情況下,環(huán)境將使用 pytorch 2.4.0 和 CUDA 11.8。如果您想使用不同版本的 CUDA(例如,如果您安裝了 CUDA Toolkit 12.2 并且不想安裝另一個(gè) 11.8 版本進(jìn)行子模塊編譯),您可以刪除該標(biāo)志并手動(dòng)安裝所需的依賴項(xiàng)。有關(guān)安裝命令,請(qǐng)參閱 PyTorch。trellis--new-env?
- 如果您安裝了多個(gè) CUDA Toolkit 版本,則應(yīng)在運(yùn)行命令之前將其設(shè)置為正確的版本。例如,如果您安裝了 CUDA Toolkit 11.8 和 12.2,則應(yīng)在運(yùn)行命令之前運(yùn)行。PATHexport PATH=/usr/local/cuda-11.8/bin:$PATH?
- 默認(rèn)情況下,代碼使用 backend 進(jìn)行關(guān)注。對(duì)于不支持的 GPU(例如 NVIDIA V100),您可以刪除僅安裝 (install only) 的標(biāo)志,并將環(huán)境變量設(shè)置為在運(yùn)行代碼之前。有關(guān)更多詳細(xì)信息,請(qǐng)參閱 最小示例。flash-attnflash-attn--flash-attnxformersATTN_BACKENDxformers?
- 由于依賴項(xiàng)數(shù)量眾多,安裝可能需要一段時(shí)間。請(qǐng)耐心等待。如果遇到任何問(wèn)題,可以嘗試逐個(gè)安裝依賴項(xiàng),一次指定一個(gè)標(biāo)志。
- 如果您在安裝過(guò)程中遇到任何問(wèn)題,請(qǐng)隨時(shí)打開(kāi)問(wèn)題或聯(lián)系我們。
創(chuàng)建一個(gè)名為 的新 conda 環(huán)境并安裝依賴項(xiàng):trellis?
. ./setup.sh --new-env --basic --xformers --flash-attn --diffoctreerast --spconv --mipgaussian --kaolin --nvdiffrast
運(yùn)行.setup.sh. ./setup.sh --help?
Usage: setup.sh [OPTIONS] Options:-h, --help Display this help message--new-env Create a new conda environment--basic Install basic dependencies--xformers Install xformers--flash-attn Install flash-attn--diffoctreerast Install diffoctreerast--vox2seq Install vox2seq--spconv Install spconv--mipgaussian Install mip-splatting--kaolin Install kaolin--nvdiffrast Install nvdiffrast--demo Install all dependencies for demo
🤖 預(yù)訓(xùn)練模型
我們提供以下預(yù)訓(xùn)練模型:
型 | 描述 | #Params | 下載 |
---|---|---|---|
格狀圖-大 | 大型圖像到 3D 模型 | 1.2乙 | 下載 |
TRELLIS-text-base | 基本文本到 3D 模型 | 342 米 | 即將推出 |
格狀文本大號(hào) | 大型文本到 3D 模型 | 1.1乙 | 即將推出 |
格子文本 xlarge | 超大文本到 3D 模型 | 2.0乙 | 即將推出 |
這些模型托管在 Hugging Face 上。您可以在代碼中直接加載模型及其存儲(chǔ)庫(kù)名稱:
TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
如果您更喜歡從本地加載模型,可以從上面的鏈接下載模型文件,并使用文件夾路徑加載模型(應(yīng)保持文件夾結(jié)構(gòu)):
TrellisImageTo3DPipeline.from_pretrained("/path/to/TRELLIS-image-large")
💡 用法
最小示例
以下是如何使用預(yù)訓(xùn)練模型生成 3D 資產(chǎn)的示例。
import os
# os.environ['ATTN_BACKEND'] = 'xformers' # Can be 'flash-attn' or 'xformers', default is 'flash-attn'
os.environ['SPCONV_ALGO'] = 'native' # Can be 'native' or 'auto', default is 'auto'.# 'auto' is faster but will do benchmarking at the beginning.# Recommended to set to 'native' if run only once.import imageio
from PIL import Image
from trellis.pipelines import TrellisImageTo3DPipeline
from trellis.utils import render_utils, postprocessing_utils# Load a pipeline from a model folder or a Hugging Face model hub.
pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
pipeline.cuda()# Load an image
image = Image.open("assets/example_image/T.png")# Run the pipeline
outputs = pipeline.run(image,seed=1,# Optional parameters# sparse_structure_sampler_params={# "steps": 12,# "cfg_strength": 7.5,# },# slat_sampler_params={# "steps": 12,# "cfg_strength": 3,# },
)
# outputs is a dictionary containing generated 3D assets in different formats:
# - outputs['gaussian']: a list of 3D Gaussians
# - outputs['radiance_field']: a list of radiance fields
# - outputs['mesh']: a list of meshes# Render the outputs
video = render_utils.render_video(outputs['gaussian'][0])['color']
imageio.mimsave("sample_gs.mp4", video, fps=30)
video = render_utils.render_video(outputs['radiance_field'][0])['color']
imageio.mimsave("sample_rf.mp4", video, fps=30)
video = render_utils.render_video(outputs['mesh'][0])['normal']
imageio.mimsave("sample_mesh.mp4", video, fps=30)# GLB files can be extracted from the outputs
glb = postprocessing_utils.to_glb(outputs['gaussian'][0],outputs['mesh'][0],# Optional parameterssimplify=0.95, # Ratio of triangles to remove in the simplification processtexture_size=1024, # Size of the texture used for the GLB
)
glb.export("sample.glb")# Save Gaussians as PLY files
outputs['gaussian'][0].save_ply("sample.ply")
運(yùn)行代碼后,您將獲得以下文件:
- ?sample_gs.mp4?:顯示 3D 高斯表示的視頻
- ?sample_rf.mp4?:顯示 Radiance Field 表示的視頻
- ?sample_mesh.mp4?:顯示網(wǎng)格表示的視頻
- ?sample.glb?:包含提取的紋理網(wǎng)格的 GLB 文件
- ?sample.ply?:包含 3D 高斯表示的 PLY 文件
Web 演示
app.py 提供了一個(gè)簡(jiǎn)單的 Web 演示,用于生成 3D 資產(chǎn)。由于此 demo 基于 Gradio,因此需要額外的依賴項(xiàng):
. ./setup.sh --demo
安裝依賴項(xiàng)后,您可以使用以下命令運(yùn)行 Demo:
python app.py
然后,您可以在終端中顯示的地址訪問(wèn)演示。