Closed sunshineywz123 closed 1 day ago
Can you try replacing the line
faces = faces.type(torch.int32)
with
faces = faces.type(torch.int64)
?
.type(torch.int64)
when i render, get error:image_renderer(meshes_to_render, cameras=cameras) *** RuntimeError: expected scalar type Float but found Long
Can you paste your current code? The verts need to be float32, the faces int64
device = torch.device("cuda:0")
import trimesh import torch
Read the PLY file using trimesh
mesh = trimesh.load_mesh("assets/bop/ycbv/models/obj_000001.ply") vertices = torch.FloatTensor(mesh.vertices) faces = torch.Tensor(mesh.faces) faces = faces.type(torch.int32) uv_coordinates = torch.FloatTensor(mesh.visual.uv)
vertices = vertices.to(device) faces = faces.to(device) uv_coordinates = uv_coordinates.to(device)
verts_uvs = uv_coordinates[None,...] faces_uvs = faces[None,...]
texture = transforms.ToTensor()(Image.open("assets/bop/ycbv/models/obj_000001.png")) texture = torch.unsqueeze(texture.to(device), 0) texture = torch.permute(texture, (0, 2, 3, 1))
from pytorch3d.renderer import TexturesUV tex = TexturesUV(maps=texture, faces_uvs=faces_uvs, verts_uvs=verts_uvs) meshes = Meshes(verts=[vertices], faces=[faces], textures=tex)
get error: IndexError: tensors used as indices must be long, byte or bool tensors