Commit 38afdcfc authored by generatedunixname89002005307016's avatar generatedunixname89002005307016 Committed by Facebook GitHub Bot
Browse files

upgrade pyre version in `fbcode/vision` - batch 2

Reviewed By: bottler

Differential Revision: D60992234

fbshipit-source-id: 899db6ed590ef966ff651c11027819e59b8401a3
parent 1e0b1d9c
...@@ -156,7 +156,6 @@ def render_point_cloud_pytorch3d( ...@@ -156,7 +156,6 @@ def render_point_cloud_pytorch3d(
cumprod = torch.cat((torch.ones_like(cumprod[..., :1]), cumprod[..., :-1]), dim=-1) cumprod = torch.cat((torch.ones_like(cumprod[..., :1]), cumprod[..., :-1]), dim=-1)
depths = (weights * cumprod * fragments.zbuf).sum(dim=-1) depths = (weights * cumprod * fragments.zbuf).sum(dim=-1)
# add the rendering mask # add the rendering mask
# pyre-fixme[6]: For 1st param expected `Tensor` but got `float`.
render_mask = -torch.prod(1.0 - weights, dim=-1) + 1.0 render_mask = -torch.prod(1.0 - weights, dim=-1) + 1.0
# cat depths and render mask # cat depths and render mask
......
...@@ -409,6 +409,7 @@ def _parse_mtl( ...@@ -409,6 +409,7 @@ def _parse_mtl(
texture_files = {} texture_files = {}
material_name = "" material_name = ""
# pyre-fixme[9]: f has type `str`; used as `IO[typing.Any]`.
with _open_file(f, path_manager, "r") as f: with _open_file(f, path_manager, "r") as f:
for line in f: for line in f:
tokens = line.strip().split() tokens = line.strip().split()
......
...@@ -756,10 +756,13 @@ def save_obj( ...@@ -756,10 +756,13 @@ def save_obj(
output_path = Path(f) output_path = Path(f)
# Save the .obj file # Save the .obj file
# pyre-fixme[9]: f has type `Union[Path, str]`; used as `IO[typing.Any]`.
with _open_file(f, path_manager, "w") as f: with _open_file(f, path_manager, "w") as f:
if save_texture: if save_texture:
# Add the header required for the texture info to be loaded correctly # Add the header required for the texture info to be loaded correctly
obj_header = "\nmtllib {0}.mtl\nusemtl mesh\n\n".format(output_path.stem) obj_header = "\nmtllib {0}.mtl\nusemtl mesh\n\n".format(output_path.stem)
# pyre-fixme[16]: Item `Path` of `Union[Path, str]` has no attribute
# `write`.
f.write(obj_header) f.write(obj_header)
_save( _save(
f, f,
......
...@@ -617,6 +617,7 @@ def _splat_points_to_volumes( ...@@ -617,6 +617,7 @@ def _splat_points_to_volumes(
w = wX * wY * wZ w = wX * wY * wZ
# valid - binary indicators of votes that fall into the volume # valid - binary indicators of votes that fall into the volume
# pyre-fixme[16]: `int` has no attribute `long`.
valid = ( valid = (
(0 <= X_) (0 <= X_)
* (X_ < grid_sizes_xyz[:, None, 0:1]) * (X_ < grid_sizes_xyz[:, None, 0:1])
...@@ -635,14 +636,19 @@ def _splat_points_to_volumes( ...@@ -635,14 +636,19 @@ def _splat_points_to_volumes(
idx_valid = idx * valid + rand_idx * (1 - valid) idx_valid = idx * valid + rand_idx * (1 - valid)
w_valid = w * valid.type_as(w) w_valid = w * valid.type_as(w)
if mask is not None: if mask is not None:
# pyre-fixme[6]: For 1st argument expected `Tensor` but got `int`.
w_valid = w_valid * mask.type_as(w)[:, :, None] w_valid = w_valid * mask.type_as(w)[:, :, None]
# scatter add casts the votes into the weight accumulator # scatter add casts the votes into the weight accumulator
# and the feature accumulator # and the feature accumulator
# pyre-fixme[6]: For 3rd argument expected `Tensor` but got
# `Union[int, Tensor]`.
volume_densities.scatter_add_(1, idx_valid, w_valid) volume_densities.scatter_add_(1, idx_valid, w_valid)
# reshape idx_valid -> (minibatch, feature_dim, n_points) # reshape idx_valid -> (minibatch, feature_dim, n_points)
idx_valid = idx_valid.view(ba, 1, n_points).expand_as(points_features) idx_valid = idx_valid.view(ba, 1, n_points).expand_as(points_features)
# pyre-fixme[16]: Item `int` of `Union[int, Tensor]` has no
# attribute `view`.
w_valid = w_valid.view(ba, 1, n_points) w_valid = w_valid.view(ba, 1, n_points)
# volume_features of shape (minibatch, feature_dim, n_voxels) # volume_features of shape (minibatch, feature_dim, n_voxels)
...@@ -724,6 +730,7 @@ def _round_points_to_volumes( ...@@ -724,6 +730,7 @@ def _round_points_to_volumes(
# valid - binary indicators of votes that fall into the volume # valid - binary indicators of votes that fall into the volume
# pyre-fixme[9]: grid_sizes has type `LongTensor`; used as `Tensor`. # pyre-fixme[9]: grid_sizes has type `LongTensor`; used as `Tensor`.
grid_sizes = grid_sizes.type_as(XYZ) grid_sizes = grid_sizes.type_as(XYZ)
# pyre-fixme[16]: `int` has no attribute `long`.
valid = ( valid = (
(0 <= X) (0 <= X)
* (X < grid_sizes_xyz[:, None, 0:1]) * (X < grid_sizes_xyz[:, None, 0:1])
......
...@@ -497,6 +497,7 @@ def clip_faces( ...@@ -497,6 +497,7 @@ def clip_faces(
faces_case3 = face_verts_unclipped[case3_unclipped_idx] faces_case3 = face_verts_unclipped[case3_unclipped_idx]
# index (0, 1, or 2) of the vertex in front of the clipping plane # index (0, 1, or 2) of the vertex in front of the clipping plane
# pyre-fixme[61]: `faces_clipped_verts` is undefined, or not always defined.
p1_face_ind = torch.where(~faces_clipped_verts[case3_unclipped_idx])[1] p1_face_ind = torch.where(~faces_clipped_verts[case3_unclipped_idx])[1]
# Solve for the points p4, p5 that intersect the clipping plane # Solve for the points p4, p5 that intersect the clipping plane
...@@ -540,6 +541,7 @@ def clip_faces( ...@@ -540,6 +541,7 @@ def clip_faces(
faces_case4 = face_verts_unclipped[case4_unclipped_idx] faces_case4 = face_verts_unclipped[case4_unclipped_idx]
# index (0, 1, or 2) of the vertex behind the clipping plane # index (0, 1, or 2) of the vertex behind the clipping plane
# pyre-fixme[61]: `faces_clipped_verts` is undefined, or not always defined.
p1_face_ind = torch.where(faces_clipped_verts[case4_unclipped_idx])[1] p1_face_ind = torch.where(faces_clipped_verts[case4_unclipped_idx])[1]
# Solve for the points p4, p5 that intersect the clipping plane # Solve for the points p4, p5 that intersect the clipping plane
......
...@@ -369,6 +369,7 @@ def plot_scene( ...@@ -369,6 +369,7 @@ def plot_scene(
# update camera viewpoint if provided # update camera viewpoint if provided
if viewpoints_eye_at_up_world is not None: if viewpoints_eye_at_up_world is not None:
# Use camera params for batch index or the first camera if only one provided. # Use camera params for batch index or the first camera if only one provided.
# pyre-fixme[61]: `n_viewpoint_cameras` is undefined, or not always defined.
viewpoint_idx = min(n_viewpoint_cameras - 1, subplot_idx) viewpoint_idx = min(n_viewpoint_cameras - 1, subplot_idx)
eye, at, up = (i[viewpoint_idx] for i in viewpoints_eye_at_up_world) eye, at, up = (i[viewpoint_idx] for i in viewpoints_eye_at_up_world)
...@@ -627,7 +628,7 @@ def _add_struct_from_batch( ...@@ -627,7 +628,7 @@ def _add_struct_from_batch(
def _add_mesh_trace( def _add_mesh_trace(
fig: go.Figure, # pyre-ignore[11] fig: go.Figure,
meshes: Meshes, meshes: Meshes,
trace_name: str, trace_name: str,
subplot_idx: int, subplot_idx: int,
...@@ -673,6 +674,7 @@ def _add_mesh_trace( ...@@ -673,6 +674,7 @@ def _add_mesh_trace(
verts[~verts_used] = verts_center verts[~verts_used] = verts_center
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1 row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace( fig.add_trace(
go.Mesh3d( go.Mesh3d(
x=verts[:, 0], x=verts[:, 0],
...@@ -739,6 +741,7 @@ def _add_pointcloud_trace( ...@@ -739,6 +741,7 @@ def _add_pointcloud_trace(
row = subplot_idx // ncols + 1 row = subplot_idx // ncols + 1
col = subplot_idx % ncols + 1 col = subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace( fig.add_trace(
go.Scatter3d( go.Scatter3d(
x=verts[:, 0], x=verts[:, 0],
...@@ -800,6 +803,7 @@ def _add_camera_trace( ...@@ -800,6 +803,7 @@ def _add_camera_trace(
x, y, z = all_cam_wires.detach().cpu().numpy().T.astype(float) x, y, z = all_cam_wires.detach().cpu().numpy().T.astype(float)
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1 row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace( fig.add_trace(
go.Scatter3d(x=x, y=y, z=z, marker={"size": 1}, name=trace_name), go.Scatter3d(x=x, y=y, z=z, marker={"size": 1}, name=trace_name),
row=row, row=row,
...@@ -894,6 +898,7 @@ def _add_ray_bundle_trace( ...@@ -894,6 +898,7 @@ def _add_ray_bundle_trace(
ray_lines = torch.cat((ray_lines, nan_tensor, ray_line)) ray_lines = torch.cat((ray_lines, nan_tensor, ray_line))
x, y, z = ray_lines.detach().cpu().numpy().T.astype(float) x, y, z = ray_lines.detach().cpu().numpy().T.astype(float)
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1 row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace( fig.add_trace(
go.Scatter3d( go.Scatter3d(
x=x, x=x,
...@@ -988,7 +993,7 @@ def _gen_fig_with_subplots( ...@@ -988,7 +993,7 @@ def _gen_fig_with_subplots(
def _update_axes_bounds( def _update_axes_bounds(
verts_center: torch.Tensor, verts_center: torch.Tensor,
max_expand: float, max_expand: float,
current_layout: go.Scene, # pyre-ignore[11] current_layout: go.Scene,
) -> None: # pragma: no cover ) -> None: # pragma: no cover
""" """
Takes in the vertices' center point and max spread, and the current plotly figure Takes in the vertices' center point and max spread, and the current plotly figure
...@@ -1005,6 +1010,7 @@ def _update_axes_bounds( ...@@ -1005,6 +1010,7 @@ def _update_axes_bounds(
# Ensure that within a subplot, the bounds capture all traces # Ensure that within a subplot, the bounds capture all traces
old_xrange, old_yrange, old_zrange = ( old_xrange, old_yrange, old_zrange = (
# pyre-fixme[16]: `Scene` has no attribute `__getitem__`.
current_layout["xaxis"]["range"], current_layout["xaxis"]["range"],
current_layout["yaxis"]["range"], current_layout["yaxis"]["range"],
current_layout["zaxis"]["range"], current_layout["zaxis"]["range"],
...@@ -1023,6 +1029,7 @@ def _update_axes_bounds( ...@@ -1023,6 +1029,7 @@ def _update_axes_bounds(
xaxis = {"range": x_range} xaxis = {"range": x_range}
yaxis = {"range": y_range} yaxis = {"range": y_range}
zaxis = {"range": z_range} zaxis = {"range": z_range}
# pyre-fixme[16]: `Scene` has no attribute `update`.
current_layout.update({"xaxis": xaxis, "yaxis": yaxis, "zaxis": zaxis}) current_layout.update({"xaxis": xaxis, "yaxis": yaxis, "zaxis": zaxis})
......
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