mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-08-24 08:45:43 +08:00
Remove unused type error suppressions
Summary: This diff was automatically generated by the Pyre per-target upgrade tool. It removes `# pyre-fixme` or `pyrefly: ignore` comments that are no longer needed because the underlying type errors have been resolved. Note that it will also aim to ensure type checking runs cleanly, and will add suppressions to existing type errors. #pyreupgrade Differential Revision: D116557086 fbshipit-source-id: 1337613d4fb3ab79bd3a733f3a4c9a499a72f971
This commit is contained in:
committed by
meta-codesync[bot]
parent
2bce7110d5
commit
fdaf9bd6fe
@@ -117,16 +117,12 @@ class Experiment(Configurable):
|
||||
will be saved here.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `data_source` is never initialized.
|
||||
data_source: DataSourceBase
|
||||
data_source_class_type: str = "ImplicitronDataSource"
|
||||
# pyre-fixme[13]: Attribute `model_factory` is never initialized.
|
||||
model_factory: ModelFactoryBase
|
||||
model_factory_class_type: str = "ImplicitronModelFactory"
|
||||
# pyre-fixme[13]: Attribute `optimizer_factory` is never initialized.
|
||||
optimizer_factory: OptimizerFactoryBase
|
||||
optimizer_factory_class_type: str = "ImplicitronOptimizerFactory"
|
||||
# pyre-fixme[13]: Attribute `training_loop` is never initialized.
|
||||
training_loop: TrainingLoopBase
|
||||
training_loop_class_type: str = "ImplicitronTrainingLoop"
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ class ImplicitronModelFactory(ModelFactoryBase):
|
||||
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `model` is never initialized.
|
||||
model: ImplicitronModelBase
|
||||
model_class_type: str = "GenericModel"
|
||||
resume: bool = True
|
||||
|
||||
@@ -169,7 +169,6 @@ class ImplicitronOptimizerFactory(OptimizerFactoryBase):
|
||||
gamma=self.gamma,
|
||||
)
|
||||
elif self.lr_policy.casefold() == "Exponential".casefold():
|
||||
# pyre-fixme[28]: Unexpected keyword argument `verbose`.
|
||||
scheduler = torch.optim.lr_scheduler.LambdaLR(
|
||||
optimizer,
|
||||
lambda epoch: self.gamma ** (epoch / self.exponential_lr_step_size),
|
||||
@@ -190,9 +189,7 @@ class ImplicitronOptimizerFactory(OptimizerFactoryBase):
|
||||
gamma = self.gamma ** (epoch_rest / self.exponential_lr_step_size)
|
||||
return gamma
|
||||
|
||||
# pyre-fixme[28]: Unexpected keyword argument `verbose`.
|
||||
scheduler = torch.optim.lr_scheduler.LambdaLR(
|
||||
# pyrefly: ignore [unexpected-keyword]
|
||||
optimizer,
|
||||
_get_lr,
|
||||
# pyrefly: ignore [unexpected-keyword]
|
||||
|
||||
@@ -36,7 +36,6 @@ class TrainingLoopBase(ReplaceableBase):
|
||||
evaluator: An EvaluatorBase instance, used to evaluate training results.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `evaluator` is never initialized.
|
||||
evaluator: Optional[EvaluatorBase]
|
||||
evaluator_class_type: Optional[str] = "ImplicitronEvaluator"
|
||||
|
||||
@@ -380,7 +379,6 @@ class ImplicitronTrainingLoop(TrainingLoopBase):
|
||||
|
||||
# update the stats logger
|
||||
stats.update(preds, time_start=t_start, stat_set=trainmode)
|
||||
# pyre-ignore [16]
|
||||
assert stats.it[trainmode] == it, "inconsistent stat iteration number!"
|
||||
|
||||
# print textual status update
|
||||
|
||||
@@ -23,7 +23,6 @@ def meshgrid_ij(
|
||||
Like torch.meshgrid was before PyTorch 1.10.0, i.e. with indexing set to ij
|
||||
"""
|
||||
if (
|
||||
# pyre-fixme[16]: Callable `meshgrid` has no attribute `__kwdefaults__`.
|
||||
torch.meshgrid.__kwdefaults__ is not None
|
||||
and "indexing" in torch.meshgrid.__kwdefaults__
|
||||
):
|
||||
|
||||
@@ -52,11 +52,8 @@ class ImplicitronDataSource(DataSourceBase):
|
||||
data_loader_map_provider_class_type: identifies type for data_loader_map_provider.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `dataset_map_provider` is never initialized.
|
||||
dataset_map_provider: DatasetMapProviderBase
|
||||
# pyre-fixme[13]: Attribute `dataset_map_provider_class_type` is never initialized.
|
||||
dataset_map_provider_class_type: str
|
||||
# pyre-fixme[13]: Attribute `data_loader_map_provider` is never initialized.
|
||||
data_loader_map_provider: DataLoaderMapProviderBase
|
||||
data_loader_map_provider_class_type: str = "SequenceDataLoaderMapProvider"
|
||||
|
||||
@@ -78,7 +75,7 @@ class ImplicitronDataSource(DataSourceBase):
|
||||
)
|
||||
|
||||
try:
|
||||
from .sql_dataset_provider import ( # noqa: F401 # pyre-ignore
|
||||
from .sql_dataset_provider import ( # noqa: F401
|
||||
SqlIndexDatasetMapProvider,
|
||||
)
|
||||
except ModuleNotFoundError:
|
||||
@@ -100,7 +97,7 @@ class ImplicitronDataSource(DataSourceBase):
|
||||
"""
|
||||
DEPRECATED! The property will be removed in future versions.
|
||||
"""
|
||||
if self._all_train_cameras_cache is None: # pyre-ignore[16]
|
||||
if self._all_train_cameras_cache is None:
|
||||
all_train_cameras = self.dataset_map_provider.get_all_train_cameras()
|
||||
self._all_train_cameras_cache = (all_train_cameras,)
|
||||
|
||||
|
||||
@@ -297,7 +297,6 @@ 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:]),
|
||||
@@ -312,7 +311,6 @@ 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:]),
|
||||
|
||||
@@ -175,7 +175,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
self._filter_db() # also computes sequence indices
|
||||
self._extract_and_set_eval_batches()
|
||||
|
||||
# pyre-ignore
|
||||
self._frame_data_builder = FrameDataBuilder(
|
||||
dataset_root=self.dataset_root,
|
||||
load_images=self.load_images,
|
||||
@@ -220,7 +219,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
raise ValueError("This function can only join a list of JsonIndexDataset")
|
||||
# pyre-ignore[16]
|
||||
self.frame_annots.extend([fa for d in other_datasets for fa in d.frame_annots])
|
||||
# pyre-ignore[16]
|
||||
self.seq_annots.update(
|
||||
# https://gist.github.com/treyhunner/f35292e676efa0be1728
|
||||
functools.reduce(
|
||||
@@ -301,7 +299,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
self.frame_annots[idx]["frame_annotation"].frame_number: idx
|
||||
for idx in seq_idx
|
||||
}
|
||||
# pyre-ignore[16]
|
||||
for seq, seq_idx in self._seq_to_idx.items()
|
||||
}
|
||||
|
||||
@@ -374,7 +371,7 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
# Deep copy the whole dataset except frame_annots, which are large so we
|
||||
# deep copy only the requested subset of frame_annots.
|
||||
memo = {id(self.frame_annots): None} # pyre-ignore[16]
|
||||
memo = {id(self.frame_annots): None}
|
||||
dataset_new = copy.deepcopy(self, memo)
|
||||
dataset_new.frame_annots = copy.deepcopy(
|
||||
[self.frame_annots[i] for i in valid_dataset_indices]
|
||||
@@ -402,11 +399,9 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
return dataset_new
|
||||
|
||||
def __str__(self) -> str:
|
||||
# pyre-ignore[16]
|
||||
return f"JsonIndexDataset #frames={len(self.frame_annots)}"
|
||||
|
||||
def __len__(self) -> int:
|
||||
# pyre-ignore[16]
|
||||
return len(self.frame_annots)
|
||||
|
||||
def _get_frame_type(self, entry: FrameAnnotsEntry) -> Optional[str]:
|
||||
@@ -418,7 +413,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
"""
|
||||
logger.info("Loading all train cameras.")
|
||||
cameras = []
|
||||
# pyre-ignore[16]
|
||||
for frame_idx, frame_annot in enumerate(tqdm(self.frame_annots)):
|
||||
frame_type = self._get_frame_type(frame_annot)
|
||||
if frame_type is None:
|
||||
@@ -429,16 +423,13 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
return join_cameras_as_batch(cameras)
|
||||
|
||||
def __getitem__(self, index) -> FrameData:
|
||||
# pyre-ignore[16]
|
||||
if index >= len(self.frame_annots):
|
||||
raise IndexError(f"index {index} out of range {len(self.frame_annots)}")
|
||||
|
||||
entry = self.frame_annots[index]["frame_annotation"]
|
||||
|
||||
# pyre-ignore
|
||||
frame_data = self._frame_data_builder.build(
|
||||
entry,
|
||||
# pyre-ignore
|
||||
self.seq_annots[entry.sequence_name],
|
||||
)
|
||||
# Optional field
|
||||
@@ -483,7 +474,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
for subset, frames in subset_to_seq_frame.items()
|
||||
for _, _, path in frames
|
||||
}
|
||||
# pyre-ignore[16]
|
||||
for frame in self.frame_annots:
|
||||
frame["subset"] = frame_path_to_subset.get(
|
||||
frame["frame_annotation"].image.path, None
|
||||
@@ -496,7 +486,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
def _sort_frames(self) -> None:
|
||||
# Sort frames to have them grouped by sequence, ordered by timestamp
|
||||
# pyre-ignore[16]
|
||||
self.frame_annots = sorted(
|
||||
self.frame_annots,
|
||||
key=lambda f: (
|
||||
@@ -508,7 +497,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
def _filter_db(self) -> None:
|
||||
if self.remove_empty_masks:
|
||||
logger.info("Removing images with empty masks.")
|
||||
# pyre-ignore[16]
|
||||
old_len = len(self.frame_annots)
|
||||
|
||||
msg = "remove_empty_masks needs every MaskAnnotation.mass to be set."
|
||||
@@ -549,7 +537,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
if len(self.limit_category_to) > 0:
|
||||
logger.info(f"Limiting dataset to categories: {self.limit_category_to}")
|
||||
# pyre-ignore[16]
|
||||
self.seq_annots = {
|
||||
name: entry
|
||||
for name, entry in self.seq_annots.items()
|
||||
@@ -587,7 +574,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
if self.n_frames_per_sequence > 0:
|
||||
logger.info(f"Taking max {self.n_frames_per_sequence} per sequence.")
|
||||
keep_idx = []
|
||||
# pyre-ignore[16]
|
||||
for seq, seq_indices in self._seq_to_idx.items():
|
||||
# infer the seed from the sequence name, this is reproducible
|
||||
# and makes the selection differ for different sequences
|
||||
@@ -617,7 +603,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
self._invalidate_seq_to_idx()
|
||||
|
||||
if filter_seq_annots:
|
||||
# pyre-ignore[16]
|
||||
self.seq_annots = {
|
||||
k: v
|
||||
for k, v in self.seq_annots.items()
|
||||
@@ -627,7 +612,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
def _invalidate_seq_to_idx(self) -> None:
|
||||
seq_to_idx = defaultdict(list)
|
||||
# pyre-ignore[16]
|
||||
for idx, entry in enumerate(self.frame_annots):
|
||||
seq_to_idx[entry["frame_annotation"].sequence_name].append(idx)
|
||||
# pyre-ignore[16]
|
||||
@@ -658,7 +642,6 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
def category_to_sequence_names(self) -> Dict[str, List[str]]:
|
||||
c2seq = defaultdict(list)
|
||||
# pyre-ignore
|
||||
for sequence_name, sa in self.seq_annots.items():
|
||||
c2seq[sa.category].append(sequence_name)
|
||||
return dict(c2seq)
|
||||
|
||||
@@ -94,7 +94,6 @@ class JsonIndexDatasetMapProvider(DatasetMapProviderBase):
|
||||
path_manager_factory_class_type: The class type of `path_manager_factory`.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `category` is never initialized.
|
||||
category: str
|
||||
task_str: str = "singlesequence"
|
||||
dataset_root: str = _CO3D_DATASET_ROOT
|
||||
@@ -104,10 +103,8 @@ class JsonIndexDatasetMapProvider(DatasetMapProviderBase):
|
||||
test_restrict_sequence_id: int = -1
|
||||
assert_single_seq: bool = False
|
||||
only_test_set: bool = False
|
||||
# pyre-fixme[13]: Attribute `dataset` is never initialized.
|
||||
dataset: JsonIndexDataset
|
||||
dataset_class_type: str = "JsonIndexDataset"
|
||||
# pyre-fixme[13]: Attribute `path_manager_factory` is never initialized.
|
||||
path_manager_factory: PathManagerFactory
|
||||
path_manager_factory_class_type: str = "PathManagerFactory"
|
||||
|
||||
|
||||
@@ -169,9 +169,7 @@ class JsonIndexDatasetMapProviderV2(DatasetMapProviderBase):
|
||||
path_manager_factory_class_type: The class type of `path_manager_factory`.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `category` is never initialized.
|
||||
category: str
|
||||
# pyre-fixme[13]: Attribute `subset_name` is never initialized.
|
||||
subset_name: str
|
||||
dataset_root: str = _CO3DV2_DATASET_ROOT
|
||||
|
||||
@@ -183,10 +181,8 @@ class JsonIndexDatasetMapProviderV2(DatasetMapProviderBase):
|
||||
n_known_frames_for_test: int = 0
|
||||
|
||||
dataset_class_type: str = "JsonIndexDataset"
|
||||
# pyre-fixme[13]: Attribute `dataset` is never initialized.
|
||||
dataset: JsonIndexDataset
|
||||
|
||||
# pyre-fixme[13]: Attribute `path_manager_factory` is never initialized.
|
||||
path_manager_factory: PathManagerFactory
|
||||
path_manager_factory_class_type: str = "PathManagerFactory"
|
||||
|
||||
|
||||
@@ -76,12 +76,10 @@ class RenderedMeshDatasetMapProvider(DatasetMapProviderBase):
|
||||
resolution: int = 128
|
||||
use_point_light: bool = True
|
||||
gpu_idx: Optional[int] = 0
|
||||
# pyre-fixme[13]: Attribute `path_manager_factory` is never initialized.
|
||||
path_manager_factory: PathManagerFactory
|
||||
path_manager_factory_class_type: str = "PathManagerFactory"
|
||||
|
||||
def get_dataset_map(self) -> DatasetMap:
|
||||
# pyre-ignore[16]
|
||||
return DatasetMap(train=self.train_dataset, val=None, test=None)
|
||||
|
||||
def get_all_train_cameras(self) -> CamerasBase:
|
||||
@@ -117,10 +115,8 @@ class RenderedMeshDatasetMapProvider(DatasetMapProviderBase):
|
||||
device=device,
|
||||
use_point_light=self.use_point_light,
|
||||
)
|
||||
# pyre-ignore[16]
|
||||
self.poses = poses.cpu()
|
||||
# pyre-ignore[16]
|
||||
self.train_dataset = SingleSceneDataset( # pyre-ignore[28]
|
||||
self.train_dataset = SingleSceneDataset(
|
||||
# pyrefly: ignore [unexpected-keyword]
|
||||
object_name="cow",
|
||||
# pyrefly: ignore [unexpected-keyword]
|
||||
|
||||
@@ -99,11 +99,8 @@ class SingleSceneDatasetMapProviderBase(DatasetMapProviderBase):
|
||||
testing frame.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `base_dir` is never initialized.
|
||||
base_dir: str
|
||||
# pyre-fixme[13]: Attribute `object_name` is never initialized.
|
||||
object_name: str
|
||||
# pyre-fixme[13]: Attribute `path_manager_factory` is never initialized.
|
||||
path_manager_factory: PathManagerFactory
|
||||
path_manager_factory_class_type: str = "PathManagerFactory"
|
||||
n_known_frames_for_test: Optional[int] = None
|
||||
@@ -149,7 +146,6 @@ class SingleSceneDatasetMapProviderBase(DatasetMapProviderBase):
|
||||
split = np.concatenate([split, train_split])
|
||||
frame_types.extend([DATASET_TYPE_KNOWN] * len(train_split))
|
||||
|
||||
# pyre-ignore[28]
|
||||
return SingleSceneDataset(
|
||||
object_name=self.object_name,
|
||||
# pyre-ignore[16]
|
||||
|
||||
@@ -205,7 +205,7 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase):
|
||||
logger.info(str(self))
|
||||
|
||||
if self.scoped_session:
|
||||
self._session_factory = sessionmaker(bind=self._sql_engine) # pyre-ignore
|
||||
self._session_factory = sessionmaker(bind=self._sql_engine)
|
||||
|
||||
if self.precompute_seq_to_idx:
|
||||
# This is deprecated and will be removed in the future.
|
||||
@@ -215,7 +215,7 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase):
|
||||
)
|
||||
self._index["rowid"] = np.arange(len(self._index))
|
||||
groupby = self._index.groupby("sequence_name", sort=False)["rowid"]
|
||||
self._seq_to_indices = dict(groupby.apply(list)) # pyre-ignore
|
||||
self._seq_to_indices = dict(groupby.apply(list))
|
||||
del self._index["rowid"]
|
||||
|
||||
def __len__(self) -> int:
|
||||
@@ -280,7 +280,6 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase):
|
||||
self.sequence_annotations_type.sequence_name == seq
|
||||
)
|
||||
if self.scoped_session:
|
||||
# pyre-ignore
|
||||
with scoped_session(self._session_factory)() as session:
|
||||
entry = session.scalars(stmt).one()
|
||||
seq_metadata = session.scalars(seq_stmt).one()
|
||||
@@ -404,7 +403,6 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase):
|
||||
only dataset indices.
|
||||
"""
|
||||
if self.precompute_seq_to_idx and subset_filter is None:
|
||||
# pyre-ignore
|
||||
yield from self._seq_to_indices[seq_name]
|
||||
else:
|
||||
for _, _, idx in self.sequence_frames_in_order(seq_name, subset_filter):
|
||||
@@ -836,7 +834,7 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase):
|
||||
|
||||
if self.scoped_session:
|
||||
stmt_text = str(stmt.compile(compile_kwargs={"literal_binds": True}))
|
||||
with scoped_session(self._session_factory)() as session: # pyre-ignore
|
||||
with scoped_session(self._session_factory)() as session:
|
||||
frame_no_ts = pd.read_sql_query(stmt_text, session.connection())
|
||||
else:
|
||||
with self._sql_engine.connect() as connection:
|
||||
|
||||
@@ -193,9 +193,9 @@ class SqlIndexDatasetMapProvider(DatasetMapProviderBase):
|
||||
|
||||
# this is a mould that is never constructed, used to build self._dataset_map values
|
||||
dataset_class_type: str = "SqlIndexDataset"
|
||||
dataset: SqlIndexDataset # pyre-ignore [13]
|
||||
dataset: SqlIndexDataset
|
||||
|
||||
path_manager_factory: PathManagerFactory # pyre-ignore [13]
|
||||
path_manager_factory: PathManagerFactory
|
||||
path_manager_factory_class_type: str = "PathManagerFactory"
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
@@ -306,7 +306,6 @@ def _unwrap_type(tp):
|
||||
|
||||
def _get_dataclass_field_default(field: Field) -> Any:
|
||||
if field.default_factory is not MISSING:
|
||||
# pyre-fixme[29]: `Union[dataclasses._MISSING_TYPE,
|
||||
# dataclasses._DefaultFactory[typing.Any]]` is not a function.
|
||||
return field.default_factory()
|
||||
elif field.default is not MISSING:
|
||||
|
||||
@@ -192,7 +192,6 @@ def rescale_bbox(
|
||||
assert bbox is not None
|
||||
assert np.prod(orig_res) > 1e-8
|
||||
# average ratio of dimensions
|
||||
# pyre-ignore
|
||||
rel_size = (new_res[0] / orig_res[0] + new_res[1] / orig_res[1]) / 2.0
|
||||
return bbox * rel_size
|
||||
|
||||
@@ -368,7 +367,6 @@ def adjust_camera_to_bbox_crop_(
|
||||
)
|
||||
|
||||
camera.focal_length = focal_length[None]
|
||||
# pyre-fixme[16]: `PerspectiveCameras` has no attribute `principal_point`.
|
||||
camera.principal_point = principal_point_cropped[None]
|
||||
|
||||
|
||||
@@ -397,8 +395,7 @@ def adjust_camera_to_image_scale_(
|
||||
image_size_wh_output,
|
||||
)
|
||||
camera.focal_length = focal_length_scaled[None]
|
||||
# pyre-fixme[16]: `PerspectiveCameras` has no attribute `principal_point`.
|
||||
camera.principal_point = principal_point_scaled[None] # pyre-ignore[16]
|
||||
camera.principal_point = principal_point_scaled[None]
|
||||
|
||||
|
||||
# NOTE this cache is per-worker; they are implemented as processes.
|
||||
|
||||
@@ -46,7 +46,6 @@ def get_implicitron_sequence_pointcloud(
|
||||
sequence_entries = [
|
||||
ei
|
||||
for ei in sequence_entries
|
||||
# pyre-ignore[16]
|
||||
if dataset.frame_annots[ei]["frame_annotation"].sequence_name
|
||||
== sequence_name
|
||||
]
|
||||
|
||||
@@ -321,7 +321,6 @@ def eval_batch(
|
||||
# only record depth metrics for the foreground
|
||||
_, abs_ = eval_depth(
|
||||
cloned_render["depth_render"],
|
||||
# pyre-fixme[6]: For 2nd param expected `Tensor` but got
|
||||
# `Optional[Tensor]`.
|
||||
frame_data.depth_map,
|
||||
get_best_scale=True,
|
||||
|
||||
@@ -220,6 +220,5 @@ class ResNetFeatureExtractor(FeatureExtractorBase):
|
||||
if self.feature_rescale != 1.0:
|
||||
out_feats = {k: self.feature_rescale * f for k, f in out_feats.items()}
|
||||
|
||||
# pyre-fixme[7]: Incompatible return type, expected `Dict[typing.Any, Tensor]`
|
||||
# but got `Dict[typing.Any, float]`
|
||||
return out_feats
|
||||
|
||||
@@ -222,42 +222,34 @@ class GenericModel(ImplicitronModelBase):
|
||||
|
||||
# ---- global encoder settings
|
||||
global_encoder_class_type: Optional[str] = None
|
||||
# pyre-fixme[13]: Attribute `global_encoder` is never initialized.
|
||||
global_encoder: Optional[GlobalEncoderBase]
|
||||
|
||||
# ---- raysampler
|
||||
raysampler_class_type: str = "AdaptiveRaySampler"
|
||||
# pyre-fixme[13]: Attribute `raysampler` is never initialized.
|
||||
raysampler: RaySamplerBase
|
||||
|
||||
# ---- renderer configs
|
||||
renderer_class_type: str = "MultiPassEmissionAbsorptionRenderer"
|
||||
# pyre-fixme[13]: Attribute `renderer` is never initialized.
|
||||
renderer: BaseRenderer
|
||||
|
||||
# ---- image feature extractor settings
|
||||
# (This is only created if view_pooler is enabled)
|
||||
# pyre-fixme[13]: Attribute `image_feature_extractor` is never initialized.
|
||||
image_feature_extractor: Optional[FeatureExtractorBase]
|
||||
image_feature_extractor_class_type: Optional[str] = None
|
||||
# ---- view pooler settings
|
||||
view_pooler_enabled: bool = False
|
||||
# pyre-fixme[13]: Attribute `view_pooler` is never initialized.
|
||||
view_pooler: Optional[ViewPooler]
|
||||
|
||||
# ---- implicit function settings
|
||||
implicit_function_class_type: str = "NeuralRadianceFieldImplicitFunction"
|
||||
# This is just a model, never constructed.
|
||||
# The actual implicit functions live in self._implicit_functions
|
||||
# pyre-fixme[13]: Attribute `implicit_function` is never initialized.
|
||||
implicit_function: ImplicitFunctionBase
|
||||
|
||||
# ----- metrics
|
||||
# pyre-fixme[13]: Attribute `view_metrics` is never initialized.
|
||||
view_metrics: ViewMetricsBase
|
||||
view_metrics_class_type: str = "ViewMetrics"
|
||||
|
||||
# pyre-fixme[13]: Attribute `regularization_metrics` is never initialized.
|
||||
regularization_metrics: RegularizationMetricsBase
|
||||
regularization_metrics_class_type: str = "RegularizationMetrics"
|
||||
|
||||
@@ -475,7 +467,6 @@ class GenericModel(ImplicitronModelBase):
|
||||
# pyrefly: ignore [unsupported-operation]
|
||||
custom_args["global_code"] = global_code
|
||||
|
||||
# pyre-fixme[29]: `Union[(self: Tensor) -> Any, Tensor, Module]` is not a
|
||||
# function.
|
||||
for func in self._implicit_functions:
|
||||
func.bind_args(**custom_args)
|
||||
@@ -499,7 +490,6 @@ class GenericModel(ImplicitronModelBase):
|
||||
# Unbind the custom arguments to prevent pytorch from storing
|
||||
# large buffers of intermediate results due to points in the
|
||||
# bound arguments.
|
||||
# pyre-fixme[29]: `Union[(self: Tensor) -> Any, Tensor, Module]` is not a
|
||||
# function.
|
||||
for func in self._implicit_functions:
|
||||
func.unbind_args()
|
||||
|
||||
@@ -65,7 +65,6 @@ class SequenceAutodecoder(GlobalEncoderBase, torch.nn.Module):
|
||||
of the frame's sequence identifier.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `autodecoder` is never initialized.
|
||||
autodecoder: Autodecoder
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
@@ -229,10 +229,8 @@ class MLPWithInputSkips(Configurable, torch.nn.Module):
|
||||
# if the skip tensor is None, we use `x` instead.
|
||||
z = x
|
||||
skipi = 0
|
||||
# pyre-fixme[6]: For 1st argument expected `Iterable[_T]` but got
|
||||
# `Union[Tensor, Module]`.
|
||||
for li, layer in enumerate(self.mlp):
|
||||
# pyre-fixme[58]: `in` is not supported for right operand type
|
||||
# `Union[Tensor, Module]`.
|
||||
if li in self._input_skips:
|
||||
if self._skip_affine_trans:
|
||||
@@ -273,7 +271,6 @@ class MLPDecoder(DecoderFunctionBase):
|
||||
|
||||
input_dim: int = 3
|
||||
param_groups: Dict[str, str] = field(default_factory=lambda: {})
|
||||
# pyre-fixme[13]: Attribute `network` is never initialized.
|
||||
network: MLPWithInputSkips
|
||||
|
||||
def __post_init__(self):
|
||||
@@ -351,7 +348,6 @@ class TransformerWithInputSkips(torch.nn.Module):
|
||||
self.last = torch.nn.Linear(dimout, output_dim)
|
||||
_xavier_init(self.last)
|
||||
|
||||
# pyre-fixme[8]: Attribute has type `Tuple[ModuleList, ModuleList]`; used as
|
||||
# `ModuleList`.
|
||||
self.layers_pool, self.layers_ray = (
|
||||
torch.nn.ModuleList(layers_pool),
|
||||
|
||||
@@ -177,7 +177,6 @@ class IdrFeatureField(ImplicitFunctionBase, torch.nn.Module):
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[An...
|
||||
x = self.linear_layers[layer_idx](x)
|
||||
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, other: Union[bool, complex,
|
||||
# float, int, Tensor]) -> Tensor, Module, Tensor]` is not a function.
|
||||
if layer_idx < self.num_layers - 2:
|
||||
# pyre-fixme[29]: `Union[Module, Tensor]` is not a function.
|
||||
|
||||
@@ -125,7 +125,6 @@ class NeuralRadianceFieldBase(ImplicitFunctionBase, torch.nn.Module):
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
rays_embedding = self.harmonic_embedding_dir(rays_directions_normed)
|
||||
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
return self.color_layer((self.intermediate_linear(features), rays_embedding))
|
||||
|
||||
@staticmethod
|
||||
@@ -196,7 +195,6 @@ class NeuralRadianceFieldBase(ImplicitFunctionBase, torch.nn.Module):
|
||||
embeds = create_embeddings_for_implicit_function(
|
||||
xyz_world=rays_points_world,
|
||||
# for 2nd param but got `Union[None, torch.Tensor, torch.nn.Module]`.
|
||||
# pyre-fixme[6]: For 2nd argument expected `Optional[(...) -> Any]` but
|
||||
# got `Union[None, Tensor, Module]`.
|
||||
xyz_embedding_function=(
|
||||
self.harmonic_embedding_xyz if self.input_xyz else None
|
||||
@@ -224,7 +222,6 @@ class NeuralRadianceFieldBase(ImplicitFunctionBase, torch.nn.Module):
|
||||
if camera is None:
|
||||
raise ValueError("Camera must be given if xyz_ray_dir_in_camera_coords")
|
||||
|
||||
# pyre-fixme[58]: `@` is not supported for operand types `Tensor` and
|
||||
# `Union[Tensor, Module]`.
|
||||
directions = ray_bundle.directions @ camera.R
|
||||
else:
|
||||
|
||||
@@ -171,7 +171,6 @@ class SRNPixelGenerator(Configurable, torch.nn.Module):
|
||||
# Obtain the harmonic embedding of the normalized ray directions.
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
rays_embedding = self._harmonic_embedding(rays_directions_normed)
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
return self._color_layer((features, rays_embedding))
|
||||
|
||||
def forward(
|
||||
@@ -208,7 +207,6 @@ class SRNPixelGenerator(Configurable, torch.nn.Module):
|
||||
if camera is None:
|
||||
raise ValueError("Camera must be given if xyz_ray_dir_in_camera_coords")
|
||||
|
||||
# pyre-fixme[58]: `@` is not supported for operand types `Tensor` and
|
||||
# `Union[Tensor, Module]`.
|
||||
directions = ray_bundle.directions @ camera.R
|
||||
else:
|
||||
@@ -331,9 +329,7 @@ class SRNRaymarchHyperNet(Configurable, torch.nn.Module):
|
||||
@registry.register
|
||||
class SRNImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
latent_dim: int = 0
|
||||
# pyre-fixme[13]: Attribute `raymarch_function` is never initialized.
|
||||
raymarch_function: SRNRaymarchFunction
|
||||
# pyre-fixme[13]: Attribute `pixel_generator` is never initialized.
|
||||
pixel_generator: SRNPixelGenerator
|
||||
|
||||
def __post_init__(self):
|
||||
@@ -389,9 +385,7 @@ class SRNHyperNetImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
|
||||
latent_dim_hypernet: int = 0
|
||||
latent_dim: int = 0
|
||||
# pyre-fixme[13]: Attribute `hypernet` is never initialized.
|
||||
hypernet: SRNRaymarchHyperNet
|
||||
# pyre-fixme[13]: Attribute `pixel_generator` is never initialized.
|
||||
pixel_generator: SRNPixelGenerator
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
@@ -844,7 +844,6 @@ class VoxelGridModule(Configurable, torch.nn.Module):
|
||||
"""
|
||||
|
||||
voxel_grid_class_type: str = "FullResolutionVoxelGrid"
|
||||
# pyre-fixme[13]: Attribute `voxel_grid` is never initialized.
|
||||
voxel_grid: VoxelGridBase
|
||||
|
||||
extents: Tuple[float, float, float] = (2.0, 2.0, 2.0)
|
||||
@@ -907,7 +906,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
|
||||
@@ -996,7 +994,6 @@ class VoxelGridModule(Configurable, torch.nn.Module):
|
||||
"""
|
||||
'''
|
||||
new_params = {}
|
||||
# pyre-fixme[29]: `Union[(self: Tensor) -> Any, Tensor, Module]` is not a
|
||||
# function.
|
||||
for name in self.params:
|
||||
key = prefix + "params." + name
|
||||
@@ -1035,7 +1032,6 @@ class VoxelGridModule(Configurable, torch.nn.Module):
|
||||
grid_values, _ = self.voxel_grid.change_resolution(
|
||||
new_grid_values, grid_values_with_wanted_resolution=old_grid_values
|
||||
)
|
||||
# pyre-fixme[16]: `VoxelGridModule` has no attribute `params`.
|
||||
self.params = torch.nn.ParameterDict(
|
||||
{
|
||||
k: torch.nn.Parameter(val)
|
||||
|
||||
@@ -142,11 +142,9 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
"""
|
||||
|
||||
# ---- voxel grid for density
|
||||
# pyre-fixme[13]: Attribute `voxel_grid_density` is never initialized.
|
||||
voxel_grid_density: VoxelGridModule
|
||||
|
||||
# ---- voxel grid for color
|
||||
# pyre-fixme[13]: Attribute `voxel_grid_color` is never initialized.
|
||||
voxel_grid_color: VoxelGridModule
|
||||
|
||||
# ---- harmonic embeddings density
|
||||
@@ -162,12 +160,10 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
|
||||
# ---- decoder function for density
|
||||
decoder_density_class_type: str = "MLPDecoder"
|
||||
# pyre-fixme[13]: Attribute `decoder_density` is never initialized.
|
||||
decoder_density: DecoderFunctionBase
|
||||
|
||||
# ---- decoder function for color
|
||||
decoder_color_class_type: str = "MLPDecoder"
|
||||
# pyre-fixme[13]: Attribute `decoder_color` is never initialized.
|
||||
decoder_color: DecoderFunctionBase
|
||||
|
||||
# ---- cuda streams
|
||||
@@ -190,25 +186,20 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
run_auto_creation(self)
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `voxel_grid_scaffold`.
|
||||
self.voxel_grid_scaffold = self._create_voxel_grid_scaffold()
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `harmonic_embedder_xyz_density`.
|
||||
self.harmonic_embedder_xyz_density = HarmonicEmbedding(
|
||||
**self.harmonic_embedder_xyz_density_args
|
||||
)
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `harmonic_embedder_xyz_color`.
|
||||
self.harmonic_embedder_xyz_color = HarmonicEmbedding(
|
||||
**self.harmonic_embedder_xyz_color_args
|
||||
)
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `harmonic_embedder_dir_color`.
|
||||
self.harmonic_embedder_dir_color = HarmonicEmbedding(
|
||||
**self.harmonic_embedder_dir_color_args
|
||||
)
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `_scaffold_ready`.
|
||||
self._scaffold_ready = False
|
||||
|
||||
@@ -372,7 +363,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
feature dimensionality which `decoder_density` returns
|
||||
"""
|
||||
embeds_density = self.voxel_grid_density(points)
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
harmonic_embedding_density = self.harmonic_embedder_xyz_density(embeds_density)
|
||||
# shape = [..., density_dim]
|
||||
return self.decoder_density(harmonic_embedding_density)
|
||||
@@ -407,7 +397,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
if self.xyz_ray_dir_in_camera_coords:
|
||||
if camera is None:
|
||||
raise ValueError("Camera must be given if xyz_ray_dir_in_camera_coords")
|
||||
# pyre-fixme[58]: `@` is not supported for operand types `Tensor` and
|
||||
# `Union[Tensor, Module]`.
|
||||
directions = directions @ camera.R
|
||||
|
||||
@@ -417,13 +406,11 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
|
||||
# ########## embed with the harmonic function ########## #
|
||||
# Obtain the harmonic embedding of the voxel grid output.
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
harmonic_embedding_color = self.harmonic_embedder_xyz_color(embeds_color)
|
||||
|
||||
# Normalize the ray_directions to unit l2 norm.
|
||||
rays_directions_normed = torch.nn.functional.normalize(directions, dim=-1)
|
||||
# Obtain the harmonic embedding of the normalized ray directions.
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
harmonic_embedding_dir = self.harmonic_embedder_dir_color(
|
||||
rays_directions_normed
|
||||
)
|
||||
@@ -493,7 +480,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
an object inside, else False.
|
||||
"""
|
||||
# find bounding box
|
||||
# pyre-fixme[16]: Item `Tensor` of `Tensor | Module` has no attribute
|
||||
# `get_grid_points`.
|
||||
points = self.voxel_grid_scaffold.get_grid_points(epoch=epoch)
|
||||
assert self._scaffold_ready, "Scaffold has to be calculated before cropping."
|
||||
@@ -529,7 +515,6 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
"""
|
||||
|
||||
planes = []
|
||||
# pyre-fixme[16]: Item `Tensor` of `Tensor | Module` has no attribute
|
||||
# `get_grid_points`.
|
||||
points = self.voxel_grid_scaffold.get_grid_points(epoch=epoch)
|
||||
|
||||
@@ -550,9 +535,7 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
|
||||
stride=1,
|
||||
)
|
||||
occupancy_cube = density_cube > self.scaffold_empty_space_threshold
|
||||
# pyre-fixme[16]: Item `Tensor` of `Tensor | Module` has no attribute `params`.
|
||||
self.voxel_grid_scaffold.params["voxel_grid"] = occupancy_cube.float()
|
||||
# pyre-fixme[16]: `VoxelGridImplicitFunction` has no attribute
|
||||
# `_scaffold_ready`.
|
||||
self._scaffold_ready = True
|
||||
|
||||
|
||||
@@ -195,34 +195,27 @@ class OverfitModel(ImplicitronModelBase):
|
||||
|
||||
# ---- global encoder settings
|
||||
global_encoder_class_type: Optional[str] = None
|
||||
# pyre-fixme[13]: Attribute `global_encoder` is never initialized.
|
||||
global_encoder: Optional[GlobalEncoderBase]
|
||||
|
||||
# ---- raysampler
|
||||
raysampler_class_type: str = "AdaptiveRaySampler"
|
||||
# pyre-fixme[13]: Attribute `raysampler` is never initialized.
|
||||
raysampler: RaySamplerBase
|
||||
|
||||
# ---- renderer configs
|
||||
renderer_class_type: str = "MultiPassEmissionAbsorptionRenderer"
|
||||
# pyre-fixme[13]: Attribute `renderer` is never initialized.
|
||||
renderer: BaseRenderer
|
||||
|
||||
# ---- implicit function settings
|
||||
share_implicit_function_across_passes: bool = False
|
||||
implicit_function_class_type: str = "NeuralRadianceFieldImplicitFunction"
|
||||
# pyre-fixme[13]: Attribute `implicit_function` is never initialized.
|
||||
implicit_function: ImplicitFunctionBase
|
||||
coarse_implicit_function_class_type: Optional[str] = None
|
||||
# pyre-fixme[13]: Attribute `coarse_implicit_function` is never initialized.
|
||||
coarse_implicit_function: Optional[ImplicitFunctionBase]
|
||||
|
||||
# ----- metrics
|
||||
# pyre-fixme[13]: Attribute `view_metrics` is never initialized.
|
||||
view_metrics: ViewMetricsBase
|
||||
view_metrics_class_type: str = "ViewMetrics"
|
||||
|
||||
# pyre-fixme[13]: Attribute `regularization_metrics` is never initialized.
|
||||
regularization_metrics: RegularizationMetricsBase
|
||||
regularization_metrics_class_type: str = "RegularizationMetrics"
|
||||
|
||||
@@ -658,7 +651,6 @@ class OverfitModel(ImplicitronModelBase):
|
||||
|
||||
implicit_function_type = registry.get(
|
||||
ImplicitFunctionBase,
|
||||
# pyre-ignore: config is None allow to check if this is None.
|
||||
self.coarse_implicit_function_class_type,
|
||||
)
|
||||
expand_args_fields(implicit_function_type)
|
||||
|
||||
@@ -108,7 +108,6 @@ class ImplicitronRayBundle:
|
||||
def lengths(self) -> torch.Tensor:
|
||||
if self.bins is not None:
|
||||
# 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
|
||||
|
||||
@@ -135,7 +135,6 @@ class LSTMRenderer(BaseRenderer, torch.nn.Module):
|
||||
break
|
||||
|
||||
# run the lstm marcher
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
state_h, state_c = self._lstm(
|
||||
raymarch_features.view(-1, raymarch_features.shape[-1]),
|
||||
states[-1],
|
||||
|
||||
@@ -84,7 +84,6 @@ class MultiPassEmissionAbsorptionRenderer(BaseRenderer, torch.nn.Module):
|
||||
"""
|
||||
|
||||
raymarcher_class_type: str = "EmissionAbsorptionRaymarcher"
|
||||
# pyre-fixme[13]: Attribute `raymarcher` is never initialized.
|
||||
raymarcher: RaymarcherBase
|
||||
|
||||
n_pts_per_ray_fine_training: int = 64
|
||||
|
||||
@@ -42,9 +42,7 @@ class RayPointRefiner(Configurable, torch.nn.Module):
|
||||
for Anti-Aliasing Neural Radiance Fields." ICCV 2021.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `n_pts_per_ray` is never initialized.
|
||||
n_pts_per_ray: int
|
||||
# pyre-fixme[13]: Attribute `random_sampling` is never initialized.
|
||||
random_sampling: bool
|
||||
add_input_samples: bool = True
|
||||
blurpool_weights: bool = False
|
||||
|
||||
@@ -207,7 +207,6 @@ class AbstractMaskRaySampler(RaySamplerBase, torch.nn.Module):
|
||||
"""
|
||||
sample_mask = None
|
||||
if (
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[An...
|
||||
self._sampling_mode[evaluation_mode] == RenderSamplingMode.MASK_SAMPLE
|
||||
and mask is not None
|
||||
):
|
||||
@@ -242,7 +241,6 @@ class AbstractMaskRaySampler(RaySamplerBase, torch.nn.Module):
|
||||
"Heterogeneous ray bundle is not supported for conical frustum computation yet"
|
||||
)
|
||||
elif self.cast_ray_bundle_as_cone:
|
||||
# pyre-fixme[9]: pixel_hw has type `Tuple[float, float]`; used as
|
||||
# `Tuple[Union[Tensor, Module], Union[Tensor, Module]]`.
|
||||
pixel_hw: Tuple[float, float] = (self.pixel_height, self.pixel_width)
|
||||
pixel_radii_2d = compute_radii(cameras, ray_bundle.xys[..., :2], pixel_hw)
|
||||
|
||||
@@ -571,7 +571,6 @@ def _get_sphere_intersection(
|
||||
# cam_loc = cam_loc.unsqueeze(-1)
|
||||
# ray_cam_dot = torch.bmm(ray_directions, cam_loc).squeeze()
|
||||
ray_cam_dot = (ray_directions * cam_loc).sum(-1) # n_images x n_rays
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
under_sqrt = ray_cam_dot**2 - (cam_loc.norm(2, dim=-1) ** 2 - r**2)
|
||||
|
||||
under_sqrt = under_sqrt.reshape(-1)
|
||||
|
||||
@@ -27,7 +27,6 @@ from .rgb_net import RayNormalColoringNetwork
|
||||
class SignedDistanceFunctionRenderer(BaseRenderer, torch.nn.Module):
|
||||
render_features_dimensions: int = 3
|
||||
object_bounding_sphere: float = 1.0
|
||||
# pyre-fixme[13]: Attribute `ray_tracer` is never initialized.
|
||||
ray_tracer: RayTracing
|
||||
ray_normal_coloring_network_args: DictConfig = get_default_args_field(
|
||||
RayNormalColoringNetwork
|
||||
@@ -208,7 +207,6 @@ class SignedDistanceFunctionRenderer(BaseRenderer, torch.nn.Module):
|
||||
]
|
||||
normals_full.view(-1, 3)[surface_mask] = normals
|
||||
render_full.view(-1, self.render_features_dimensions)[surface_mask] = (
|
||||
# pyre-fixme[29]: `Union[Tensor, Module]` is not a function.
|
||||
self._rgb_network(
|
||||
features,
|
||||
differentiable_surface_points[None],
|
||||
|
||||
@@ -532,7 +532,6 @@ def _get_ray_dir_dot_prods(camera: CamerasBase, pts: torch.Tensor):
|
||||
|
||||
# does not produce nans randomly unlike get_camera_center() below
|
||||
cam_centers_rep = -torch.bmm(
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[Any, A...
|
||||
camera_rep.T[:, None],
|
||||
camera_rep.R.permute(0, 2, 1),
|
||||
).reshape(-1, *([1] * (pts.ndim - 2)), 3)
|
||||
@@ -632,7 +631,6 @@ def _avgmaxstd_reduction_function(
|
||||
x_aggr = torch.cat(pooled_features, dim=-1)
|
||||
|
||||
# zero out features that were all masked out
|
||||
# pyre-fixme[16]: `bool` has no attribute `type_as`.
|
||||
any_active = (w.max(dim=dim, keepdim=True).values > 1e-4).type_as(x_aggr)
|
||||
x_aggr = x_aggr * any_active[..., None]
|
||||
|
||||
@@ -660,7 +658,6 @@ def _std_reduction_function(
|
||||
):
|
||||
if mu is None:
|
||||
mu = _avg_reduction_function(x, w, dim=dim)
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
std = wmean((x - mu) ** 2, w, dim=dim, eps=1e-2).clamp(1e-4).sqrt()
|
||||
# FIXME: somehow this is extremely heavy in mem?
|
||||
return std
|
||||
|
||||
@@ -34,10 +34,8 @@ class ViewPooler(Configurable, torch.nn.Module):
|
||||
from a set of source images. FeatureAggregator executes step (4) above.
|
||||
"""
|
||||
|
||||
# pyre-fixme[13]: Attribute `view_sampler` is never initialized.
|
||||
view_sampler: ViewSampler
|
||||
feature_aggregator_class_type: str = "AngleWeightedReductionFeatureAggregator"
|
||||
# pyre-fixme[13]: Attribute `feature_aggregator` is never initialized.
|
||||
feature_aggregator: FeatureAggregatorBase
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
@@ -312,7 +312,6 @@ class _Registry:
|
||||
raise ValueError(
|
||||
f"{name} resolves to {result} which does not subclass {base_class_wanted}"
|
||||
)
|
||||
# pyre-ignore[7]
|
||||
return result
|
||||
|
||||
def get_all(
|
||||
|
||||
@@ -51,7 +51,6 @@ def cleanup_eval_depth(
|
||||
# the threshold is a sigma-multiple of the standard deviation of the depth
|
||||
mu = wmean(depth.view(ba, -1, 1), mask.view(ba, -1)).view(ba, 1)
|
||||
std = (
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
wmean((depth.view(ba, -1) - mu).view(ba, -1, 1) ** 2, mask.view(ba, -1))
|
||||
.clamp(1e-4)
|
||||
.sqrt()
|
||||
|
||||
@@ -79,7 +79,6 @@ def eval_depth(
|
||||
|
||||
df = gt - pred
|
||||
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
mse_depth = (dmask * (df**2)).sum((1, 2, 3)) / dmask_mass
|
||||
abs_depth = (dmask * df.abs()).sum((1, 2, 3)) / dmask_mass
|
||||
|
||||
@@ -115,10 +114,8 @@ def calc_mse(
|
||||
Calculates the mean square error between tensors `x` and `y`.
|
||||
"""
|
||||
if mask is None:
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
return torch.mean((x - y) ** 2)
|
||||
else:
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
return (((x - y) ** 2) * mask).sum() / mask.expand_as(x).sum().clamp(1e-5)
|
||||
|
||||
|
||||
@@ -146,7 +143,6 @@ def calc_bce(
|
||||
mask_bg = (1 - mask_fg) * mask
|
||||
weight = mask_fg / mask_fg.sum().clamp(1.0) + mask_bg / mask_bg.sum().clamp(1.0)
|
||||
# weight sum should be at this point ~2
|
||||
# pyre-fixme[58]: `/` is not supported for operand types `int` and `Tensor`.
|
||||
weight = weight * (weight.numel() / weight.sum().clamp(1.0))
|
||||
else:
|
||||
weight = torch.ones_like(gt) * mask
|
||||
|
||||
@@ -49,7 +49,6 @@ def get_stats_path(fl, eval_results: bool = False) -> str:
|
||||
break
|
||||
else:
|
||||
flstats = "%s_stats.jgz" % fl
|
||||
# pyre-fixme[61]: `flstats` is undefined, or not always defined.
|
||||
return flstats
|
||||
|
||||
|
||||
@@ -148,15 +147,12 @@ def find_last_checkpoint(
|
||||
)
|
||||
if len(fls) > 0:
|
||||
break
|
||||
# pyre-fixme[61]: `fls` is undefined, or not always defined.
|
||||
if len(fls) == 0:
|
||||
fl = None
|
||||
else:
|
||||
if all_checkpoints:
|
||||
# pyre-fixme[61]: `fls` is undefined, or not always defined.
|
||||
fl = [f[0 : -len(ext)] + ".pth" for f in fls]
|
||||
else:
|
||||
# pyre-fixme[61]: `ext` is undefined, or not always defined.
|
||||
fl = fls[-1][0 : -len(ext)] + ".pth"
|
||||
|
||||
return fl
|
||||
|
||||
@@ -62,7 +62,6 @@ 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]
|
||||
|
||||
@@ -218,7 +218,6 @@ def load_obj(
|
||||
"""
|
||||
data_dir = "./"
|
||||
if isinstance(f, (str, bytes, Path)):
|
||||
# pyre-fixme[6]: For 1st argument expected `PathLike[Variable[AnyStr <:
|
||||
# [str, bytes]]]` but got `Union[Path, bytes, str]`.
|
||||
data_dir = os.path.dirname(f)
|
||||
if path_manager is None:
|
||||
|
||||
@@ -122,16 +122,13 @@ def corresponding_cameras_alignment(
|
||||
|
||||
# create a new cameras object and set the R and T accordingly
|
||||
cameras_src_aligned = cameras_src.clone()
|
||||
# pyre-fixme[6]: For 2nd argument expected `Tensor` but got `Union[Tensor, Module]`.
|
||||
cameras_src_aligned.R = torch.bmm(align_t_R.expand_as(cameras_src.R), cameras_src.R)
|
||||
cameras_src_aligned.T = (
|
||||
torch.bmm(
|
||||
align_t_T[:, None].repeat(cameras_src.R.shape[0], 1, 1),
|
||||
# pyre-fixme[6]: For 2nd argument expected `Tensor` but got
|
||||
# `Union[Tensor, Module]`.
|
||||
cameras_src.R,
|
||||
)[:, 0]
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, other: Union[bool, complex,
|
||||
# float, int, Tensor]) -> Tensor, Tensor, Module]` is not a function.
|
||||
+ cameras_src.T * align_t_s
|
||||
)
|
||||
@@ -180,8 +177,6 @@ def _align_camera_extrinsics(
|
||||
R_A = (U V^T)^T
|
||||
```
|
||||
"""
|
||||
# pyre-fixme[6]: For 1st argument expected `Tensor` but got `Union[Tensor, Module]`.
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, dim0: int, dim1: int) -> Tensor,
|
||||
# Tensor, Module]` is not a function.
|
||||
RRcov = torch.bmm(cameras_src.R, cameras_tgt.R.transpose(2, 1)).mean(0)
|
||||
U, _, V = torch.svd(RRcov)
|
||||
@@ -212,11 +207,7 @@ def _align_camera_extrinsics(
|
||||
T_A = mean(B) - mean(A) * s_A
|
||||
```
|
||||
"""
|
||||
# pyre-fixme[6]: For 1st argument expected `Tensor` but got `Union[Tensor, Module]`.
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[Any, Any, ...
|
||||
A = torch.bmm(cameras_src.R, cameras_src.T[:, :, None])[:, :, 0]
|
||||
# pyre-fixme[6]: For 1st argument expected `Tensor` but got `Union[Tensor, Module]`.
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[Any, Any, ...
|
||||
B = torch.bmm(cameras_src.R, cameras_tgt.T[:, :, None])[:, :, 0]
|
||||
Amu = A.mean(0, keepdim=True)
|
||||
Bmu = B.mean(0, keepdim=True)
|
||||
|
||||
@@ -103,7 +103,6 @@ def cot_laplacian(
|
||||
s = 0.5 * (A + B + C)
|
||||
# note that the area can be negative (close to 0) causing nans after sqrt()
|
||||
# we clip it to a small positive value
|
||||
# pyre-fixme[16]: `float` has no attribute `clamp`.
|
||||
area = (s * (s - A) * (s - B) * (s - C)).clamp(min=eps).sqrt()
|
||||
|
||||
# Compute cotangents of angles, of shape (sum(F_n), 3)
|
||||
|
||||
@@ -156,7 +156,6 @@ 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]
|
||||
@@ -164,7 +163,6 @@ def estimate_pointcloud_local_coord_frames(
|
||||
)
|
||||
# disambiguate the main curvature
|
||||
z = _disambiguate_vector_directions(
|
||||
# pyrefly: ignore [unsupported-operation]
|
||||
points_centered,
|
||||
knns,
|
||||
# pyrefly: ignore [unsupported-operation]
|
||||
|
||||
@@ -168,9 +168,7 @@ def sample_farthest_points_naive(
|
||||
sample_idx_batch[0] = selected_idx
|
||||
|
||||
# If the pointcloud has fewer than K points then only iterate over the min
|
||||
# pyre-fixme[6]: For 1st param expected `SupportsRichComparisonT` but got
|
||||
# `Tensor`.
|
||||
# pyre-fixme[6]: For 2nd param expected `SupportsRichComparisonT` but got
|
||||
# `Tensor`.
|
||||
k_n = min(lengths[n], K[n])
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ def wmean(
|
||||
args = {"dim": dim, "keepdim": keepdim}
|
||||
|
||||
if weight is None:
|
||||
# pyre-fixme[6]: For 1st param expected `Optional[dtype]` but got
|
||||
# `Union[Tuple[int], int]`.
|
||||
return x.mean(**args)
|
||||
|
||||
@@ -101,7 +100,6 @@ def wmean(
|
||||
):
|
||||
raise ValueError("wmean: weights are not compatible with the tensor")
|
||||
|
||||
# pyre-fixme[6]: For 1st param expected `Optional[dtype]` but got
|
||||
# `Union[Tuple[int], int]`.
|
||||
return (x * weight[..., None]).sum(**args) / weight[..., None].sum(**args).clamp(
|
||||
eps
|
||||
|
||||
@@ -228,7 +228,6 @@ def softmax_rgb_blend(
|
||||
|
||||
# Also apply exp normalize trick for the background color weight.
|
||||
# Clamp to ensure delta is never 0.
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `float`.
|
||||
delta = torch.exp((eps - z_inv_max) / blend_params.gamma).clamp(min=eps)
|
||||
|
||||
# Normalize weights.
|
||||
|
||||
@@ -65,10 +65,8 @@ def _opencv_from_cameras_projection(
|
||||
cameras: PerspectiveCameras,
|
||||
image_size: torch.Tensor,
|
||||
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, memory_format:
|
||||
# Optional[memory_format] = ...) -> Tensor, Tensor, Module]` is not a function.
|
||||
R_pytorch3d = cameras.R.clone()
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, memory_format:
|
||||
# Optional[memory_format] = ...) -> Tensor, Tensor, Module]` is not a function.
|
||||
T_pytorch3d = cameras.T.clone()
|
||||
focal_pytorch3d = cameras.focal_length
|
||||
|
||||
@@ -230,9 +230,7 @@ class CamerasBase(TensorProperties):
|
||||
a Transform3d object which represents a batch of transforms
|
||||
of shape (N, 3, 3)
|
||||
"""
|
||||
# pyre-fixme[16]: `CamerasBase` has no attribute `R`.
|
||||
self.R: torch.Tensor = kwargs.get("R", self.R)
|
||||
# pyre-fixme[16]: `CamerasBase` has no attribute `T`.
|
||||
self.T: torch.Tensor = kwargs.get("T", self.T)
|
||||
world_to_view_transform = self.get_world_to_view_transform(R=self.R, T=self.T)
|
||||
view_to_proj_transform = self.get_projection_transform(**kwargs)
|
||||
@@ -409,9 +407,7 @@ class CamerasBase(TensorProperties):
|
||||
kwargs = {}
|
||||
|
||||
tensor_types = {
|
||||
# pyre-fixme[16]: Module `cuda` has no attribute `BoolTensor`.
|
||||
"bool": (torch.BoolTensor, torch.cuda.BoolTensor),
|
||||
# pyre-fixme[16]: Module `cuda` has no attribute `LongTensor`.
|
||||
"long": (torch.LongTensor, torch.cuda.LongTensor),
|
||||
}
|
||||
if not isinstance(
|
||||
@@ -429,13 +425,10 @@ class CamerasBase(TensorProperties):
|
||||
index = [index]
|
||||
|
||||
if isinstance(index, tensor_types["bool"]):
|
||||
# pyre-fixme[16]: Item `List` of `Union[List[int], BoolTensor,
|
||||
# LongTensor]` has no attribute `ndim`.
|
||||
# pyre-fixme[16]: Item `List` of `Union[List[int], BoolTensor,
|
||||
# LongTensor]` has no attribute `shape`.
|
||||
if index.ndim != 1 or index.shape[0] != len(self):
|
||||
raise ValueError(
|
||||
# pyre-fixme[16]: Item `List` of `Union[List[int], BoolTensor,
|
||||
# LongTensor]` has no attribute `shape`.
|
||||
f"Boolean index of shape {index.shape} does not match cameras"
|
||||
)
|
||||
@@ -1179,7 +1172,6 @@ class PerspectiveCameras(CamerasBase):
|
||||
|
||||
unprojection_transform = to_camera_transform.inverse()
|
||||
xy_inv_depth = torch.cat(
|
||||
# pyre-fixme[6]: For 1st argument expected `Union[List[Tensor],
|
||||
# tuple[Tensor, ...]]` but got `Tuple[Tensor, float]`.
|
||||
(xy_depth[..., :2], torch.reciprocal(xy_depth[..., 2:3])),
|
||||
dim=-1, # type: ignore
|
||||
@@ -1750,7 +1742,7 @@ def look_at_view_transform(
|
||||
elev, # pyrefly: ignore [bad-argument-type]
|
||||
azim, # pyrefly: ignore [bad-argument-type]
|
||||
degrees=degrees,
|
||||
device=device, # pyrefly: ignore [bad-argument-type]
|
||||
device=device,
|
||||
)
|
||||
+ at
|
||||
)
|
||||
|
||||
@@ -183,7 +183,6 @@ 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),
|
||||
|
||||
@@ -236,7 +236,6 @@ class MultinomialRaysampler(torch.nn.Module):
|
||||
# is not batched and does not support partial permutation
|
||||
_, width, height, _ = xy_grid.shape
|
||||
weights = xy_grid.new_ones(batch_size, width * height)
|
||||
# pyre-fixme[6]: For 2nd param expected `int` but got `Union[bool,
|
||||
# float, int]`.
|
||||
rays_idx = _safe_multinomial(weights, n_rays_per_image)[..., None].expand(
|
||||
-1, -1, 2
|
||||
|
||||
@@ -170,7 +170,6 @@ class ImplicitRenderer(torch.nn.Module):
|
||||
# given sampled rays, call the volumetric function that
|
||||
# evaluates the densities and features at the locations of the
|
||||
# ray points
|
||||
# pyre-fixme[23]: Unable to unpack `object` into 2 values.
|
||||
rays_densities, rays_features = volumetric_function(
|
||||
ray_bundle=ray_bundle, cameras=cameras, **kwargs
|
||||
)
|
||||
|
||||
@@ -496,7 +496,6 @@ 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]
|
||||
@@ -540,12 +539,10 @@ 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
|
||||
p, p_barycentric = _find_verts_intersecting_clipping_plane(
|
||||
# pyrefly: ignore [bad-argument-type]
|
||||
faces_case4,
|
||||
p1_face_ind,
|
||||
# pyrefly: ignore [bad-argument-type]
|
||||
|
||||
@@ -453,7 +453,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
|
||||
|
||||
@@ -537,7 +536,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(
|
||||
# pyrefly: ignore [bad-argument-type]
|
||||
self._atlas_padded,
|
||||
@@ -803,7 +801,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
|
||||
|
||||
@@ -840,7 +837,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:
|
||||
@@ -853,7 +849,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)
|
||||
|
||||
@@ -1099,7 +1094,6 @@ 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(
|
||||
# pyrefly: ignore [bad-argument-type]
|
||||
self._faces_uvs_padded,
|
||||
@@ -1132,7 +1126,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, missing-attribute]
|
||||
# pyrefly: ignore [missing-attribute]
|
||||
self._verts_uvs_list = list(self._verts_uvs_padded.unbind(0))
|
||||
# pyrefly: ignore [bad-return]
|
||||
return self._verts_uvs_list
|
||||
@@ -1755,7 +1749,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
|
||||
|
||||
@@ -1832,7 +1825,6 @@ 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(
|
||||
# pyrefly: ignore [bad-argument-type]
|
||||
self._verts_features_padded,
|
||||
|
||||
@@ -288,7 +288,6 @@ class _OpenGLMachinery:
|
||||
bary_coords = []
|
||||
zbufs = []
|
||||
|
||||
# pyre-ignore Incompatible parameter type [6]
|
||||
for mesh_id, mesh in enumerate(meshes_gl_ndc):
|
||||
pix_to_face, bary_coord, zbuf = self._rasterize_mesh(
|
||||
mesh,
|
||||
@@ -385,13 +384,11 @@ class _OpenGLMachinery:
|
||||
|
||||
# Free GL resources.
|
||||
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.fbo)
|
||||
# pyre-fixme[16]: Module `GL_3_0` has no attribute `glDeleteFramebuffers`.
|
||||
gl.glDeleteFramebuffers(1, [self.fbo])
|
||||
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
|
||||
del self.fbo
|
||||
|
||||
gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, self.mesh_buffer_object)
|
||||
# pyre-fixme[16]: Module `GL_1_5` has no attribute `glDeleteBuffers`.
|
||||
gl.glDeleteBuffers(1, [self.mesh_buffer_object])
|
||||
gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, 0)
|
||||
del self.mesh_buffer_object
|
||||
@@ -408,7 +405,6 @@ class _OpenGLMachinery:
|
||||
projection matrix: A 3x3 float tensor.
|
||||
"""
|
||||
gl.glUseProgram(self.program)
|
||||
# pyre-fixme[16]: Module `GL_2_0` has no attribute `glUniformMatrix4fv`.
|
||||
gl.glUniformMatrix4fv(
|
||||
self.perspective_projection_uniform,
|
||||
1,
|
||||
|
||||
@@ -471,7 +471,6 @@ 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(),
|
||||
|
||||
@@ -61,7 +61,6 @@ def _is_heterogeneous_ray_bundle(struct: Union[List[Struct], Struct]) -> bool:
|
||||
True if something is a HeterogeneousRayBundle or ImplicitronRayBundle
|
||||
and cant be reduced to RayBundle else False
|
||||
"""
|
||||
# pyre-ignore[16]
|
||||
return hasattr(struct, "camera_counts") and struct.camera_counts is not None
|
||||
|
||||
|
||||
@@ -586,15 +585,11 @@ def _add_struct_from_batch(
|
||||
if isinstance(batched_struct, CamerasBase):
|
||||
# we can't index directly into camera batches
|
||||
R, T = batched_struct.R, batched_struct.T
|
||||
# pyre-fixme[6]: For 1st argument expected
|
||||
# `pyre_extensions.PyreReadOnly[Sized]` but got `Union[Tensor, Module]`.
|
||||
r_idx = min(scene_num, len(R) - 1)
|
||||
# pyre-fixme[6]: For 1st argument expected
|
||||
# `pyre_extensions.PyreReadOnly[Sized]` but got `Union[Tensor, Module]`.
|
||||
t_idx = min(scene_num, len(T) - 1)
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[Any, A...
|
||||
R = R[r_idx].unsqueeze(0)
|
||||
# pyre-fixme[29]: `Union[(self: TensorBase, indices: Union[None, slice[Any, A...
|
||||
T = T[t_idx].unsqueeze(0)
|
||||
struct = CamerasBase(device=batched_struct.device, R=R, T=T)
|
||||
elif _is_ray_bundle(batched_struct) and not _is_heterogeneous_ray_bundle(
|
||||
@@ -616,7 +611,6 @@ def _add_struct_from_batch(
|
||||
struct = RayBundle(
|
||||
**{
|
||||
attr: getattr(batched_struct, attr)[
|
||||
# pyre-ignore[16]
|
||||
first_idxs[struct_idx] : first_idxs[struct_idx + 1]
|
||||
]
|
||||
for attr in ["origins", "directions", "lengths", "xys"]
|
||||
|
||||
@@ -59,7 +59,6 @@ def texturesuv_image_matplotlib(
|
||||
for i in indices:
|
||||
# setting clip_on=False makes it obvious when
|
||||
# we have UV coordinates outside the correct range
|
||||
# pyre-fixme[6]: For 1st argument expected `Tuple[float, float]` but got
|
||||
# `ndarray[Any, Any]`.
|
||||
ax.add_patch(Circle(centers[i], radius, color=color, clip_on=False))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user