Last active
June 22, 2023 03:49
-
-
Save justinhchae/5fc397dfba14e7dcbd09203741f9aa4b to your computer and use it in GitHub Desktop.
Example Usage for save_obj with multiple textures in PyTorch3D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install direct from our forked repository: https://github.com/Esri/pytorch3d/tree/multitexture-obj-high-precision | |
!pip install 'git+https://github.com/Esri/pytorch3d.git@multitexture-obj-high-precision' | |
from pytorch3d.io import save_obj | |
# save_obj now allows for saving objs with multiple textures and control over the texture outputs | |
save_obj( | |
f=obj_filename, | |
verts=obj[0], | |
faces=obj[1].verts_idx, | |
verts_uvs=obj[2].verts_uvs, | |
faces_uvs=obj[1].textures_idx, | |
texture_images=obj[2].texture_images, | |
materials_idx=obj[1].materials_idx, | |
image_format='jpeg', # or 'png' | |
normals=face_verts_normals, | |
faces_normals_idx=faces_normals_idx, | |
image_quality=95, # we can now choose the image quality according to PIL docs | |
image_name_kwargs=dict( | |
material_name_as_file_name=True, # if false the obj file name is enumerated to save each material file | |
reuse_material_files=True # if true, an obj with multiple subsets that reference the same materials are not written of the same file already exists | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment