Commit 1c45ec97 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

Avoid gradients when rendering for visualization

Summary: The renderer gets used for visualization only in places. Here we avoid creating an autograd graph during that, which is not needed and can fail because some of the graph which existed earlier might be needed and has not been retained after the optimizer step. See https://github.com/facebookresearch/pytorch3d/issues/624

Reviewed By: gkioxari

Differential Revision: D27593018

fbshipit-source-id: 62ae7a5a790111273aa4c566f172abd36c844bfb
parent 42016bc0
......@@ -455,7 +455,8 @@
" target_image=target_rgb[1], title='', \n",
" silhouette=False):\n",
" inds = 3 if silhouette else range(3)\n",
" predicted_images = renderer(predicted_mesh)\n",
" with torch.no_grad():\n",
" predicted_images = renderer(predicted_mesh)\n",
" plt.figure(figsize=(20, 10))\n",
" plt.subplot(1, 2, 1)\n",
" plt.imshow(predicted_images[0, ..., inds].cpu().detach().numpy())\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment