Closed godfatherwang2 closed 1 year ago
What is renderer_textured?
Thank you for your attention,I use the below code to create this oject. Perhaps I need a sample code to learn how to optimize the UV map with pytorch3D. camera = FoVPerspectiveCameras(device="cuda") renderer_textured = MeshRenderer( rasterizer=MeshRasterizer( cameras=camera, raster_settings=raster_settings_soft ), shader=SoftPhongShader(device="cuda", cameras=camera, ) )
What is renderer_textured? Thank you for your attention,I use the below code to create this oject. Perhaps I need a sample code to learn how to optimize the UV map with pytorch3D. camera = FoVPerspectiveCameras(device="cuda") renderer_textured = MeshRenderer( rasterizer=MeshRasterizer( cameras=camera, raster_settings=raster_settings_soft ), shader=SoftPhongShader(device="cuda", cameras=camera, ) )
When you visualise the output, do you see the mesh?
Yes, I am sure I can see the rendered mesh. Is it possiable that I use the wrong rasterizer or shader ?
The rasterizer does not matter. The shader is fine. I don't understand what is happening here. Can you paste the image of the output of the renderer here? Does it contain many different colors (showing that it is affected by many elements of the map)?
I'm very sorry, I think I made a very basic mistake. I found the gradient to be 0 because of an issue with my IDE's display format. I think PyTorch3D is a great project.
❓ Questions on how to use PyTorch3D
Hello, I have some question about the Differentiable rendering,I set the raw texture UV map as parameter to be optimized, and load the mesh. However when I render the mesh , I find when using the output image to compute the loss. The gradient of the texture UV map is zero. I use the code below:
uvmaps = Variable(torch.randn(1, 1024, 1024,3).cuda(), requires_grad=True) mesh = Meshes(verts=[param3d_middle], faces=[f_uv],textures=TexturesUV(maps=uvmaps,faces_uvs=[f_uv], verts_uvs=[uv_coords])) image = renderer_textured(mesh,R = R,T = T)[...,:3] loss_rgb = ((image-target_image)**2).mean() loss_rgb.backward() print(uvmaps.grad)