Update README.md
#16
by
dylanebert
- opened
README.md
CHANGED
|
@@ -7,10 +7,109 @@ language:
|
|
| 7 |
---
|
| 8 |
# TRELLIS Image Large
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
# TRELLIS Image Large
|
| 9 |
|
| 10 |
+
**TRELLIS Image Large** generates 3D objects from images. The inputs are images (`.jpg`, `.png`) and the outputs are meshes (`.glb`) and splats (`.ply`).
|
| 11 |
|
| 12 |
+
## 🗒️ Model Details
|
| 13 |
|
| 14 |
+
- Name: TRELLIS-image-large
|
| 15 |
+
- Type: [Image-to-3D](https://huggingface.co/tasks/image-to-3d)
|
| 16 |
+
- Size: 1.2 billion parameters
|
| 17 |
+
- Code: https://github.com/microsoft/TRELLIS
|
| 18 |
+
- Paper: https://arxiv.org/abs/2412.01506
|
| 19 |
+
- Training Data: [TRELLIS-500K](https://github.com/microsoft/TRELLIS#-dataset)
|
| 20 |
|
| 21 |
+
## 💡 Usage
|
| 22 |
+
|
| 23 |
+
### Minimal Example
|
| 24 |
+
|
| 25 |
+
Here is an example of how to use the pretrained models for 3D asset generation.
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
import os
|
| 29 |
+
# os.environ['ATTN_BACKEND'] = 'xformers' # Can be 'flash-attn' or 'xformers', default is 'flash-attn'
|
| 30 |
+
os.environ['SPCONV_ALGO'] = 'native' # Can be 'native' or 'auto', default is 'auto'.
|
| 31 |
+
# 'auto' is faster but will do benchmarking at the beginning.
|
| 32 |
+
# Recommended to set to 'native' if run only once.
|
| 33 |
+
|
| 34 |
+
import imageio
|
| 35 |
+
from PIL import Image
|
| 36 |
+
from trellis.pipelines import TrellisImageTo3DPipeline
|
| 37 |
+
from trellis.utils import render_utils, postprocessing_utils
|
| 38 |
+
|
| 39 |
+
# Load a pipeline from a model folder or a Hugging Face model hub.
|
| 40 |
+
pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
|
| 41 |
+
pipeline.cuda()
|
| 42 |
+
|
| 43 |
+
# Load an image
|
| 44 |
+
image = Image.open("assets/example_image/T.png")
|
| 45 |
+
|
| 46 |
+
# Run the pipeline
|
| 47 |
+
outputs = pipeline.run(
|
| 48 |
+
image,
|
| 49 |
+
seed=1,
|
| 50 |
+
# Optional parameters
|
| 51 |
+
# sparse_structure_sampler_params={
|
| 52 |
+
# "steps": 12,
|
| 53 |
+
# "cfg_strength": 7.5,
|
| 54 |
+
# },
|
| 55 |
+
# slat_sampler_params={
|
| 56 |
+
# "steps": 12,
|
| 57 |
+
# "cfg_strength": 3,
|
| 58 |
+
# },
|
| 59 |
+
)
|
| 60 |
+
# outputs is a dictionary containing generated 3D assets in different formats:
|
| 61 |
+
# - outputs['gaussian']: a list of 3D Gaussians
|
| 62 |
+
# - outputs['radiance_field']: a list of radiance fields
|
| 63 |
+
# - outputs['mesh']: a list of meshes
|
| 64 |
+
|
| 65 |
+
# Render the outputs
|
| 66 |
+
video = render_utils.render_video(outputs['gaussian'][0])['color']
|
| 67 |
+
imageio.mimsave("sample_gs.mp4", video, fps=30)
|
| 68 |
+
video = render_utils.render_video(outputs['radiance_field'][0])['color']
|
| 69 |
+
imageio.mimsave("sample_rf.mp4", video, fps=30)
|
| 70 |
+
video = render_utils.render_video(outputs['mesh'][0])['normal']
|
| 71 |
+
imageio.mimsave("sample_mesh.mp4", video, fps=30)
|
| 72 |
+
|
| 73 |
+
# GLB files can be extracted from the outputs
|
| 74 |
+
glb = postprocessing_utils.to_glb(
|
| 75 |
+
outputs['gaussian'][0],
|
| 76 |
+
outputs['mesh'][0],
|
| 77 |
+
# Optional parameters
|
| 78 |
+
simplify=0.95, # Ratio of triangles to remove in the simplification process
|
| 79 |
+
texture_size=1024, # Size of the texture used for the GLB
|
| 80 |
+
)
|
| 81 |
+
glb.export("sample.glb")
|
| 82 |
+
|
| 83 |
+
# Save Gaussians as PLY files
|
| 84 |
+
outputs['gaussian'][0].save_ply("sample.ply")
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
After running the code, you will get the following files:
|
| 88 |
+
|
| 89 |
+
- sample_gs.mp4: a video showing the 3D Gaussian representation
|
| 90 |
+
- sample_rf.mp4: a video showing the Radiance Field representation
|
| 91 |
+
- sample_mesh.mp4: a video showing the mesh representation
|
| 92 |
+
- sample.glb: a GLB file containing the extracted textured mesh
|
| 93 |
+
- sample.ply: a PLY file containing the 3D Gaussian representation
|
| 94 |
+
|
| 95 |
+
## ⚖️ License
|
| 96 |
+
|
| 97 |
+
TRELLIS models and the majority of the code are licensed under the [MIT License](LICENSE). The following submodules may have different licenses:
|
| 98 |
+
- [**diffoctreerast**](https://github.com/JeffreyXiang/diffoctreerast): We developed a CUDA-based real-time differentiable octree renderer for rendering radiance fields as part of this project. This renderer is derived from the [diff-gaussian-rasterization](https://github.com/graphdeco-inria/diff-gaussian-rasterization) project and is available under the [LICENSE](https://github.com/JeffreyXiang/diffoctreerast/blob/master/LICENSE).
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
- [**Modified Flexicubes**](https://github.com/MaxtirError/FlexiCubes): In this project, we used a modified version of [Flexicubes](https://github.com/nv-tlabs/FlexiCubes) to support vertex attributes. This modified version is licensed under the [LICENSE](https://github.com/nv-tlabs/FlexiCubes/blob/main/LICENSE.txt).
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
## 📜 Citation
|
| 105 |
+
|
| 106 |
+
If you find this work helpful, please consider citing our paper:
|
| 107 |
+
|
| 108 |
+
```bibtex
|
| 109 |
+
@article{xiang2024structured,
|
| 110 |
+
title = {Structured 3D Latents for Scalable and Versatile 3D Generation},
|
| 111 |
+
author = {Xiang, Jianfeng and Lv, Zelong and Xu, Sicheng and Deng, Yu and Wang, Ruicheng and Zhang, Bowen and Chen, Dong and Tong, Xin and Yang, Jiaolong},
|
| 112 |
+
journal = {arXiv preprint arXiv:2412.01506},
|
| 113 |
+
year = {2024}
|
| 114 |
+
}
|
| 115 |
+
```
|