| import os |
| os.environ['ATTN_BACKEND'] = 'xformers' |
| os.environ['SPCONV_ALGO'] = 'native' |
| |
| |
|
|
|
|
| import imageio |
| from PIL import Image |
| from trellis.pipelines import TrellisImageTo3DPipeline |
| from trellis.utils import render_utils, postprocessing_utils |
|
|
| |
| pipeline = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large") |
| pipeline.cuda() |
|
|
| |
| image = Image.open("assets/example_image/T.png") |
|
|
| |
| outputs = pipeline.run( |
| image, |
| seed=1, |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| ) |
| |
| |
| |
| |
|
|
| |
| 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 = postprocessing_utils.to_glb( |
| outputs['gaussian'][0], |
| outputs['mesh'][0], |
| |
| simplify=0.95, |
| texture_size=1024, |
| ) |
| glb.export("sample.glb") |
|
|
| |
| outputs['gaussian'][0].save_ply("sample.ply") |
|
|