diff --git a/projects/implicitron_trainer/experiment.py b/projects/implicitron_trainer/experiment.py index fa109af5..6c0e0cca 100755 --- a/projects/implicitron_trainer/experiment.py +++ b/projects/implicitron_trainer/experiment.py @@ -193,7 +193,6 @@ class Experiment(Configurable): last_epoch=start_epoch, model=model, resume=self.model_factory.resume, - # pyrefly: ignore [missing-attribute] resume_epoch=self.model_factory.resume_epoch, ) @@ -213,7 +212,6 @@ class Experiment(Configurable): # Enter the main training loop. self.training_loop.run( - # pyrefly: ignore [bad-argument-type] train_loader=train_loader, val_loader=val_loader, test_loader=test_loader, diff --git a/projects/implicitron_trainer/impl/optimizer_factory.py b/projects/implicitron_trainer/impl/optimizer_factory.py index 2305979e..34642a01 100644 --- a/projects/implicitron_trainer/impl/optimizer_factory.py +++ b/projects/implicitron_trainer/impl/optimizer_factory.py @@ -173,7 +173,6 @@ class ImplicitronOptimizerFactory(OptimizerFactoryBase): scheduler = torch.optim.lr_scheduler.LambdaLR( optimizer, lambda epoch: self.gamma ** (epoch / self.exponential_lr_step_size), - # pyrefly: ignore [unexpected-keyword] verbose=False, ) elif self.lr_policy.casefold() == "LinearExponential".casefold(): @@ -192,11 +191,7 @@ class ImplicitronOptimizerFactory(OptimizerFactoryBase): # pyre-fixme[28]: Unexpected keyword argument `verbose`. scheduler = torch.optim.lr_scheduler.LambdaLR( - # pyrefly: ignore [unexpected-keyword] - optimizer, - _get_lr, - # pyrefly: ignore [unexpected-keyword] - verbose=False, + optimizer, _get_lr, verbose=False ) else: raise ValueError("no such lr policy %s" % self.lr_policy) diff --git a/projects/implicitron_trainer/impl/training_loop.py b/projects/implicitron_trainer/impl/training_loop.py index 28884a41..b752d595 100644 --- a/projects/implicitron_trainer/impl/training_loop.py +++ b/projects/implicitron_trainer/impl/training_loop.py @@ -199,7 +199,6 @@ class ImplicitronTrainingLoop(TrainingLoopBase): and self.test_interval > 0 and epoch % self.test_interval == 0 ): - # pyrefly: ignore [missing-attribute] self.evaluator.run( device=device, dataloader=test_loader, @@ -216,7 +215,6 @@ class ImplicitronTrainingLoop(TrainingLoopBase): if self.test_when_finished: if test_loader is not None: - # pyrefly: ignore [missing-attribute] self.evaluator.run( device=device, dump_to_json=True, diff --git a/projects/implicitron_trainer/impl/utils.py b/projects/implicitron_trainer/impl/utils.py index f37889d9..90c8071d 100644 --- a/projects/implicitron_trainer/impl/utils.py +++ b/projects/implicitron_trainer/impl/utils.py @@ -14,7 +14,6 @@ import torch def seed_all_random_engines(seed: int) -> None: - # pyrefly: ignore [bad-argument-type] np.random.seed(seed) torch.manual_seed(seed) random.seed(seed) diff --git a/projects/implicitron_trainer/visualize_reconstruction.py b/projects/implicitron_trainer/visualize_reconstruction.py index 384ddd47..707bd286 100644 --- a/projects/implicitron_trainer/visualize_reconstruction.py +++ b/projects/implicitron_trainer/visualize_reconstruction.py @@ -75,7 +75,6 @@ def visualize_reconstruction( # Set the random seeds torch.manual_seed(0) - # pyrefly: ignore [bad-argument-type] np.random.seed(0) # Get the config from the experiment_directory, @@ -136,7 +135,6 @@ def visualize_reconstruction( "device": device, **render_flyaround_kwargs, } - # pyrefly: ignore [bad-argument-type] render_flyaround(**render_kwargs) diff --git a/pytorch3d/common/workaround/symeig3x3.py b/pytorch3d/common/workaround/symeig3x3.py index ca736602..c7fda114 100644 --- a/pytorch3d/common/workaround/symeig3x3.py +++ b/pytorch3d/common/workaround/symeig3x3.py @@ -90,7 +90,6 @@ class _SymEig3x3(nn.Module): ) p = torch.sqrt(p2 / 6.0) - # pyrefly: ignore [unsupported-operation] B = (inputs - q[..., None, None] * self._identity) / p[..., None, None] r = torch.det(B) / 2.0 @@ -175,10 +174,8 @@ class _SymEig3x3(nn.Module): """ # Find the eigenvector corresponding to alpha0, its eigenvalue is distinct - # pyrefly: ignore [unsupported-operation] ev0 = self._get_ev0(inputs - alpha0[..., None, None] * self._identity) u, v = self._get_uv(ev0) - # pyrefly: ignore [unsupported-operation] ev1 = self._get_ev1(inputs - alpha1[..., None, None] * self._identity, u, v) # Third eigenvector is computed as the cross-product of the other two ev2 = torch.cross(ev0, ev1, dim=-1) @@ -253,7 +250,6 @@ class _SymEig3x3(nn.Module): """ min_idx = w.abs().argmin(dim=-1) - # pyrefly: ignore [bad-index] rotation_2d = self._rotations_3d[min_idx].to(w) u = F.normalize((rotation_2d @ w[..., None])[..., 0], dim=-1) diff --git a/pytorch3d/datasets/r2n2/r2n2.py b/pytorch3d/datasets/r2n2/r2n2.py index 307478fa..c4e182f9 100644 --- a/pytorch3d/datasets/r2n2/r2n2.py +++ b/pytorch3d/datasets/r2n2/r2n2.py @@ -200,7 +200,6 @@ class R2N2(ShapeNetBase): # pragma: no cover ) % (shapenet_dir, ", ".join(synset_not_present)) warnings.warn(msg) - # pyrefly: ignore [bad-override] def __getitem__(self, model_idx, view_idxs: Optional[List[int]] = None) -> Dict: """ Read a model by the given index. @@ -371,7 +370,6 @@ class R2N2(ShapeNetBase): # pragma: no cover T = RT[3, :3] return R, T - # pyrefly: ignore [bad-override] def render( self, model_ids: Optional[List[str]] = None, diff --git a/pytorch3d/datasets/r2n2/utils.py b/pytorch3d/datasets/r2n2/utils.py index 951eae2a..0bb52ae1 100644 --- a/pytorch3d/datasets/r2n2/utils.py +++ b/pytorch3d/datasets/r2n2/utils.py @@ -62,10 +62,8 @@ def collate_batched_R2N2(batch: List[Dict]): # pragma: no cover # all models have the same number of views V, stack the batches of # views of each model into a new batch of shape (N, V, H, W, 3). # Otherwise leave it as a list. - # pyrefly: ignore [not-iterable] if "images" in collated_dict: try: - # pyrefly: ignore [unsupported-operation] collated_dict["images"] = torch.stack(collated_dict["images"]) except RuntimeError: print( @@ -77,14 +75,10 @@ def collate_batched_R2N2(batch: List[Dict]): # pragma: no cover # matrices and that all models have the same number of views V, stack each # type of matrices into a new batch of shape (N, V, ...). # Otherwise leave them as lists. - # pyrefly: ignore [not-iterable] if all(x in collated_dict for x in ["R", "T", "K"]): try: - # pyrefly: ignore [unsupported-operation] collated_dict["R"] = torch.stack(collated_dict["R"]) # (N, V, 3, 3) - # pyrefly: ignore [unsupported-operation] collated_dict["T"] = torch.stack(collated_dict["T"]) # (N, V, 3) - # pyrefly: ignore [unsupported-operation] collated_dict["K"] = torch.stack(collated_dict["K"]) # (N, V, 4, 4) except RuntimeError: print( @@ -95,10 +89,8 @@ def collate_batched_R2N2(batch: List[Dict]): # pragma: no cover # If collate_batched_meshes receives voxels and all models have the same # number of views V, stack the batches of voxels into a new batch of shape # (N, V, S, S, S), where S is the voxel size. - # pyrefly: ignore [not-iterable] if "voxels" in collated_dict: try: - # pyrefly: ignore [unsupported-operation] collated_dict["voxels"] = torch.stack(collated_dict["voxels"]) except RuntimeError: print( @@ -466,7 +458,6 @@ class BlenderCamera(CamerasBase): # pragma: no cover def get_projection_transform(self, **kwargs) -> Transform3d: transform = Transform3d(device=self.device) - # pyrefly: ignore [not-callable] transform._matrix = self.K.transpose(1, 2).contiguous() return transform diff --git a/pytorch3d/datasets/shapenet_base.py b/pytorch3d/datasets/shapenet_base.py index 0f4c8595..d90bea67 100644 --- a/pytorch3d/datasets/shapenet_base.py +++ b/pytorch3d/datasets/shapenet_base.py @@ -52,7 +52,6 @@ class ShapeNetBase(torch.utils.data.Dataset): # pragma: no cover """ return len(self.model_ids) - # pyrefly: ignore [bad-override-param-name] def __getitem__(self, idx) -> Dict: """ Read a model by the given index. Need to be implemented for every child class @@ -148,17 +147,12 @@ class ShapeNetBase(torch.utils.data.Dataset): # pragma: no cover idxs = self._handle_render_inputs(model_ids, categories, sample_nums, idxs) # Use the getitem method which loads mesh + texture models = [self[idx] for idx in idxs] - # pyrefly: ignore [unsupported-operation] meshes = collate_batched_meshes(models)["mesh"] - # pyrefly: ignore [missing-attribute] if meshes.textures is None: - # pyrefly: ignore [missing-attribute] meshes.textures = TexturesVertex( - # pyrefly: ignore [missing-attribute] verts_features=torch.ones_like(meshes.verts_padded(), device=device) ) - # pyrefly: ignore [missing-attribute] meshes = meshes.to(device) cameras = kwargs.get("cameras", FoVPerspectiveCameras()).to(device) if len(cameras) != 1 and len(cameras) % len(meshes) != 0: diff --git a/pytorch3d/datasets/utils.py b/pytorch3d/datasets/utils.py index 935023c0..9974f1ea 100644 --- a/pytorch3d/datasets/utils.py +++ b/pytorch3d/datasets/utils.py @@ -34,14 +34,12 @@ def collate_batched_meshes(batch: List[Dict]): # pragma: no cover for k in batch[0].keys(): collated_dict[k] = [d[k] for d in batch] - # pyrefly: ignore [unsupported-operation] collated_dict["mesh"] = None if {"verts", "faces"}.issubset(collated_dict.keys()): textures = None if "textures" in collated_dict: textures = TexturesAtlas(atlas=collated_dict["textures"]) - # pyrefly: ignore [unsupported-operation] collated_dict["mesh"] = Meshes( verts=collated_dict["verts"], faces=collated_dict["faces"], diff --git a/pytorch3d/implicitron/dataset/dataset_base.py b/pytorch3d/implicitron/dataset/dataset_base.py index 78e6f204..98ff999f 100644 --- a/pytorch3d/implicitron/dataset/dataset_base.py +++ b/pytorch3d/implicitron/dataset/dataset_base.py @@ -101,7 +101,6 @@ class DatasetBase(GenericWorkaround, torch.utils.data.Dataset[FrameData]): # crashes without overriding __getitem__ sequence_category = self[first_frame_idx].sequence_category c2seq[sequence_category].append(sequence_name) - # pyrefly: ignore [bad-return] return dict(c2seq) def sequence_frames_in_order( diff --git a/pytorch3d/implicitron/dataset/frame_data.py b/pytorch3d/implicitron/dataset/frame_data.py index 5ec6214e..a73fa710 100644 --- a/pytorch3d/implicitron/dataset/frame_data.py +++ b/pytorch3d/implicitron/dataset/frame_data.py @@ -297,11 +297,7 @@ class FrameData(Mapping[str, Any]): depth_map = self.depth_map if depth_map is not None: clamp_bbox_xyxy_depth = rescale_bbox( - # pyrefly: ignore [bad-argument-type] - clamp_bbox_xyxy, - # pyrefly: ignore [bad-argument-type] - tuple(depth_map.shape[-2:]), - effective_image_size_hw, + clamp_bbox_xyxy, tuple(depth_map.shape[-2:]), effective_image_size_hw ).long() self.depth_map = crop_around_box( depth_map, @@ -312,11 +308,7 @@ class FrameData(Mapping[str, Any]): depth_mask = self.depth_mask if depth_mask is not None: clamp_bbox_xyxy_depth = rescale_bbox( - # pyrefly: ignore [bad-argument-type] - clamp_bbox_xyxy, - # pyrefly: ignore [bad-argument-type] - tuple(depth_mask.shape[-2:]), - effective_image_size_hw, + clamp_bbox_xyxy, tuple(depth_mask.shape[-2:]), effective_image_size_hw ).long() self.depth_mask = crop_around_box( depth_mask, @@ -461,7 +453,6 @@ class FrameDataBuilderBase(ReplaceableBase, Generic[FrameDataSubtype], ABC): """ # To be initialised to FrameDataSubtype - # pyrefly: ignore [invalid-annotation] frame_data_type: ClassVar[Type[FrameDataSubtype]] @abstractmethod diff --git a/pytorch3d/implicitron/dataset/json_index_dataset.py b/pytorch3d/implicitron/dataset/json_index_dataset.py index 2ea4b091..0669e515 100644 --- a/pytorch3d/implicitron/dataset/json_index_dataset.py +++ b/pytorch3d/implicitron/dataset/json_index_dataset.py @@ -425,7 +425,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase): raise ValueError("subsets not loaded") if is_known_frame_scalar(frame_type): cameras.append(self[frame_idx].camera) - # pyrefly: ignore [bad-argument-type] return join_cameras_as_batch(cameras) def __getitem__(self, index) -> FrameData: diff --git a/pytorch3d/implicitron/dataset/json_index_dataset_map_provider_v2.py b/pytorch3d/implicitron/dataset/json_index_dataset_map_provider_v2.py index cf1d9859..fd4fdd64 100644 --- a/pytorch3d/implicitron/dataset/json_index_dataset_map_provider_v2.py +++ b/pytorch3d/implicitron/dataset/json_index_dataset_map_provider_v2.py @@ -311,7 +311,6 @@ class JsonIndexDatasetMapProviderV2(DatasetMapProviderBase): subset_mapping["test"], ) = self._extend_test_data_with_known_views( subset_mapping, - # pyrefly: ignore [bad-argument-type] eval_batch_index, ) @@ -323,7 +322,6 @@ class JsonIndexDatasetMapProviderV2(DatasetMapProviderBase): try: test_dataset.eval_batches = ( test_dataset.seq_frame_index_to_dataset_index( - # pyrefly: ignore [bad-argument-type] eval_batch_index, ) ) @@ -337,7 +335,6 @@ class JsonIndexDatasetMapProviderV2(DatasetMapProviderBase): ) test_dataset.eval_batches = ( test_dataset.seq_frame_index_to_dataset_index( - # pyrefly: ignore [bad-argument-type] eval_batch_index, allow_missing_indices=True, remove_missing_indices=True, diff --git a/pytorch3d/implicitron/dataset/orm_types.py b/pytorch3d/implicitron/dataset/orm_types.py index 808cc987..e66ce4b1 100644 --- a/pytorch3d/implicitron/dataset/orm_types.py +++ b/pytorch3d/implicitron/dataset/orm_types.py @@ -90,7 +90,6 @@ def TupleTypeFactory(dtype=float, shape: Tuple[int, ...] = (2,)): impl = LargeBinary _format = format_symbol * math.prod(shape) - # pyrefly: ignore [bad-override-param-name] def process_bind_param(self, value, _): if value is None: return None @@ -100,7 +99,6 @@ def TupleTypeFactory(dtype=float, shape: Tuple[int, ...] = (2,)): return struct.pack(TupleType._format, *value) - # pyrefly: ignore [bad-override-param-name] def process_result_value(self, value, _): if value is None: return None diff --git a/pytorch3d/implicitron/dataset/rendered_mesh_dataset_map_provider.py b/pytorch3d/implicitron/dataset/rendered_mesh_dataset_map_provider.py index 3797d7e5..29013ad0 100644 --- a/pytorch3d/implicitron/dataset/rendered_mesh_dataset_map_provider.py +++ b/pytorch3d/implicitron/dataset/rendered_mesh_dataset_map_provider.py @@ -121,17 +121,11 @@ class RenderedMeshDatasetMapProvider(DatasetMapProviderBase): self.poses = poses.cpu() # pyre-ignore[16] self.train_dataset = SingleSceneDataset( # pyre-ignore[28] - # pyrefly: ignore [unexpected-keyword] object_name="cow", - # pyrefly: ignore [unexpected-keyword] images=list(images.permute(0, 3, 1, 2).cpu()), - # pyrefly: ignore [unexpected-keyword] fg_probabilities=list(masks[:, None].cpu()), - # pyrefly: ignore [unexpected-keyword] poses=[self.poses[i] for i in range(len(poses))], - # pyrefly: ignore [unexpected-keyword] frame_types=[DATASET_TYPE_KNOWN] * len(poses), - # pyrefly: ignore [unexpected-keyword] eval_batches=None, ) diff --git a/pytorch3d/implicitron/dataset/single_sequence_dataset.py b/pytorch3d/implicitron/dataset/single_sequence_dataset.py index 7700c1d3..90995dec 100644 --- a/pytorch3d/implicitron/dataset/single_sequence_dataset.py +++ b/pytorch3d/implicitron/dataset/single_sequence_dataset.py @@ -131,12 +131,10 @@ class SingleSceneDatasetMapProviderBase(DatasetMapProviderBase): None # pyre-ignore[16] if self.fg_probabilities is None - # pyrefly: ignore [bad-index] else self.fg_probabilities[split] ) eval_batches = [[i] for i in range(len(split))] if split_idx != 0 and self.n_known_frames_for_test is not None: - # pyrefly: ignore [missing-attribute] train_split = self.i_split[0] if set_eval_batches: generator = np.random.default_rng(seed=0) diff --git a/pytorch3d/implicitron/dataset/sql_dataset.py b/pytorch3d/implicitron/dataset/sql_dataset.py index f0e75a57..7e78004a 100644 --- a/pytorch3d/implicitron/dataset/sql_dataset.py +++ b/pytorch3d/implicitron/dataset/sql_dataset.py @@ -221,7 +221,6 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): def __len__(self) -> int: return len(self._index) - # pyrefly: ignore [bad-override-param-name] def __getitem__(self, frame_idx: Union[int, Tuple[str, int]]) -> FrameData: """ Fetches FrameData by either iloc in the index or by (sequence, frame_no) pair @@ -425,7 +424,6 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): # override @property - # pyrefly: ignore [bad-override] def frame_data_type(self) -> Type[FrameData]: return self.frame_data_builder.frame_data_type @@ -632,9 +630,7 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): # dev load: 94 s / 23 s (3.1M / 500K) pick_frames_criteria.append( sa.or_( - # pyrefly: ignore [missing-attribute] self.frame_annotations_type._mask_mass.is_(None), - # pyrefly: ignore [missing-attribute] self.frame_annotations_type._mask_mass != 0, ) ) @@ -701,7 +697,6 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): where_conditions.append( sa.or_( self.frame_annotations_type._mask_mass.is_(None), # pyre-ignore[16] - # pyrefly: ignore [missing-attribute] self.frame_annotations_type._mask_mass != 0, ) ) diff --git a/pytorch3d/implicitron/dataset/types.py b/pytorch3d/implicitron/dataset/types.py index 2ddeb3be..faf8c790 100644 --- a/pytorch3d/implicitron/dataset/types.py +++ b/pytorch3d/implicitron/dataset/types.py @@ -162,7 +162,6 @@ def load_dataclass(f: IO, cls: Type[_X], binary: bool = False) -> _X: else: res = _dataclass_from_dict(asdict, cls) - # pyrefly: ignore [bad-return] return res diff --git a/pytorch3d/implicitron/dataset/utils.py b/pytorch3d/implicitron/dataset/utils.py index c8c9726b..4e6c47d9 100644 --- a/pytorch3d/implicitron/dataset/utils.py +++ b/pytorch3d/implicitron/dataset/utils.py @@ -117,7 +117,6 @@ def crop_around_box( # bbox is xyxy, where the upper bound is corrected with +1 bbox = clamp_box_to_image_bounds_and_round( bbox, - # pyrefly: ignore [bad-argument-type] image_size_hw=tuple(tensor.shape[-2:]), ) tensor = tensor[..., bbox[1] : bbox[3], bbox[0] : bbox[2]] diff --git a/pytorch3d/implicitron/evaluation/evaluate_new_view_synthesis.py b/pytorch3d/implicitron/evaluation/evaluate_new_view_synthesis.py index f17b472d..1d7ab689 100644 --- a/pytorch3d/implicitron/evaluation/evaluate_new_view_synthesis.py +++ b/pytorch3d/implicitron/evaluation/evaluate_new_view_synthesis.py @@ -312,7 +312,6 @@ def eval_batch( ) if visualize: - # pyrefly: ignore [unbound-name] visualizer.show_rgb( results[metric_name].item(), metric_name, loss_mask_now ) @@ -331,7 +330,6 @@ def eval_batch( results["depth_abs" + name_postfix] = abs_.mean() if visualize: - # pyrefly: ignore [unbound-name] visualizer.show_depth(abs_.mean().item(), name_postfix, loss_mask_now) if break_after_visualising: breakpoint() # noqa: B601 diff --git a/pytorch3d/implicitron/models/generic_model.py b/pytorch3d/implicitron/models/generic_model.py index 7f7d0a1c..0687cc1a 100644 --- a/pytorch3d/implicitron/models/generic_model.py +++ b/pytorch3d/implicitron/models/generic_model.py @@ -472,7 +472,6 @@ class GenericModel(ImplicitronModelBase): sequence_name=safe_slice_targets(sequence_name), frame_timestamp=safe_slice_targets(frame_timestamp), ) - # pyrefly: ignore [unsupported-operation] custom_args["global_code"] = global_code # pyre-fixme[29]: `Union[(self: Tensor) -> Any, Tensor, Module]` is not a diff --git a/pytorch3d/implicitron/models/implicit_function/voxel_grid.py b/pytorch3d/implicitron/models/implicit_function/voxel_grid.py index 26b64f50..60d58544 100644 --- a/pytorch3d/implicitron/models/implicit_function/voxel_grid.py +++ b/pytorch3d/implicitron/models/implicit_function/voxel_grid.py @@ -907,7 +907,6 @@ class VoxelGridModule(Configurable, torch.nn.Module): else: # Torch Module to hold parameters since they can only be registered # at object level. - # pyrefly: ignore [bad-assignment] self.params = _RegistratedBufferDict(vars(params)) @staticmethod diff --git a/pytorch3d/implicitron/models/implicit_function/voxel_grid_implicit_function.py b/pytorch3d/implicitron/models/implicit_function/voxel_grid_implicit_function.py index ecd84684..f58c15b2 100644 --- a/pytorch3d/implicitron/models/implicit_function/voxel_grid_implicit_function.py +++ b/pytorch3d/implicitron/models/implicit_function/voxel_grid_implicit_function.py @@ -476,7 +476,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module): call_epochs = list( set(self.scaffold_calculating_epochs) | set(self.volume_cropping_epochs) ) - # pyrefly: ignore [bad-return] return call_epochs, callback def _crop(self, epoch: int) -> bool: @@ -582,7 +581,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module): ) cls = registry.get(DecoderFunctionBase, type_) - # pyrefly: ignore [bad-argument-type] need_input_dim = any(field.name == "input_dim" for field in fields(cls)) if need_input_dim: self.decoder_density = cls(input_dim=input_dim, **args) @@ -623,7 +621,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module): input_dim = input_dim0 + input_dim1 cls = registry.get(DecoderFunctionBase, type_) - # pyrefly: ignore [bad-argument-type] need_input_dim = any(field.name == "input_dim" for field in fields(cls)) if need_input_dim: self.decoder_color = cls(input_dim=input_dim, **args) diff --git a/pytorch3d/implicitron/models/renderer/base.py b/pytorch3d/implicitron/models/renderer/base.py index d82361b7..a92cb8f1 100644 --- a/pytorch3d/implicitron/models/renderer/base.py +++ b/pytorch3d/implicitron/models/renderer/base.py @@ -110,7 +110,6 @@ class ImplicitronRayBundle: # equivalent to: 0.5 * (bins[..., 1:] + bins[..., :-1]) but more efficient # pyre-ignore return torch.lerp(self.bins[..., :-1], self.bins[..., 1:], 0.5) - # pyrefly: ignore [bad-return] return self._lengths @lengths.setter @@ -167,7 +166,6 @@ class ImplicitronRayBundle: ) num_inputs = camera_counts.sum().item() max_size = torch.max(camera_counts).item() - # pyrefly: ignore [bad-argument-type] xys = packed_to_padded(self.xys, first_idxs, max_size) # pyre-ignore [7] pytorch typeshed inaccuracy return xys, first_idxs, num_inputs diff --git a/pytorch3d/implicitron/models/renderer/raymarcher.py b/pytorch3d/implicitron/models/renderer/raymarcher.py index a7bd9335..2bca6e77 100644 --- a/pytorch3d/implicitron/models/renderer/raymarcher.py +++ b/pytorch3d/implicitron/models/renderer/raymarcher.py @@ -198,7 +198,6 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module): depth = (weights * ray_lengths)[..., None].sum(dim=-2) alpha = opacities if self.blend_output else 1 - # pyrefly: ignore [bad-index] if self._bg_color.shape[-1] not in [1, features.shape[-1]]: raise ValueError("Wrong number of background color channels.") # pyre-fixme[58]: `*` is not supported for operand types `int` and diff --git a/pytorch3d/implicitron/models/renderer/sdf_renderer.py b/pytorch3d/implicitron/models/renderer/sdf_renderer.py index 7fc3676e..c769b5f5 100644 --- a/pytorch3d/implicitron/models/renderer/sdf_renderer.py +++ b/pytorch3d/implicitron/models/renderer/sdf_renderer.py @@ -146,7 +146,6 @@ class SignedDistanceFunctionRenderer(BaseRenderer, torch.nn.Module): # Sample points for the eikonal loss eik_bounding_box: float = self.object_bounding_sphere n_eik_points = batch_size * num_pixels // 2 - # pyrefly: ignore [no-matching-overload] eikonal_points = torch.empty( n_eik_points, 3, diff --git a/pytorch3d/implicitron/models/utils.py b/pytorch3d/implicitron/models/utils.py index 8f2f4e7b..1b867ce1 100644 --- a/pytorch3d/implicitron/models/utils.py +++ b/pytorch3d/implicitron/models/utils.py @@ -118,7 +118,6 @@ def weighted_sum_losses( return None loss = sum(losses_weighted) assert torch.is_tensor(loss) - # pyrefly: ignore [bad-return] return loss diff --git a/pytorch3d/implicitron/tools/config.py b/pytorch3d/implicitron/tools/config.py index e553cd06..4479fe65 100644 --- a/pytorch3d/implicitron/tools/config.py +++ b/pytorch3d/implicitron/tools/config.py @@ -231,9 +231,7 @@ class Configurable: return obj -# pyrefly: ignore [invalid-type-var] _X = TypeVar("X", bound=ReplaceableBase) -# pyrefly: ignore [invalid-type-var] _Y = TypeVar("Y", bound=Union[ReplaceableBase, Configurable]) @@ -892,13 +890,10 @@ def expand_args_fields( continue expand_args_fields(base, _do_not_process=_do_not_process) if "_creation_functions" in base.__dict__: - # pyrefly: ignore [missing-attribute] creation_functions.extend(base._creation_functions) if "_known_implementations" in base.__dict__: - # pyrefly: ignore [missing-attribute] known_implementations.update(base._known_implementations) if "_processed_members" in base.__dict__: - # pyrefly: ignore [missing-attribute] processed_members.update(base._processed_members) to_process: List[Tuple[str, Type, _ProcessType]] = [] diff --git a/pytorch3d/implicitron/tools/rasterize_mc.py b/pytorch3d/implicitron/tools/rasterize_mc.py index ff1fd1e6..0ca7669b 100644 --- a/pytorch3d/implicitron/tools/rasterize_mc.py +++ b/pytorch3d/implicitron/tools/rasterize_mc.py @@ -62,14 +62,9 @@ def rasterize_sparse_ray_bundle( max_size = torch.max(camera_counts).item() features_depth_ras = packed_to_padded( - # pyrefly: ignore [bad-argument-type] - features_depth_ras[:, 0], - first_idxs, - # pyrefly: ignore [bad-argument-type] - max_size, + features_depth_ras[:, 0], first_idxs, max_size ) if masks is not None: - # pyrefly: ignore [bad-argument-type] padded_mask = packed_to_padded(masks.flatten(1, -1), first_idxs, max_size) masks_ras = padded_mask * masks_ras diff --git a/pytorch3d/implicitron/tools/video_writer.py b/pytorch3d/implicitron/tools/video_writer.py index 4c74e194..c0abd0cc 100644 --- a/pytorch3d/implicitron/tools/video_writer.py +++ b/pytorch3d/implicitron/tools/video_writer.py @@ -124,12 +124,10 @@ class VideoWriter: if im is not None: if resize is not None: if isinstance(resize, float): - # pyrefly: ignore [bad-assignment] resize = [int(resize * s) for s in im.size] else: resize = im.size # make sure size is divisible by 2 - # pyrefly: ignore [bad-assignment, bad-index, unsupported-operation] resize = tuple([resize[i] + resize[i] % 2 for i in (0, 1)]) im = im.resize(resize, Image.ANTIALIAS) diff --git a/pytorch3d/io/experimental_gltf_io.py b/pytorch3d/io/experimental_gltf_io.py index 5c926a47..99226a5a 100644 --- a/pytorch3d/io/experimental_gltf_io.py +++ b/pytorch3d/io/experimental_gltf_io.py @@ -120,7 +120,6 @@ class _TargetType(IntEnum): class OurEncoder(json.JSONEncoder): - # pyrefly: ignore [bad-override-param-name] def default(self, obj): if isinstance(obj, np.int64): return str(obj) @@ -243,7 +242,6 @@ class _GLTFLoader: by _get_texture_map_image which caches it. """ - # pyrefly: ignore [unsupported-operation] image_json = self._json_data["images"][image_index] buffer_view = self._buffer_views[image_json["bufferView"]] if "byteStride" in buffer_view: @@ -409,12 +407,10 @@ class _GLTFLoader: verts_uvs[:, 1] = 1 - verts_uvs[:, -1] faces_uvs = indices material_index = primitive.get("material", 0) - # pyrefly: ignore [unsupported-operation] material = self._json_data["materials"][material_index] material_roughness = material["pbrMetallicRoughness"] if "baseColorTexture" in material_roughness: texture_index = material_roughness["baseColorTexture"]["index"] - # pyrefly: ignore [unsupported-operation] texture_json = self._json_data["textures"][texture_index] # Todo - include baseColorFactor when also given # Todo - look at the sampler @@ -559,7 +555,6 @@ class _GLTFWriter: # pyre-fixme[6]: Incompatible parameter type self._json_data["scene"] = scene_index self._json_data["scenes"].append({"nodes": [scene_index]}) - # pyrefly: ignore [unsupported-operation] self._json_data["asset"] = {"version": "2.0"} node = {"name": "Node", "mesh": 0} self._json_data["nodes"].append(node) @@ -626,7 +621,6 @@ class _GLTFWriter: byte_per_element = 3 * _DTYPE_BYTES[_ITEM_TYPES[_ComponentType.FLOAT]] elif key == "texcoords": component_type = _ComponentType.FLOAT - # pyrefly: ignore [missing-attribute] data = self.mesh.textures.verts_uvs_list()[0].cpu().numpy() data[:, 1] = 1 - data[:, -1] # flip y tex-coordinate element_type = "VEC2" @@ -636,7 +630,6 @@ class _GLTFWriter: byte_per_element = 2 * _DTYPE_BYTES[_ITEM_TYPES[_ComponentType.FLOAT]] elif key == "texvertices": component_type = _ComponentType.FLOAT - # pyrefly: ignore [missing-attribute] data = self.mesh.textures.verts_features_list()[0].cpu().numpy() element_type = "VEC3" buffer_view = 2 @@ -707,14 +700,11 @@ class _GLTFWriter: target = _TargetType.ELEMENT_ARRAY_BUFFER bufferview["target"] = target - # pyrefly: ignore [bad-typed-dict-key] bufferview["byteOffset"] = kwargs.get("offset") - # pyrefly: ignore [bad-typed-dict-key] bufferview["byteLength"] = kwargs.get("byte_length") self._json_data["bufferViews"].append(bufferview) def _write_image_buffer(self, **kwargs) -> Tuple[int, bytes]: - # pyrefly: ignore [missing-attribute] image_np = self.mesh.textures.maps_list()[0].cpu().numpy() image_array = (image_np * 255.0).astype(np.uint8) im = Image.fromarray(image_array) @@ -726,7 +716,6 @@ class _GLTFWriter: bufferview_image = { "buffer": 0, } - # pyrefly: ignore [bad-typed-dict-key] bufferview_image["byteOffset"] = kwargs.get("offset") bufferview_image["byteLength"] = image_data_byte_length self._json_data["bufferViews"].append(bufferview_image) diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index e1862fc0..4a32c7b6 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -226,7 +226,6 @@ def load_obj( with _open_file(f, path_manager, "r") as f: return _load_obj( f, - # pyrefly: ignore [bad-argument-type] data_dir=data_dir, load_textures=load_textures, create_texture_atlas=create_texture_atlas, @@ -642,7 +641,6 @@ def _load_obj( material_names.append(next(iter(material_colors.keys()))) # replace all -1 by 0 material idx if torch.is_tensor(faces_materials_idx): - # pyrefly: ignore [missing-attribute] faces_materials_idx.clamp_(min=0) if create_texture_atlas: @@ -651,18 +649,14 @@ def _load_obj( # Create an array of strings of material names for each face. # If faces_materials_idx == -1 then that face doesn't have a material. - # pyrefly: ignore [missing-attribute] idx = faces_materials_idx.cpu().numpy() face_material_names = np.array([""] + material_names)[idx + 1] # (F,) # Construct the atlas. texture_atlas = make_mesh_texture_atlas( - # pyrefly: ignore [bad-argument-type] material_colors, - # pyrefly: ignore [bad-argument-type] texture_images, face_material_names, - # pyrefly: ignore [bad-argument-type] faces_textures_idx, verts_uvs, texture_atlas_size, diff --git a/pytorch3d/io/ply_io.py b/pytorch3d/io/ply_io.py index ec517b2c..db077a28 100644 --- a/pytorch3d/io/ply_io.py +++ b/pytorch3d/io/ply_io.py @@ -878,14 +878,10 @@ def _get_verts_column_indices( ): color_scale = 1.0 / 255 return _VertsColumnIndices( - # pyrefly: ignore [bad-argument-type] point_idxs=point_idxs, - # pyrefly: ignore [bad-argument-type] color_idxs=None if None in color_idxs else color_idxs, color_scale=color_scale, - # pyrefly: ignore [bad-argument-type] normal_idxs=None if None in normal_idxs else normal_idxs, - # pyrefly: ignore [bad-argument-type] texture_uv_idxs=None if None in texture_uv_idxs else texture_uv_idxs, ) diff --git a/pytorch3d/loss/point_mesh_distance.py b/pytorch3d/loss/point_mesh_distance.py index b4f69e20..32bb71dd 100644 --- a/pytorch3d/loss/point_mesh_distance.py +++ b/pytorch3d/loss/point_mesh_distance.py @@ -81,7 +81,6 @@ class _PointFaceDistance(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists): grad_dists = grad_dists.contiguous() points, tris, idxs = ctx.saved_tensors @@ -144,7 +143,6 @@ class _FacePointDistance(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists): grad_dists = grad_dists.contiguous() points, tris, idxs = ctx.saved_tensors @@ -196,7 +194,6 @@ class _PointEdgeDistance(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists): grad_dists = grad_dists.contiguous() points, segms, idxs = ctx.saved_tensors @@ -247,7 +244,6 @@ class _EdgePointDistance(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists): grad_dists = grad_dists.contiguous() points, segms, idxs = ctx.saved_tensors diff --git a/pytorch3d/ops/ball_query.py b/pytorch3d/ops/ball_query.py index 8008c050..698d816c 100644 --- a/pytorch3d/ops/ball_query.py +++ b/pytorch3d/ops/ball_query.py @@ -36,7 +36,6 @@ class _ball_query(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists, grad_idx): p1, p2, lengths1, lengths2, idx = ctx.saved_tensors # TODO(gkioxari) Change cast to floats once we add support for doubles. diff --git a/pytorch3d/ops/graph_conv.py b/pytorch3d/ops/graph_conv.py index aba80834..a43eeb3a 100644 --- a/pytorch3d/ops/graph_conv.py +++ b/pytorch3d/ops/graph_conv.py @@ -162,7 +162,6 @@ class GatherScatter(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_output = grad_output.contiguous() edges = ctx.saved_tensors[0] diff --git a/pytorch3d/ops/interp_face_attrs.py b/pytorch3d/ops/interp_face_attrs.py index 4cf6b993..c1f04891 100644 --- a/pytorch3d/ops/interp_face_attrs.py +++ b/pytorch3d/ops/interp_face_attrs.py @@ -72,7 +72,6 @@ class _InterpFaceAttrs(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_pix_attrs): args = ctx.saved_tensors args = args + (grad_pix_attrs,) diff --git a/pytorch3d/ops/iou_box3d.py b/pytorch3d/ops/iou_box3d.py index 5b245811..3c01bd65 100644 --- a/pytorch3d/ops/iou_box3d.py +++ b/pytorch3d/ops/iou_box3d.py @@ -106,7 +106,6 @@ class _box3d_overlap(Function): return vol, iou @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_vol, grad_iou): raise ValueError("box3d_overlap backward is not supported") diff --git a/pytorch3d/ops/knn.py b/pytorch3d/ops/knn.py index a4530500..114334fd 100644 --- a/pytorch3d/ops/knn.py +++ b/pytorch3d/ops/knn.py @@ -95,7 +95,6 @@ class _knn_points(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_dists, grad_idx): p1, p2, lengths1, lengths2, idx = ctx.saved_tensors norm = ctx.norm diff --git a/pytorch3d/ops/marching_cubes.py b/pytorch3d/ops/marching_cubes.py index b6f90d8c..17236857 100644 --- a/pytorch3d/ops/marching_cubes.py +++ b/pytorch3d/ops/marching_cubes.py @@ -247,7 +247,6 @@ class _marching_cubes(Function): return verts, faces, ids @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_verts, grad_faces): raise ValueError("marching_cubes backward is not supported") diff --git a/pytorch3d/ops/mesh_face_areas_normals.py b/pytorch3d/ops/mesh_face_areas_normals.py index 4937d1f6..ea91f482 100644 --- a/pytorch3d/ops/mesh_face_areas_normals.py +++ b/pytorch3d/ops/mesh_face_areas_normals.py @@ -50,7 +50,6 @@ class _MeshFaceAreasNormals(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_areas, grad_normals): grad_areas = grad_areas.contiguous() grad_normals = grad_normals.contiguous() diff --git a/pytorch3d/ops/packed_to_padded.py b/pytorch3d/ops/packed_to_padded.py index 8bc18c2a..fd40bcc4 100644 --- a/pytorch3d/ops/packed_to_padded.py +++ b/pytorch3d/ops/packed_to_padded.py @@ -54,7 +54,6 @@ class _PackedToPadded(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_output = grad_output.contiguous() first_idxs = ctx.saved_tensors[0] @@ -144,7 +143,6 @@ class _PaddedToPacked(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_output = grad_output.contiguous() first_idxs = ctx.saved_tensors[0] diff --git a/pytorch3d/ops/points_alignment.py b/pytorch3d/ops/points_alignment.py index 1ae50cdb..6ca2950e 100644 --- a/pytorch3d/ops/points_alignment.py +++ b/pytorch3d/ops/points_alignment.py @@ -103,17 +103,14 @@ def iterative_closest_point( Xt, num_points_X = oputil.convert_pointclouds_to_tensor(X) Yt, num_points_Y = oputil.convert_pointclouds_to_tensor(Y) - # pyrefly: ignore [missing-attribute] b, size_X, dim = Xt.shape - # pyrefly: ignore [missing-attribute] if (Xt.shape[2] != Yt.shape[2]) or (Xt.shape[0] != Yt.shape[0]): raise ValueError( "Point sets X and Y have to have the same " + "number of batches and data dimensions." ) - # pyrefly: ignore [missing-attribute] if ((num_points_Y < Yt.shape[1]).any() or (num_points_X < Xt.shape[1]).any()) and ( num_points_Y != num_points_X ).any(): @@ -124,7 +121,6 @@ def iterative_closest_point( < num_points_X[:, None] ).type_as(Xt) else: - # pyrefly: ignore [missing-attribute] mask_X = Xt.new_ones(b, size_X) # clone the initial point cloud @@ -149,15 +145,11 @@ def iterative_closest_point( "of scalars of shape (minibatch,)." ) from None # apply the init transform to the input point cloud - # pyrefly: ignore [bad-argument-type] Xt = _apply_similarity_transform(Xt, R, T, s) else: # initialize the transformation with identity - # pyrefly: ignore [missing-attribute] R = oputil.eyes(dim, b, device=Xt.device, dtype=Xt.dtype) - # pyrefly: ignore [missing-attribute] T = Xt.new_zeros((b, dim)) - # pyrefly: ignore [missing-attribute] s = Xt.new_ones(b) prev_rmse = None @@ -171,14 +163,7 @@ def iterative_closest_point( # the main loop over ICP iterations for iteration in range(max_iterations): Xt_nn_points = knn_points( - # pyrefly: ignore [bad-argument-type] - Xt, - # pyrefly: ignore [bad-argument-type] - Yt, - lengths1=num_points_X, - lengths2=num_points_Y, - K=1, - return_nn=True, + Xt, Yt, lengths1=num_points_X, lengths2=num_points_Y, K=1, return_nn=True ).knn[:, :, 0, :] # get the alignment of the nearest neighbors from Yt with Xt_init @@ -231,7 +216,6 @@ def iterative_closest_point( if oputil.is_pointclouds(X): Xt = X.update_padded(Xt) # type: ignore - # pyrefly: ignore [bad-argument-type] return ICPSolution(converged, rmse, Xt, SimilarityTransform(R, T, s), t_history) @@ -292,7 +276,6 @@ def corresponding_points_alignment( Xt, num_points = oputil.convert_pointclouds_to_tensor(X) Yt, num_points_Y = oputil.convert_pointclouds_to_tensor(Y) - # pyrefly: ignore [missing-attribute] if (Xt.shape != Yt.shape) or (num_points != num_points_Y).any(): raise ValueError( "Point sets X and Y have to have the same \ @@ -308,33 +291,25 @@ def corresponding_points_alignment( weights = [w[..., None] for w in weights] weights = strutil.list_to_padded(weights)[..., 0] - # pyrefly: ignore [bad-index] if Xt.shape[:2] != weights.shape: raise ValueError("weights should have the same first two dimensions as X.") - # pyrefly: ignore [not-iterable] b, n, dim = Xt.shape - # pyrefly: ignore [bad-index, missing-attribute] if (num_points < Xt.shape[1]).any() or (num_points < Yt.shape[1]).any(): # in case we got Pointclouds as input, mask the unused entries in Xc, Yc mask = ( torch.arange(n, dtype=torch.int64, device=Xt.device)[None] < num_points[:, None] ).type_as(Xt) - # pyrefly: ignore [bad-argument-type] weights = mask if weights is None else mask * weights.type_as(Xt) # compute the centroids of the point sets - # pyrefly: ignore [bad-argument-type] Xmu = oputil.wmean(Xt, weight=weights, eps=eps) - # pyrefly: ignore [bad-argument-type] Ymu = oputil.wmean(Yt, weight=weights, eps=eps) # mean-center the point sets - # pyrefly: ignore [unsupported-operation] Xc = Xt - Xmu - # pyrefly: ignore [unsupported-operation] Yc = Yt - Ymu total_weight = torch.clamp(num_points, 1) diff --git a/pytorch3d/ops/points_normals.py b/pytorch3d/ops/points_normals.py index baa21c2c..f4d3b27c 100644 --- a/pytorch3d/ops/points_normals.py +++ b/pytorch3d/ops/points_normals.py @@ -119,7 +119,6 @@ def estimate_pointcloud_local_coord_frames( points_padded, num_points = convert_pointclouds_to_tensor(pointclouds) - # pyrefly: ignore [missing-attribute] ba, N, dim = points_padded.shape if dim != 3: raise ValueError( @@ -134,7 +133,6 @@ def estimate_pointcloud_local_coord_frames( # undo global mean for stability # TODO: replace with tutil.wmean once landed - # pyrefly: ignore [missing-attribute] pcl_mean = points_padded.sum(1) / num_points[:, None] points_centered = points_padded - pcl_mean[:, None, :] @@ -156,26 +154,17 @@ def estimate_pointcloud_local_coord_frames( if disambiguate_directions: # disambiguate normal n = _disambiguate_vector_directions( - # pyrefly: ignore [unsupported-operation] - points_centered, - knns, - # pyrefly: ignore [unsupported-operation] - local_coord_frames[:, :, :, 0], + points_centered, knns, local_coord_frames[:, :, :, 0] ) # disambiguate the main curvature z = _disambiguate_vector_directions( - # pyrefly: ignore [unsupported-operation] - points_centered, - knns, - # pyrefly: ignore [unsupported-operation] - local_coord_frames[:, :, :, 2], + points_centered, knns, local_coord_frames[:, :, :, 2] ) # the secondary curvature is just a cross between n and z y = torch.cross(n, z, dim=2) # cat to form the set of principal directions local_coord_frames = torch.stack((n, y, z), dim=3) - # pyrefly: ignore [bad-return] return curvatures, local_coord_frames diff --git a/pytorch3d/ops/points_to_volumes.py b/pytorch3d/ops/points_to_volumes.py index d099cea8..d9fd7700 100644 --- a/pytorch3d/ops/points_to_volumes.py +++ b/pytorch3d/ops/points_to_volumes.py @@ -141,7 +141,6 @@ class _points_to_volumes_function(Function): @staticmethod @once_differentiable - # pyrefly: ignore [bad-override] def backward(ctx, grad_volume_densities, grad_volume_features): splat = ctx.splat N, C = grad_volume_features.shape[:2] @@ -378,7 +377,6 @@ def add_points_features_to_volume_densities_features( if grid_sizes is None: # grid sizes shape (minibatch, 3) grid_sizes = ( - # pyrefly: ignore [bad-assignment] torch.LongTensor(list(volume_densities.shape[2:])) .to(volume_densities.device) .expand(volume_densities.shape[0], 3) diff --git a/pytorch3d/ops/sample_farthest_points.py b/pytorch3d/ops/sample_farthest_points.py index ddcb75ad..9742c7dc 100644 --- a/pytorch3d/ops/sample_farthest_points.py +++ b/pytorch3d/ops/sample_farthest_points.py @@ -141,7 +141,6 @@ def sample_farthest_points_naive( for n in range(N): # Initialize an array for the sampled indices, shape: (max_K,) - # pyrefly: ignore [no-matching-overload] sample_idx_batch = torch.full( # pyre-fixme[6]: For 1st param expected `Union[List[int], Size, # typing.Tuple[int, ...]]` but got `Tuple[Tensor]`. diff --git a/pytorch3d/ops/utils.py b/pytorch3d/ops/utils.py index 1c73ea97..29afc3f9 100644 --- a/pytorch3d/ops/utils.py +++ b/pytorch3d/ops/utils.py @@ -143,7 +143,6 @@ def convert_pointclouds_to_tensor(pcl: Union[torch.Tensor, "Pointclouds"]): elif torch.is_tensor(pcl): X = pcl num_points = X.shape[1] * torch.ones( # type: ignore - # pyrefly: ignore [missing-attribute] X.shape[0], device=X.device, dtype=torch.int64, diff --git a/pytorch3d/renderer/blending.py b/pytorch3d/renderer/blending.py index ba5793dc..b84b91ab 100644 --- a/pytorch3d/renderer/blending.py +++ b/pytorch3d/renderer/blending.py @@ -101,7 +101,6 @@ class _SigmoidAlphaBlend(torch.autograd.Function): return alphas @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_alphas): dists, pix_to_face, alphas = ctx.saved_tensors sigma = ctx.sigma @@ -213,10 +212,8 @@ def softmax_rgb_blend( # Reshape to be compatible with (N, H, W, K) values in fragments if torch.is_tensor(zfar): - # pyrefly: ignore [bad-index] zfar = zfar[:, None, None, None] if torch.is_tensor(znear): - # pyrefly: ignore [bad-index] znear = znear[:, None, None, None] # pyre-fixme[6]: Expected `float` but got `Union[float, Tensor]` diff --git a/pytorch3d/renderer/camera_conversions.py b/pytorch3d/renderer/camera_conversions.py index 6c5b2cbc..378bd5f3 100644 --- a/pytorch3d/renderer/camera_conversions.py +++ b/pytorch3d/renderer/camera_conversions.py @@ -86,7 +86,6 @@ def _opencv_from_cameras_projection( scale = scale.expand(-1, 2) c0 = image_size_wh / 2.0 - # pyrefly: ignore [unsupported-operation] principal_point = -p0_pytorch3d * scale + c0 focal_length = focal_pytorch3d * scale diff --git a/pytorch3d/renderer/camera_utils.py b/pytorch3d/renderer/camera_utils.py index 43211c99..e5656315 100644 --- a/pytorch3d/renderer/camera_utils.py +++ b/pytorch3d/renderer/camera_utils.py @@ -202,10 +202,8 @@ def join_cameras_as_batch(cameras_list: Sequence[CamerasBase]) -> CamerasBase: # In the init, all inputs will be converted to # batched tensors before set as attributes # Join as a tensor along the batch dimension - # pyrefly: ignore [unsupported-operation] kwargs[field] = torch.cat(attrs_list, dim=0) else: raise ValueError(f"Field {field} type is not supported for batching") - # pyrefly: ignore [bad-argument-type] return c0.__class__(**kwargs) diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index c2505324..0b7653df 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -362,7 +362,6 @@ class CamerasBase(TensorProperties): self, with_xyflip=with_xyflip, image_size=image_size ).transform_points(points_ndc, eps=eps) - # pyrefly: ignore [bad-override] def clone(self): """ Returns a copy of `self`. @@ -391,7 +390,6 @@ class CamerasBase(TensorProperties): """ return getattr(self, "image_size", None) - # pyrefly: ignore [bad-override] def __getitem__( self, index: Union[int, List[int], torch.BoolTensor, torch.LongTensor] ) -> "CamerasBase": @@ -457,14 +455,11 @@ class CamerasBase(TensorProperties): elif isinstance(val, torch.Tensor): # In the init, all inputs will be converted to # tensors before setting as attributes - # pyrefly: ignore [unsupported-operation] kwargs[field] = val[index] else: raise ValueError(f"Field {field} type is not supported for indexing") - # pyrefly: ignore [unsupported-operation] kwargs["device"] = self.device - # pyrefly: ignore [bad-argument-type] return self.__class__(**kwargs) @@ -1746,14 +1741,7 @@ def look_at_view_transform( dist, elev, azim, at, up = broadcasted_args C = ( camera_position_from_spherical_angles( - # pyrefly: ignore [bad-argument-type] - dist, - # pyrefly: ignore [bad-argument-type] - elev, - # pyrefly: ignore [bad-argument-type] - azim, - degrees=degrees, - device=device, + dist, elev, azim, degrees=degrees, device=device ) + at ) @@ -1799,7 +1787,6 @@ def get_ndc_to_screen_transform( K = torch.zeros((cameras._N, 4, 4), device=cameras.device, dtype=torch.float32) if not torch.is_tensor(image_size): image_size = torch.tensor(image_size, device=cameras.device) - # pyrefly: ignore [missing-attribute] image_size = image_size.view(-1, 2) # of shape (1 or B)x2 height, width = image_size.unbind(1) diff --git a/pytorch3d/renderer/compositing.py b/pytorch3d/renderer/compositing.py index d8676352..507f3f90 100644 --- a/pytorch3d/renderer/compositing.py +++ b/pytorch3d/renderer/compositing.py @@ -51,7 +51,6 @@ class _CompositeAlphaPoints(torch.autograd.Function): return pt_cld @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_features = None grad_alphas = None @@ -131,7 +130,6 @@ class _CompositeNormWeightedSumPoints(torch.autograd.Function): return pt_cld @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_features = None grad_alphas = None @@ -210,7 +208,6 @@ class _CompositeWeightedSumPoints(torch.autograd.Function): return pt_cld @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_output): grad_features = None grad_alphas = None diff --git a/pytorch3d/renderer/fisheyecameras.py b/pytorch3d/renderer/fisheyecameras.py index 551e94de..cf5261b7 100644 --- a/pytorch3d/renderer/fisheyecameras.py +++ b/pytorch3d/renderer/fisheyecameras.py @@ -124,7 +124,6 @@ class FishEyeCameras(CamerasBase): else: self.image_size = None - # pyrefly: ignore [bad-assignment] self.device = device self.focal = focal_length.to(self.device) self.principal_point = principal_point.to(self.device) diff --git a/pytorch3d/renderer/implicit/harmonic_embedding.py b/pytorch3d/renderer/implicit/harmonic_embedding.py index ee44f237..c3b1e944 100644 --- a/pytorch3d/renderer/implicit/harmonic_embedding.py +++ b/pytorch3d/renderer/implicit/harmonic_embedding.py @@ -136,16 +136,13 @@ class HarmonicEmbedding(torch.nn.Module): [..., (n_harmonic_functions * 2 + int(append_input)) * num_points_per_ray] """ # [..., dim, n_harmonic_functions] - # pyrefly: ignore [unsupported-operation] embed = x[..., None] * self._frequencies # [..., 1, dim, n_harmonic_functions] + [2, 1, 1] => [..., 2, dim, n_harmonic_functions] - # pyrefly: ignore [bad-index] embed = embed[..., None, :, :] + self._zero_half_pi[..., None, None] # Use the trig identity cos(x) = sin(x + pi/2) # and do one vectorized call to sin([x, x+pi/2]) instead of (sin(x), cos(x)). embed = embed.sin() if diag_cov is not None: - # pyrefly: ignore [no-matching-overload] x_var = diag_cov[..., None] * torch.pow(self._frequencies, 2) exp_var = torch.exp(-0.5 * x_var) # [..., 2, dim, n_harmonic_functions] @@ -183,9 +180,5 @@ class HarmonicEmbedding(torch.nn.Module): so the input might be xyz. """ return self.get_output_dim_static( - # pyrefly: ignore [bad-argument-type] - input_dims, - # pyrefly: ignore [bad-argument-type] - len(self._frequencies), - self.append_input, + input_dims, len(self._frequencies), self.append_input ) diff --git a/pytorch3d/renderer/implicit/raymarching.py b/pytorch3d/renderer/implicit/raymarching.py index b8aef474..60eae7b7 100644 --- a/pytorch3d/renderer/implicit/raymarching.py +++ b/pytorch3d/renderer/implicit/raymarching.py @@ -226,7 +226,6 @@ def _check_raymarcher_inputs( if not z_can_be_none and rays_z.shape != rays_shape: raise ValueError("rays_z have to be of the same shape as rays_densities.") - # pyrefly: ignore [missing-attribute] if not features_can_be_none and rays_features.shape[:-1] != rays_shape: raise ValueError( "The first to previous to last dimensions of rays_features" diff --git a/pytorch3d/renderer/implicit/raysampling.py b/pytorch3d/renderer/implicit/raysampling.py index 222e0249..09decba8 100644 --- a/pytorch3d/renderer/implicit/raysampling.py +++ b/pytorch3d/renderer/implicit/raysampling.py @@ -197,7 +197,6 @@ class MultinomialRaysampler(torch.nn.Module): "`n_rays_total` and `n_rays_per_image` cannot both be defined." ) if n_rays_total: - # pyrefly: ignore [bad-assignment] ( cameras, mask, @@ -222,7 +221,6 @@ class MultinomialRaysampler(torch.nn.Module): if mask is not None and n_rays_per_image is None: # if num rays not given, sample according to the smallest mask n_rays_per_image = ( - # pyrefly: ignore [bad-assignment] n_rays_per_image or mask.sum(dim=(1, 2)).min().int().item() ) @@ -455,7 +453,6 @@ class MonteCarloRaysampler(torch.nn.Module): # of shape (batch_size, n_rays_per_image, 2) rays_xy = torch.cat( [ - # pyrefly: ignore [no-matching-overload] torch.rand( size=(batch_size, n_rays_per_image, 1), dtype=torch.float32, diff --git a/pytorch3d/renderer/lighting.py b/pytorch3d/renderer/lighting.py index 38c487c6..7e019462 100644 --- a/pytorch3d/renderer/lighting.py +++ b/pytorch3d/renderer/lighting.py @@ -190,12 +190,10 @@ class DirectionalLights(TensorProperties): direction=direction, ) _validate_light_properties(self) - # pyrefly: ignore [bad-index] if self.direction.shape[-1] != 3: msg = "Expected direction to have shape (N, 3); got %r" raise ValueError(msg % repr(self.direction.shape)) - # pyrefly: ignore [bad-override] def clone(self): other = self.__class__(device=self.device) return super().clone(other) @@ -253,12 +251,10 @@ class PointLights(TensorProperties): location=location, ) _validate_light_properties(self) - # pyrefly: ignore [bad-index] if self.location.shape[-1] != 3: msg = "Expected location to have shape (N, 3); got %r" raise ValueError(msg % repr(self.location.shape)) - # pyrefly: ignore [bad-override] def clone(self): other = self.__class__(device=self.device) return super().clone(other) @@ -323,7 +319,6 @@ class AmbientLights(TensorProperties): ambient_color = ((1.0, 1.0, 1.0),) super().__init__(ambient_color=ambient_color, device=device) - # pyrefly: ignore [bad-override] def clone(self): other = self.__class__(device=self.device) return super().clone(other) @@ -335,9 +330,7 @@ class AmbientLights(TensorProperties): return self._zeros_channels(points) def _zeros_channels(self, points: torch.Tensor) -> torch.Tensor: - # pyrefly: ignore [bad-index] ch = self.ambient_color.shape[-1] - # pyrefly: ignore [no-matching-overload] return torch.zeros(*points.shape[:-1], ch, device=points.device) diff --git a/pytorch3d/renderer/materials.py b/pytorch3d/renderer/materials.py index 7b9ebb25..be85b8ab 100644 --- a/pytorch3d/renderer/materials.py +++ b/pytorch3d/renderer/materials.py @@ -52,7 +52,6 @@ class Materials(TensorProperties): specular_color=specular_color, shininess=shininess, ) - # pyrefly: ignore [bad-index] C = self.ambient_color.shape[-1] for n in ["ambient_color", "diffuse_color", "specular_color"]: t = getattr(self, n) @@ -63,7 +62,6 @@ class Materials(TensorProperties): msg = "shininess should have shape (N); got %r" raise ValueError(msg % repr(self.shininess.shape)) - # pyrefly: ignore [bad-override] def clone(self): other = Materials(device=self.device) return super().clone(other) diff --git a/pytorch3d/renderer/mesh/clip.py b/pytorch3d/renderer/mesh/clip.py index 27b23b0f..b10bd4fa 100644 --- a/pytorch3d/renderer/mesh/clip.py +++ b/pytorch3d/renderer/mesh/clip.py @@ -496,12 +496,7 @@ def clip_faces( # Solve for the points p4, p5 that intersect the clipping plane p, p_barycentric = _find_verts_intersecting_clipping_plane( - # pyrefly: ignore [bad-argument-type] - faces_case3, - p1_face_ind, - # pyrefly: ignore [bad-argument-type] - z_clip_value, - perspective_correct, + faces_case3, p1_face_ind, z_clip_value, perspective_correct ) p1, _, _, p4, p5 = p @@ -545,12 +540,7 @@ def clip_faces( # Solve for the points p4, p5 that intersect the clipping plane p, p_barycentric = _find_verts_intersecting_clipping_plane( - # pyrefly: ignore [bad-argument-type] - faces_case4, - p1_face_ind, - # pyrefly: ignore [bad-argument-type] - z_clip_value, - perspective_correct, + faces_case4, p1_face_ind, z_clip_value, perspective_correct ) _, p2, p3, p4, p5 = p _, p2_barycentric, p3_barycentric, p4_barycentric, p5_barycentric = p_barycentric @@ -692,7 +682,6 @@ def convert_clipped_rasterization_to_original_faces( # rasterized pixel. pix_to_conversion_idx = torch.where( pix_to_face_clipped != -1, - # pyrefly: ignore [unsupported-operation] faces_clipped_to_conversion_idx[pix_to_face_clipped], empty, ) @@ -720,7 +709,6 @@ def convert_clipped_rasterization_to_original_faces( bary_coords_clipped_subset ) - # pyrefly: ignore [no-matching-overload] bary_coords_unclipped_subset = bary_coords_unclipped_subset.reshape([N * 3]) bary_coords_unclipped[faces_to_convert_mask_expanded] = ( bary_coords_unclipped_subset diff --git a/pytorch3d/renderer/mesh/rasterize_meshes.py b/pytorch3d/renderer/mesh/rasterize_meshes.py index c2f7b34f..10bb591f 100644 --- a/pytorch3d/renderer/mesh/rasterize_meshes.py +++ b/pytorch3d/renderer/mesh/rasterize_meshes.py @@ -316,7 +316,6 @@ class _RasterizeFaceVerts(torch.autograd.Function): return pix_to_face, zbuf, barycentric_coords, dists @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_pix_to_face, grad_zbuf, grad_barycentric_coords, grad_dists): grad_face_verts = None grad_mesh_to_face_first_idx = None diff --git a/pytorch3d/renderer/mesh/rasterizer.py b/pytorch3d/renderer/mesh/rasterizer.py index bad4e070..0e5c9f4d 100644 --- a/pytorch3d/renderer/mesh/rasterizer.py +++ b/pytorch3d/renderer/mesh/rasterizer.py @@ -161,7 +161,6 @@ class MeshRasterizer(nn.Module): self.cameras = cameras self.raster_settings = raster_settings - # pyrefly: ignore [bad-override] def to(self, device): # Manually move to device cameras as it is not a subclass of nn.Module if self.cameras is not None: @@ -239,12 +238,10 @@ class MeshRasterizer(nn.Module): if raster_settings.perspective_correct is not None: perspective_correct = raster_settings.perspective_correct else: - # pyrefly: ignore [missing-attribute] perspective_correct = cameras.is_perspective() if raster_settings.z_clip_value is not None: z_clip = raster_settings.z_clip_value else: - # pyrefly: ignore [missing-attribute] znear = cameras.get_znear() if isinstance(znear, torch.Tensor): znear = znear.min().item() diff --git a/pytorch3d/renderer/mesh/renderer.py b/pytorch3d/renderer/mesh/renderer.py index dd8ca80d..5b623243 100644 --- a/pytorch3d/renderer/mesh/renderer.py +++ b/pytorch3d/renderer/mesh/renderer.py @@ -41,7 +41,6 @@ class MeshRenderer(nn.Module): self.rasterizer = rasterizer self.shader = shader - # pyrefly: ignore [bad-override] def to(self, device): # Rasterizer and shader have submodules which are not of type nn.Module self.rasterizer.to(device) @@ -86,7 +85,6 @@ class MeshRendererWithFragments(nn.Module): self.rasterizer = rasterizer self.shader = shader - # pyrefly: ignore [bad-override] def to(self, device): # Rasterizer and shader have submodules which are not of type nn.Module self.rasterizer.to(device) diff --git a/pytorch3d/renderer/mesh/shader.py b/pytorch3d/renderer/mesh/shader.py index e751389a..77aeba91 100644 --- a/pytorch3d/renderer/mesh/shader.py +++ b/pytorch3d/renderer/mesh/shader.py @@ -72,7 +72,6 @@ class ShaderBase(nn.Module): cameras = self.cameras if cameras is not None: self.cameras = cameras.to(device) - # pyrefly: ignore [bad-assignment] self.materials = self.materials.to(device) self.lights = self.lights.to(device) return self diff --git a/pytorch3d/renderer/mesh/textures.py b/pytorch3d/renderer/mesh/textures.py index c28a9dc0..cf2a59e6 100644 --- a/pytorch3d/renderer/mesh/textures.py +++ b/pytorch3d/renderer/mesh/textures.py @@ -261,7 +261,6 @@ class TexturesBase: f"Property {p} has unsupported type {type(t)}." "Only tensors and lists are supported." ) - # pyrefly: ignore [bad-return] return new_props def _getitem(self, index: Union[int, slice], props: List[str]): @@ -276,7 +275,6 @@ class TexturesBase: t = t() # class method new_props[p] = t[index] if t is not None else None elif isinstance(index, list): - # pyrefly: ignore [bad-assignment] index = torch.tensor(index) if isinstance(index, torch.Tensor): if index.dtype == torch.bool: @@ -453,7 +451,6 @@ class TexturesAtlas(TexturesBase): msg = "Expected atlas to be of shape (N, F, R, R, C); got %r" raise ValueError(msg % repr(atlas.ndim)) self._atlas_padded = atlas - # pyrefly: ignore [bad-assignment] self._atlas_list = None self.device = atlas.device @@ -477,7 +474,6 @@ class TexturesAtlas(TexturesBase): if self._atlas_list is not None: tex._atlas_list = [atlas.clone() for atlas in self._atlas_list] num_faces = ( - # pyrefly: ignore [missing-attribute] self._num_faces_per_mesh.clone() if torch.is_tensor(self._num_faces_per_mesh) else self._num_faces_per_mesh @@ -491,7 +487,6 @@ class TexturesAtlas(TexturesBase): if self._atlas_list is not None: tex._atlas_list = [atlas.detach() for atlas in self._atlas_list] num_faces = ( - # pyrefly: ignore [missing-attribute] self._num_faces_per_mesh.detach() if torch.is_tensor(self._num_faces_per_mesh) else self._num_faces_per_mesh @@ -509,11 +504,9 @@ class TexturesAtlas(TexturesBase): new_tex = self.__class__(atlas=atlas) elif torch.is_tensor(atlas): # single element - # pyrefly: ignore [bad-argument-type] new_tex = self.__class__(atlas=[atlas]) else: raise ValueError("Not all values are provided in the correct format") - # pyrefly: ignore [bad-assignment] new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"] return new_tex @@ -535,7 +528,6 @@ class TexturesAtlas(TexturesBase): self._atlas_padded = [ torch.empty((0, 0, 0, 3), dtype=torch.float32, device=self.device) ] * self._N - # pyrefly: ignore [bad-assignment] self._atlas_list = _padded_to_list_wrapper( self._atlas_padded, split_size=self._num_faces_per_mesh ) @@ -552,7 +544,6 @@ class TexturesAtlas(TexturesBase): def extend(self, N: int) -> "TexturesAtlas": new_props = self._extend(N, ["atlas_padded", "_num_faces_per_mesh"]) new_tex = self.__class__(atlas=new_props["atlas_padded"]) - # pyrefly: ignore [bad-assignment] new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"] return new_tex @@ -799,7 +790,6 @@ class TexturesUV(TexturesBase): msg = "Expected faces_uvs to be of shape (N, F, 3); got %r" raise ValueError(msg % repr(faces_uvs.shape)) self._faces_uvs_padded = faces_uvs - # pyrefly: ignore [bad-assignment] self._faces_uvs_list = None self.device = faces_uvs.device @@ -836,7 +826,6 @@ class TexturesUV(TexturesBase): msg = "Expected verts_uvs to be of shape (N, V, 2); got %r" raise ValueError(msg % repr(verts_uvs.shape)) self._verts_uvs_padded = verts_uvs - # pyrefly: ignore [bad-assignment] self._verts_uvs_list = None if verts_uvs.device != self.device: @@ -849,7 +838,6 @@ class TexturesUV(TexturesBase): if isinstance(maps, (list, tuple)): self._maps_list = maps else: - # pyrefly: ignore [bad-assignment] self._maps_list = None self._maps_padded = self._format_maps_padded(maps) @@ -978,7 +966,6 @@ class TexturesUV(TexturesBase): if self._maps_ids_list is not None: tex._maps_ids_list = [f.clone() for f in self._maps_ids_list] num_faces = ( - # pyrefly: ignore [missing-attribute] self._num_faces_per_mesh.clone() if torch.is_tensor(self._num_faces_per_mesh) else self._num_faces_per_mesh @@ -1010,7 +997,6 @@ class TexturesUV(TexturesBase): if self._maps_ids_list is not None: tex._maps_ids_list = [mi.detach() for mi in self._maps_ids_list] num_faces = ( - # pyrefly: ignore [missing-attribute] self._num_faces_per_mesh.detach() if torch.is_tensor(self._num_faces_per_mesh) else self._num_faces_per_mesh @@ -1040,11 +1026,8 @@ class TexturesUV(TexturesBase): "Maps ids are not in the correct format expected list or tuple" ) new_tex = self.__class__( - # pyrefly: ignore [bad-argument-type] faces_uvs=faces_uvs, - # pyrefly: ignore [bad-argument-type] verts_uvs=verts_uvs, - # pyrefly: ignore [bad-argument-type] maps=maps, maps_ids=maps_ids, padding_mode=self.padding_mode, @@ -1057,11 +1040,8 @@ class TexturesUV(TexturesBase): "Maps ids are not in the correct format expected tensor" ) new_tex = self.__class__( - # pyrefly: ignore [bad-argument-type] faces_uvs=[faces_uvs], - # pyrefly: ignore [bad-argument-type] verts_uvs=[verts_uvs], - # pyrefly: ignore [bad-argument-type] maps=[maps], maps_ids=[maps_ids] if maps_ids is not None else None, padding_mode=self.padding_mode, @@ -1070,7 +1050,6 @@ class TexturesUV(TexturesBase): ) else: raise ValueError("Not all values are provided in the correct format") - # pyrefly: ignore [bad-assignment] new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"] return new_tex @@ -1093,11 +1072,9 @@ class TexturesUV(TexturesBase): torch.empty((0, 3), dtype=torch.float32, device=self.device) ] * self._N else: - # pyrefly: ignore [bad-assignment] self._faces_uvs_list = padded_to_list( self._faces_uvs_padded, split_size=self._num_faces_per_mesh ) - # pyrefly: ignore [bad-return] return self._faces_uvs_list def verts_uvs_padded(self) -> torch.Tensor: @@ -1122,9 +1099,7 @@ class TexturesUV(TexturesBase): # The number of vertices in the mesh and in verts_uvs can differ # e.g. if a vertex is shared between 3 faces, it can # have up to 3 different uv coordinates. - # pyrefly: ignore [bad-assignment] self._verts_uvs_list = list(self._verts_uvs_padded.unbind(0)) - # pyrefly: ignore [bad-return] return self._verts_uvs_list def maps_ids_padded(self) -> Optional[torch.Tensor]: @@ -1132,10 +1107,8 @@ class TexturesUV(TexturesBase): def maps_ids_list(self) -> Optional[List[torch.Tensor]]: if self._maps_ids_list is not None: - # pyrefly: ignore [bad-return] return self._maps_ids_list elif self._maps_ids_padded is not None: - # pyrefly: ignore [bad-return] return self._maps_ids_padded.unbind(0) else: return None @@ -1170,7 +1143,6 @@ class TexturesUV(TexturesBase): sampling_mode=self.sampling_mode, ) - # pyrefly: ignore [bad-assignment] new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"] return new_tex @@ -1744,7 +1716,6 @@ class TexturesVertex(TexturesBase): msg = "Expected verts_features to be of shape (N, V, C); got %r" raise ValueError(msg % repr(verts_features.shape)) self._verts_features_padded = verts_features - # pyrefly: ignore [bad-assignment] self._verts_features_list = None self.device = verts_features.device @@ -1792,11 +1763,9 @@ class TexturesVertex(TexturesBase): ) new_tex = self.__class__(verts_features=verts_features) elif torch.is_tensor(verts_features): - # pyrefly: ignore [bad-argument-type] new_tex = self.__class__(verts_features=[verts_features]) else: raise ValueError("Not all values are provided in the correct format") - # pyrefly: ignore [bad-assignment] new_tex._num_verts_per_mesh = new_props["_num_verts_per_mesh"] return new_tex @@ -1819,11 +1788,9 @@ class TexturesVertex(TexturesBase): torch.empty((0, 3), dtype=torch.float32, device=self.device) ] * self._N else: - # pyrefly: ignore [bad-assignment] self._verts_features_list = padded_to_list( self._verts_features_padded, split_size=self._num_verts_per_mesh ) - # pyrefly: ignore [bad-return] return self._verts_features_list def verts_features_packed(self) -> torch.Tensor: @@ -1835,7 +1802,6 @@ class TexturesVertex(TexturesBase): def extend(self, N: int) -> "TexturesVertex": new_props = self._extend(N, ["verts_features_padded", "_num_verts_per_mesh"]) new_tex = self.__class__(verts_features=new_props["verts_features_padded"]) - # pyrefly: ignore [bad-assignment] new_tex._num_verts_per_mesh = new_props["_num_verts_per_mesh"] return new_tex diff --git a/pytorch3d/renderer/opengl/opengl_utils.py b/pytorch3d/renderer/opengl/opengl_utils.py index e8185b05..a359d838 100755 --- a/pytorch3d/renderer/opengl/opengl_utils.py +++ b/pytorch3d/renderer/opengl/opengl_utils.py @@ -114,7 +114,6 @@ def _get_cuda_device(requested_device_id: int): # Iterate over all the EGL devices, and check if their CUDA ID matches the request. for device in devices: - # pyrefly: ignore [bad-argument-type] available_device_id = egl.EGLAttrib(ctypes.c_int(-1)) # pyre-ignore Undefined attribute [16] egl.eglQueryDeviceAttribEXT(device, EGL_CUDA_DEVICE_NV, available_device_id) diff --git a/pytorch3d/renderer/opengl/rasterizer_opengl.py b/pytorch3d/renderer/opengl/rasterizer_opengl.py index 0d7ad9a4..595d0dcf 100644 --- a/pytorch3d/renderer/opengl/rasterizer_opengl.py +++ b/pytorch3d/renderer/opengl/rasterizer_opengl.py @@ -213,7 +213,6 @@ class MeshRasterizerOpenGL(nn.Module): dists=None, ).detach() - # pyrefly: ignore [bad-override] def to(self, device): # Manually move to device cameras as it is not a subclass of nn.Module if self.cameras is not None: @@ -277,7 +276,6 @@ class _OpenGLMachinery: """ self.initialize_device_data(meshes_gl_ndc.device) - # pyrefly: ignore [missing-attribute] with self.egl_context.active_and_locked(): # Perspective projection happens in OpenGL. Move the matrix over if there's only # a single camera shared by all the meshes. @@ -372,15 +370,11 @@ class _OpenGLMachinery: """ # Finish all current operations. torch.cuda.synchronize() - # pyrefly: ignore [missing-attribute] self.cuda_context.synchronize() # Free pycuda resources. - # pyrefly: ignore [missing-attribute] self.cuda_context.push() - # pyrefly: ignore [missing-attribute] self.cuda_buffer.unregister() - # pyrefly: ignore [missing-attribute] self.cuda_context.pop() # Free GL resources. @@ -397,7 +391,6 @@ class _OpenGLMachinery: del self.mesh_buffer_object gl.glDeleteProgram(self.program) - # pyrefly: ignore [missing-attribute] self.egl_context.release() def _projection_matrix_to_opengl(self, projection_matrix: torch.Tensor) -> None: diff --git a/pytorch3d/renderer/points/pulsar/renderer.py b/pytorch3d/renderer/points/pulsar/renderer.py index 9ad1e5e8..96c8566b 100644 --- a/pytorch3d/renderer/points/pulsar/renderer.py +++ b/pytorch3d/renderer/points/pulsar/renderer.py @@ -171,7 +171,6 @@ class _Render(torch.autograd.Function): return image @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_im, *args): global GAMMA_WARNING_EMITTED ( diff --git a/pytorch3d/renderer/points/pulsar/unified.py b/pytorch3d/renderer/points/pulsar/unified.py index cb95ca61..13664d4d 100644 --- a/pytorch3d/renderer/points/pulsar/unified.py +++ b/pytorch3d/renderer/points/pulsar/unified.py @@ -121,9 +121,7 @@ class PulsarPointsRenderer(nn.Module): "gamma is a required keyword argument for the PulsarPointsRenderer!" ) if ( - # pyrefly: ignore [bad-argument-type] len(point_clouds) != len(self.rasterizer.cameras) - # pyrefly: ignore [bad-argument-type] and len(self.rasterizer.cameras) != 1 ): raise ValueError( @@ -134,7 +132,6 @@ class PulsarPointsRenderer(nn.Module): ) % ( len(point_clouds), - # pyrefly: ignore [bad-argument-type] len(self.rasterizer.cameras), ) ) @@ -144,7 +141,6 @@ class PulsarPointsRenderer(nn.Module): self.rasterizer.cameras, (FoVOrthographicCameras, OrthographicCameras) ) if orthogonal_projection != self.renderer._renderer.orthogonal: - # pyrefly: ignore [unsupported-operation] raise ValueError( "The camera type can not be changed after renderer initialization! " "Current camera orthogonal: %r. Original orthogonal: %r." @@ -223,7 +219,6 @@ class PulsarPointsRenderer(nn.Module): ) else: # Currently, this means it must be an 'OrthographicCameras' object. - # pyrefly: ignore [missing-attribute] focal_length_conf = kwargs.get("focal_length", cameras.focal_length)[ cloud_idx ] @@ -254,13 +249,11 @@ class PulsarPointsRenderer(nn.Module): znear = kwargs["znear"][cloud_idx] zfar = kwargs["zfar"][cloud_idx] principal_point_x = ( - # pyrefly: ignore [missing-attribute] kwargs.get("principal_point", cameras.principal_point)[cloud_idx][0] * 0.5 * self.renderer._renderer.width ) principal_point_y = ( - # pyrefly: ignore [missing-attribute] kwargs.get("principal_point", cameras.principal_point)[cloud_idx][1] * 0.5 * self.renderer._renderer.height @@ -268,26 +261,20 @@ class PulsarPointsRenderer(nn.Module): else: if not isinstance(cameras, PerspectiveCameras): # Create a virtual focal length that is closer than znear. - # pyrefly: ignore [missing-attribute] znear = kwargs.get("znear", cameras.znear)[cloud_idx] - # pyrefly: ignore [missing-attribute] zfar = kwargs.get("zfar", cameras.zfar)[cloud_idx] focal_length = znear - 1e-6 # Create a sensor size that matches the expected fov assuming this f. - # pyrefly: ignore [missing-attribute] afov = kwargs.get("fov", cameras.fov)[cloud_idx] - # pyrefly: ignore [missing-attribute] if kwargs.get("degrees", cameras.degrees): afov *= math.pi / 180.0 sensor_width = math.tan(afov / 2.0) * 2.0 * focal_length if not ( - # pyrefly: ignore [missing-attribute] kwargs.get("aspect_ratio", cameras.aspect_ratio)[cloud_idx] - self.renderer._renderer.width / self.renderer._renderer.height < 1e-6 ): raise ValueError( - # pyrefly: ignore [missing-attribute] "The aspect ratio (" f"{kwargs.get('aspect_ratio', cameras.aspect_ratio)[cloud_idx]}) " "must agree with the resolution width / height (" @@ -374,9 +361,7 @@ class PulsarPointsRenderer(nn.Module): """ # Shorthand: cameras = self.rasterizer.cameras - # pyrefly: ignore [missing-attribute] R = kwargs.get("R", cameras.R)[cloud_idx] - # pyrefly: ignore [missing-attribute] T = kwargs.get("T", cameras.T)[cloud_idx] tmp_cams = PerspectiveCameras( R=R.unsqueeze(0), T=T.unsqueeze(0), device=R.device @@ -403,7 +388,6 @@ class PulsarPointsRenderer(nn.Module): # or itself a tensor. raster_rad = self.rasterizer.raster_settings.radius if kwargs.get("radius_world", False): - # pyrefly: ignore [bad-return] return raster_rad if ( isinstance(raster_rad, torch.Tensor) diff --git a/pytorch3d/renderer/points/rasterize_points.py b/pytorch3d/renderer/points/rasterize_points.py index b9f853ca..d7675bc0 100644 --- a/pytorch3d/renderer/points/rasterize_points.py +++ b/pytorch3d/renderer/points/rasterize_points.py @@ -216,7 +216,6 @@ class _RasterizePoints(torch.autograd.Function): return idx, zbuf, dists @staticmethod - # pyrefly: ignore [bad-override] def backward(ctx, grad_idx, grad_zbuf, grad_dists): grad_points = None grad_cloud_to_packed_first_idx = None diff --git a/pytorch3d/renderer/points/rasterizer.py b/pytorch3d/renderer/points/rasterizer.py index 73363cb1..8c141b90 100644 --- a/pytorch3d/renderer/points/rasterizer.py +++ b/pytorch3d/renderer/points/rasterizer.py @@ -143,7 +143,6 @@ class PointsRasterizer(nn.Module): point_clouds = point_clouds.update_padded(pts_ndc) return point_clouds - # pyrefly: ignore [bad-override] def to(self, device): # Manually move to device cameras as it is not a subclass of nn.Module if self.cameras is not None: diff --git a/pytorch3d/renderer/points/renderer.py b/pytorch3d/renderer/points/renderer.py index 9be832d4..4ce53605 100644 --- a/pytorch3d/renderer/points/renderer.py +++ b/pytorch3d/renderer/points/renderer.py @@ -45,7 +45,6 @@ class PointsRenderer(nn.Module): self.rasterizer = rasterizer self.compositor = compositor - # pyrefly: ignore [bad-override] def to(self, device): # Manually move to device rasterizer as the cameras # within the class are not of type nn.Module diff --git a/pytorch3d/renderer/splatter_blend.py b/pytorch3d/renderer/splatter_blend.py index 936944b7..e396f979 100644 --- a/pytorch3d/renderer/splatter_blend.py +++ b/pytorch3d/renderer/splatter_blend.py @@ -464,7 +464,6 @@ class SplatterBlender(torch.nn.Module): input_shape, device ) - # pyrefly: ignore [bad-override] def to(self, device): self.offsets = self.offsets.to(device) self.crop_ids_h = self.crop_ids_h.to(device) diff --git a/pytorch3d/renderer/utils.py b/pytorch3d/renderer/utils.py index 260e554f..3d18be6b 100644 --- a/pytorch3d/renderer/utils.py +++ b/pytorch3d/renderer/utils.py @@ -67,15 +67,12 @@ class TensorAccessor(nn.Module): if ( v.dim() == 0 and isinstance(self.index, slice) - # pyrefly: ignore [bad-argument-type] and len(value) != len(self.index) ): msg = "Expected value to have len %r; got %r" - # pyrefly: ignore [bad-argument-type] raise ValueError(msg % (len(self.index), len(value))) self.class_object.__dict__[name][self.index] = value - # pyrefly: ignore [bad-override] def __getattr__(self, name: str): """ Return the value of the attribute given by "name" on self.class_object @@ -88,7 +85,6 @@ class TensorAccessor(nn.Module): return self.class_object.__dict__[name][self.index] else: msg = "Attribute %s not found on %r" - # pyrefly: ignore [missing-attribute] return AttributeError(msg % (name, self.class_object.__name__)) @@ -460,5 +456,4 @@ def parse_image_size( raise ValueError("Image sizes must be greater than 0; got %d, %d" % image_size) if not all(isinstance(i, int) for i in image_size): raise ValueError("Image sizes must be integers; got %f, %f" % image_size) - # pyrefly: ignore [bad-return] return tuple(image_size) diff --git a/pytorch3d/structures/meshes.py b/pytorch3d/structures/meshes.py index 962305ed..03b0a0a1 100644 --- a/pytorch3d/structures/meshes.py +++ b/pytorch3d/structures/meshes.py @@ -432,17 +432,13 @@ class Meshes: # Set the num verts/faces on the textures if present. if textures is not None: - # pyrefly: ignore [missing-attribute] shape_ok = self.textures.check_shapes(self._N, self._V, self._F) if not shape_ok: msg = "Textures do not match the dimensions of Meshes." raise ValueError(msg) - # pyrefly: ignore [missing-attribute] self.textures._num_faces_per_mesh = self._num_faces_per_mesh.tolist() - # pyrefly: ignore [missing-attribute] self.textures._num_verts_per_mesh = self._num_verts_per_mesh.tolist() - # pyrefly: ignore [missing-attribute] self.textures.valid = self.valid if verts_normals is not None: @@ -453,7 +449,6 @@ class Meshes: if len(verts_normals) != self._N: raise ValueError("Invalid verts_normals input") - # pyrefly: ignore [bad-argument-type] for item, n_verts in zip(verts_normals, self._num_verts_per_mesh): if ( not isinstance(item, torch.Tensor) @@ -471,10 +466,7 @@ class Meshes: ): raise ValueError("Vertex normals tensor has incorrect dimensions.") self._verts_normals_packed = struct_utils.padded_to_packed( - # pyrefly: ignore [missing-attribute] - verts_normals, - # pyrefly: ignore [missing-attribute] - split_size=self._num_verts_per_mesh.tolist(), + verts_normals, split_size=self._num_verts_per_mesh.tolist() ) else: raise ValueError("verts_normals must be a list or tensor") @@ -505,11 +497,8 @@ class Meshes: # NOTE consider converting index to cpu for efficiency if index.dtype == torch.bool: # advanced indexing on a single dimension - # pyrefly: ignore [bad-assignment] index = index.nonzero() - # pyrefly: ignore [missing-attribute] index = index.squeeze(1) if index.numel() > 0 else index - # pyrefly: ignore [missing-attribute] index = index.tolist() verts = [self.verts_list()[i] for i in index] faces = [self.faces_list()[i] for i in index] @@ -532,7 +521,6 @@ class Meshes: Returns: bool indicating whether there is any data. """ - # pyrefly: ignore [missing-attribute] return self._N == 0 or self.valid.eq(False).all() def verts_list(self): @@ -1070,7 +1058,6 @@ class Meshes: # All edges including duplicates. edges = torch.cat([e12, e20, e01], dim=0) # (sum(F_n)*3, 2) - # pyrefly: ignore [no-matching-overload] edge_to_mesh = torch.cat( [ self._faces_packed_to_mesh_idx, @@ -1095,7 +1082,6 @@ class Meshes: # unique_edges[inverse_idxs] == edges # i.e. inverse_idxs[i] == j means that edges[i] == unique_edges[j] - # pyrefly: ignore [missing-attribute] V = self._verts_packed.shape[0] edges_hash = V * edges[:, 0] + edges[:, 1] u, inverse_idxs = torch.unique(edges_hash, return_inverse=True) @@ -1713,7 +1699,6 @@ def join_meshes_as_batch(meshes: List[Meshes], include_textures: bool = True) -> if not tex_types_same: raise ValueError("All meshes in the batch must have the same type of texture.") - # pyrefly: ignore [missing-attribute] tex = first.join_batch(all_textures[1:]) return Meshes(verts=verts, faces=faces, textures=tex) diff --git a/pytorch3d/structures/pointclouds.py b/pytorch3d/structures/pointclouds.py index afc1cfc3..91f8d35a 100644 --- a/pytorch3d/structures/pointclouds.py +++ b/pytorch3d/structures/pointclouds.py @@ -319,7 +319,6 @@ class Pointclouds: if len(aux_input) != self._N: raise ValueError("Points and auxiliary input must be the same length.") - # pyrefly: ignore [bad-argument-type] for p, d in zip(self._num_points_per_cloud, aux_input): valid_but_empty = p == 0 and d is not None and d.ndim == 2 if p > 0 or valid_but_empty: @@ -351,7 +350,6 @@ class Pointclouds: if good_empty is None: good_empty = torch.zeros((0, aux_input_C), device=self.device) aux_input_out = [] - # pyrefly: ignore [bad-argument-type] for p, d in zip(self._num_points_per_cloud, aux_input): valid_but_empty = p == 0 and d is not None and d.ndim == 2 if p > 0 or valid_but_empty: @@ -405,11 +403,8 @@ class Pointclouds: # NOTE consider converting index to cpu for efficiency if index.dtype == torch.bool: # advanced indexing on a single dimension - # pyrefly: ignore [bad-assignment] index = index.nonzero() - # pyrefly: ignore [missing-attribute] index = index.squeeze(1) if index.numel() > 0 else index - # pyrefly: ignore [missing-attribute] index = index.tolist() points = [self.points_list()[i] for i in index] if normals_list is not None: @@ -428,7 +423,6 @@ class Pointclouds: Returns: bool indicating whether there is any data. """ - # pyrefly: ignore [missing-attribute] return self._N == 0 or self.valid.eq(False).all() def points_list(self) -> List[torch.Tensor]: @@ -492,7 +486,6 @@ class Pointclouds: tensor of points of shape (sum(P_n), 3). """ self._compute_packed() - # pyrefly: ignore [bad-return] return self._points_packed def normals_packed(self) -> Optional[torch.Tensor]: @@ -548,7 +541,6 @@ class Pointclouds: Returns: 1D tensor of sizes. """ - # pyrefly: ignore [bad-return] return self._num_points_per_cloud def points_padded(self) -> torch.Tensor: @@ -559,7 +551,6 @@ class Pointclouds: tensor of points of shape (N, max(P_n), 3). """ self._compute_padded() - # pyrefly: ignore [bad-return] return self._points_padded def normals_padded(self) -> Optional[torch.Tensor]: @@ -645,7 +636,6 @@ class Pointclouds: if features_list is not None: self._features_padded = struct_utils.list_to_padded( features_list, - # pyrefly: ignore [bad-argument-type] (self._P, self._C), pad_value=0.0, equisized=self.equisized, @@ -696,7 +686,6 @@ class Pointclouds: points_list_to_packed = struct_utils.list_to_packed(points_list) self._points_packed = points_list_to_packed[0] - # pyrefly: ignore [bad-argument-type] if not torch.allclose(self._num_points_per_cloud, points_list_to_packed[1]): raise ValueError("Inconsistent list to packed conversion") self._cloud_to_packed_first_idx = points_list_to_packed[2] @@ -1077,7 +1066,6 @@ class Pointclouds: self.normals_list() if self._points_packed is not None: # update self._normals_packed - # pyrefly: ignore [no-matching-overload] self._normals_packed = torch.cat(self._normals_list, dim=0) return normals_est diff --git a/pytorch3d/structures/volumes.py b/pytorch3d/structures/volumes.py index 84edf33d..8bf069b5 100644 --- a/pytorch3d/structures/volumes.py +++ b/pytorch3d/structures/volumes.py @@ -1010,7 +1010,6 @@ class VolumeLocator: Defaults to all items (`:`). """ device = device if device is not None else self.device - # pyrefly: ignore [bad-assignment] other._grid_sizes = self._grid_sizes[index].to(device) other._local_to_world_transform = self.get_local_to_world_coords_transform()[ # pyre-fixme[6]: For 1st param expected `Union[List[int], int, slice, @@ -1115,7 +1114,6 @@ class VolumeLocator: return other other.device = device_ - # pyrefly: ignore [bad-assignment] other._grid_sizes = self._grid_sizes.to(device_) other._local_to_world_transform = self.get_local_to_world_coords_transform().to( device diff --git a/pytorch3d/vis/plotly_vis.py b/pytorch3d/vis/plotly_vis.py index b81e2404..595a7b54 100644 --- a/pytorch3d/vis/plotly_vis.py +++ b/pytorch3d/vis/plotly_vis.py @@ -628,7 +628,6 @@ def _add_struct_from_batch( # pyre-ignore[16] struct = batched_struct[struct_idx] trace_name = "trace{}-{}".format(scene_num + 1, trace_idx) - # pyrefly: ignore [unsupported-operation] scene_dictionary[subplot_title][trace_name] = struct