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(
cumprod = torch.cat((torch.ones_like(cumprod[..., :1]), cumprod[..., :-1]), dim=-1)
depths = (weights * cumprod * fragments.zbuf).sum(dim=-1)
# 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
# cat depths and render mask
......
......@@ -409,6 +409,7 @@ def _parse_mtl(
texture_files = {}
material_name = ""
# pyre-fixme[9]: f has type `str`; used as `IO[typing.Any]`.
with _open_file(f, path_manager, "r") as f:
for line in f:
tokens = line.strip().split()
......
......@@ -756,10 +756,13 @@ def save_obj(
output_path = Path(f)
# 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:
if save_texture:
# 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)
# pyre-fixme[16]: Item `Path` of `Union[Path, str]` has no attribute
# `write`.
f.write(obj_header)
_save(
f,
......
......@@ -617,6 +617,7 @@ def _splat_points_to_volumes(
w = wX * wY * wZ
# valid - binary indicators of votes that fall into the volume
# pyre-fixme[16]: `int` has no attribute `long`.
valid = (
(0 <= X_)
* (X_ < grid_sizes_xyz[:, None, 0:1])
......@@ -635,14 +636,19 @@ def _splat_points_to_volumes(
idx_valid = idx * valid + rand_idx * (1 - valid)
w_valid = w * valid.type_as(w)
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]
# scatter add casts the votes into the weight 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)
# reshape idx_valid -> (minibatch, feature_dim, n_points)
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)
# volume_features of shape (minibatch, feature_dim, n_voxels)
......@@ -724,6 +730,7 @@ def _round_points_to_volumes(
# valid - binary indicators of votes that fall into the volume
# pyre-fixme[9]: grid_sizes has type `LongTensor`; used as `Tensor`.
grid_sizes = grid_sizes.type_as(XYZ)
# pyre-fixme[16]: `int` has no attribute `long`.
valid = (
(0 <= X)
* (X < grid_sizes_xyz[:, None, 0:1])
......
......@@ -497,6 +497,7 @@ def clip_faces(
faces_case3 = face_verts_unclipped[case3_unclipped_idx]
# 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]
# Solve for the points p4, p5 that intersect the clipping plane
......@@ -540,6 +541,7 @@ def clip_faces(
faces_case4 = face_verts_unclipped[case4_unclipped_idx]
# 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]
# Solve for the points p4, p5 that intersect the clipping plane
......
......@@ -369,6 +369,7 @@ def plot_scene(
# update camera viewpoint if provided
if viewpoints_eye_at_up_world is not None:
# 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)
eye, at, up = (i[viewpoint_idx] for i in viewpoints_eye_at_up_world)
......@@ -627,7 +628,7 @@ def _add_struct_from_batch(
def _add_mesh_trace(
fig: go.Figure, # pyre-ignore[11]
fig: go.Figure,
meshes: Meshes,
trace_name: str,
subplot_idx: int,
......@@ -673,6 +674,7 @@ def _add_mesh_trace(
verts[~verts_used] = verts_center
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace(
go.Mesh3d(
x=verts[:, 0],
......@@ -739,6 +741,7 @@ def _add_pointcloud_trace(
row = subplot_idx // ncols + 1
col = subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace(
go.Scatter3d(
x=verts[:, 0],
......@@ -800,6 +803,7 @@ def _add_camera_trace(
x, y, z = all_cam_wires.detach().cpu().numpy().T.astype(float)
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace(
go.Scatter3d(x=x, y=y, z=z, marker={"size": 1}, name=trace_name),
row=row,
......@@ -894,6 +898,7 @@ def _add_ray_bundle_trace(
ray_lines = torch.cat((ray_lines, nan_tensor, ray_line))
x, y, z = ray_lines.detach().cpu().numpy().T.astype(float)
row, col = subplot_idx // ncols + 1, subplot_idx % ncols + 1
# pyre-fixme[16]: `Figure` has no attribute `add_trace`.
fig.add_trace(
go.Scatter3d(
x=x,
......@@ -988,7 +993,7 @@ def _gen_fig_with_subplots(
def _update_axes_bounds(
verts_center: torch.Tensor,
max_expand: float,
current_layout: go.Scene, # pyre-ignore[11]
current_layout: go.Scene,
) -> None: # pragma: no cover
"""
Takes in the vertices' center point and max spread, and the current plotly figure
......@@ -1005,6 +1010,7 @@ def _update_axes_bounds(
# Ensure that within a subplot, the bounds capture all traces
old_xrange, old_yrange, old_zrange = (
# pyre-fixme[16]: `Scene` has no attribute `__getitem__`.
current_layout["xaxis"]["range"],
current_layout["yaxis"]["range"],
current_layout["zaxis"]["range"],
......@@ -1023,6 +1029,7 @@ def _update_axes_bounds(
xaxis = {"range": x_range}
yaxis = {"range": y_range}
zaxis = {"range": z_range}
# pyre-fixme[16]: `Scene` has no attribute `update`.
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