mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
tutorial fixes. validate #cameras
Summary: Update the installation cells to import torch. Replace use of deprecated Textures in deform tutorial. Correct the deform tutorial's idea of its own name. Fix typo in batched part of render_textured_meshes which meant only one mesh was being rendered with a batch of cameras. Add an error check in the rasterizer to make the error friendly from such a mistake elsewhere. Reviewed By: gkioxari Differential Revision: D23345462 fbshipit-source-id: 1d5bd25db052f7ef687b7168d7aee5cc4dce8952
This commit is contained in:
parent
32484500be
commit
9aeb88b48e
@ -82,6 +82,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
|
@ -69,6 +69,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
@ -99,7 +100,7 @@
|
||||
"from pytorch3d.io import load_obj\n",
|
||||
"\n",
|
||||
"# datastructures\n",
|
||||
"from pytorch3d.structures import Meshes, Textures\n",
|
||||
"from pytorch3d.structures import Meshes\n",
|
||||
"\n",
|
||||
"# 3D transformations functions\n",
|
||||
"from pytorch3d.transforms import Rotate, Translate\n",
|
||||
@ -108,7 +109,7 @@
|
||||
"from pytorch3d.renderer import (\n",
|
||||
" FoVPerspectiveCameras, look_at_view_transform, look_at_rotation, \n",
|
||||
" RasterizationSettings, MeshRenderer, MeshRasterizer, BlendParams,\n",
|
||||
" SoftSilhouetteShader, HardPhongShader, PointLights\n",
|
||||
" SoftSilhouetteShader, HardPhongShader, PointLights, TexturesVertex,\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@ -175,7 +176,7 @@
|
||||
"\n",
|
||||
"# Initialize each vertex to be white in color.\n",
|
||||
"verts_rgb = torch.ones_like(verts)[None] # (1, V, 3)\n",
|
||||
"textures = Textures(verts_rgb=verts_rgb.to(device))\n",
|
||||
"textures = TexturesVertex(verts_features=verts_rgb.to(device))\n",
|
||||
"\n",
|
||||
"# Create a Meshes object for the teapot. Here we have only one mesh in the batch.\n",
|
||||
"teapot_mesh = Meshes(\n",
|
||||
|
@ -44,6 +44,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
@ -494,7 +495,7 @@
|
||||
"bento/extensions/theme/main.css": true
|
||||
},
|
||||
"colab": {
|
||||
"name": "FitMesh.ipynb",
|
||||
"name": "deform_source_mesh_to_target_mesh.ipynb",
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
|
@ -61,6 +61,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
|
@ -43,6 +43,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
|
@ -66,6 +66,7 @@
|
||||
"source": [
|
||||
"!pip install torch torchvision\n",
|
||||
"import sys\n",
|
||||
"import torch\n",
|
||||
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
|
||||
" !pip install pytorch3d\n",
|
||||
"else:\n",
|
||||
@ -542,7 +543,7 @@
|
||||
"source": [
|
||||
"# We can pass arbirary keyword arguments to the rasterizer/shader via the renderer\n",
|
||||
"# so the renderer does not need to be reinitialized if any of the settings change.\n",
|
||||
"images = renderer(mesh, cameras=cameras, lights=lights)"
|
||||
"images = renderer(meshes, cameras=cameras, lights=lights)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -94,6 +94,12 @@ class MeshRasterizer(nn.Module):
|
||||
msg = "Cameras must be specified either at initialization \
|
||||
or in the forward pass of MeshRasterizer"
|
||||
raise ValueError(msg)
|
||||
|
||||
n_cameras = len(cameras)
|
||||
if n_cameras != 1 and n_cameras != len(meshes_world):
|
||||
msg = "Wrong number (%r) of cameras for %r meshes"
|
||||
raise ValueError(msg % (n_cameras, len(meshes_world)))
|
||||
|
||||
verts_world = meshes_world.verts_padded()
|
||||
|
||||
# NOTE: Retaining view space z coordinate for now.
|
||||
|
Loading…
x
Reference in New Issue
Block a user