First of all thanks for such amazing work, this really is helpful.
I am trying to render the .obj file usng torch3d as per the code below, but it is asking for texture which I am not sure how to get.
While loading itself I get this warning
/usr/local/lib/python3.10/dist-packages/pytorch3d/io/obj_io.py:550: UserWarning: Mtl file does not exist: /content/data/cow_mesh/cow.mtl warnings.warn(f"Mtl file does not exist: {f}"),
hence I donwnloaded a dummy obj, mtl and texture.png file using
torch3d runs flawlessly with this, but if I remove mtl it stops working completely. I am really stuck with this. My objective is to render obj from triposr from multiple angles and save the images. Is there a direct or alternate way to solve this. Also please point if I am doing something wrong. I would be really greatful. Thanks.
CODE
`
import torch
from pytorch3d.io import load_objs_as_meshes, load_obj
from pytorch3d.structures import Meshes
First of all thanks for such amazing work, this really is helpful. I am trying to render the .obj file usng torch3d as per the code below, but it is asking for texture which I am not sure how to get. While loading itself I get this warning
/usr/local/lib/python3.10/dist-packages/pytorch3d/io/obj_io.py:550: UserWarning: Mtl file does not exist: /content/data/cow_mesh/cow.mtl warnings.warn(f"Mtl file does not exist: {f}")
, hence I donwnloaded a dummy obj, mtl and texture.png file using!wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytorch3d/data/cow_mesh/cow.obj
!wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytorch3d/data/cow_mesh/cow.mtl
!wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytorch3d/data/cow_mesh/cow_texture.png
torch3d runs flawlessly with this, but if I remove mtl it stops working completely. I am really stuck with this. My objective is to render obj from triposr from multiple angles and save the images. Is there a direct or alternate way to solve this. Also please point if I am doing something wrong. I would be really greatful. Thanks.
CODE ` import torch from pytorch3d.io import load_objs_as_meshes, load_obj from pytorch3d.structures import Meshes
from pytorch3d.renderer import ( look_at_view_transform, FoVPerspectiveCameras, RasterizationSettings, MeshRenderer, MeshRasterizer, PointLights, SoftPhongShader )
device = torch.device("cuda") if torch.cuda.is_available() else "cpu"
load mesh
obj_filename = "mesh.obj" mesh = load_objs_as_meshes([obj_filename], device=device)
R, T = look_at_view_transform(2.7, 0, 180) cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
raster_settings = RasterizationSettings( image_size=512, blur_radius=0.0, faces_per_pixel=1 )
lights = PointLights(device=device, location=[[0.0, 0.0, -3.0]])
renderer = MeshRenderer( rasterizer=MeshRasterizer(cameras=cameras, raster_settings=raster_settings), shader=SoftPhongShader(device=device, cameras=cameras, lights=lights) )
multi-view
bs = 5 meshes = mesh.extend(bs)
elev = torch.linspace(0, 180, bs) azim = torch.linspace(-180, 180, bs)
R, T = look_at_view_transform(dist=2.7, elev=elev, azim=azim) cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
lights.locaion = torch.tensor([[0.0, 0.0, -3.0]], device=device)
render
images = renderer(meshes, cameras=cameras, lights=lights)
ERROR : ValueError: Meshes does not have textures
`
` """ ERROR:
ValueError Traceback (most recent call last)