From bfbed072a07a6a52c8d5fdc75a7a186251a835b1 Mon Sep 17 00:00:00 2001 From: generatedunixname26232875646305581 Date: Tue, 31 Mar 2026 03:16:31 -0700 Subject: [PATCH] Daily `arc lint --take BLACK` Differential Revision: D98889675 fbshipit-source-id: e9d0089e5abb73b9327f5453ad20fa5060b12a40 --- sam3/model/video_tracking_multiplex_demo.py | 6 +-- sam3/train/data/coco_json_loaders.py | 6 +-- sam3/train/trainer.py | 42 ++++++++++----------- scripts/eval/silver/download_videos.py | 6 +-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sam3/model/video_tracking_multiplex_demo.py b/sam3/model/video_tracking_multiplex_demo.py index c572577..067907c 100644 --- a/sam3/model/video_tracking_multiplex_demo.py +++ b/sam3/model/video_tracking_multiplex_demo.py @@ -1734,9 +1734,9 @@ class VideoTrackingMultiplexDemo(VideoTrackingDynamicMultiplex): ) inference_state["multiplex_state"] = multiplex_state else: - assert ( - self.is_dynamic_model - ), "New objects are not allowed after state creation" + assert self.is_dynamic_model, ( + "New objects are not allowed after state creation" + ) for i in range(num_objects): mask_inputs_per_frame[i][frame_idx] = mask_inputs_video_res[i : i + 1] diff --git a/sam3/train/data/coco_json_loaders.py b/sam3/train/data/coco_json_loaders.py index 1618e19..d39b6f4 100644 --- a/sam3/train/data/coco_json_loaders.py +++ b/sam3/train/data/coco_json_loaders.py @@ -142,9 +142,9 @@ class COCO_FROM_JSON: self.prompts = {} for loc_dict in prompts: self.prompts[int(loc_dict["id"])] = loc_dict["name"] - assert len(self.prompts) == len( - self._sorted_cat_ids - ), "Number of prompts must match number of categories" + assert len(self.prompts) == len(self._sorted_cat_ids), ( + "Number of prompts must match number of categories" + ) def getDatapointIds(self): """Return all datapoint indices for training.""" diff --git a/sam3/train/trainer.py b/sam3/train/trainer.py index 5a37886..cc6c37e 100644 --- a/sam3/train/trainer.py +++ b/sam3/train/trainer.py @@ -209,9 +209,9 @@ class Trainer: set_seeds(seed_value, self.max_epochs, self.distributed_rank) log_env_variables() - assert ( - is_dist_avail_and_initialized() - ), "Torch distributed needs to be initialized before calling the trainer." + assert is_dist_avail_and_initialized(), ( + "Torch distributed needs to be initialized before calling the trainer." + ) self._setup_components() # Except Optimizer everything is setup here. self._move_to_device() @@ -221,9 +221,9 @@ class Trainer: self.time_elapsed_meter = DurationMeter("Time Elapsed", self.device, ":.2f") if self.checkpoint_conf.resume_from is not None: - assert os.path.exists( - self.checkpoint_conf.resume_from - ), f"The 'resume_from' checkpoint {self.checkpoint_conf.resume_from} does not exist!" + assert os.path.exists(self.checkpoint_conf.resume_from), ( + f"The 'resume_from' checkpoint {self.checkpoint_conf.resume_from} does not exist!" + ) dst = os.path.join(self.checkpoint_conf.save_dir, "checkpoint.pt") if self.distributed_rank == 0 and not os.path.exists(dst): # Copy the "resume_from" checkpoint to the checkpoint folder @@ -471,9 +471,9 @@ class Trainer: return self.loss[key] assert key != "all", "Loss must be specified for key='all'" - assert ( - "default" in self.loss - ), f"Key {key} not found in losss, and no default provided" + assert "default" in self.loss, ( + f"Key {key} not found in losss, and no default provided" + ) return self.loss["default"] def _find_meter(self, phase: str, key: str): @@ -916,12 +916,12 @@ class Trainer: self.optim.zero_grad(set_to_none=True) if self.gradient_accumulation_steps > 1: - assert isinstance( - batch, list - ), f"Expected a list of batches, got {type(batch)}" - assert ( - len(batch) == self.gradient_accumulation_steps - ), f"Expected {self.gradient_accumulation_steps} batches, got {len(batch)}" + assert isinstance(batch, list), ( + f"Expected a list of batches, got {type(batch)}" + ) + assert len(batch) == self.gradient_accumulation_steps, ( + f"Expected {self.gradient_accumulation_steps} batches, got {len(batch)}" + ) accum_steps = len(batch) else: accum_steps = 1 @@ -1033,9 +1033,9 @@ class Trainer: def _check_val_key_match(self, val_keys, phase): if val_keys is not None: # Check if there are any duplicates - assert len(val_keys) == len( - set(val_keys) - ), f"Duplicate keys in val datasets, keys: {val_keys}" + assert len(val_keys) == len(set(val_keys)), ( + f"Duplicate keys in val datasets, keys: {val_keys}" + ) # Check that the keys match the meter keys if self.meters_conf is not None and phase in self.meters_conf: @@ -1049,9 +1049,9 @@ class Trainer: loss_keys = set(self.loss_conf.keys()) - set(["all"]) if "default" not in loss_keys: for k in val_keys: - assert ( - k in loss_keys - ), f"Error: key {k} is not defined in the losses, and no default is set" + assert k in loss_keys, ( + f"Error: key {k} is not defined in the losses, and no default is set" + ) def _setup_components(self): # Get the keys for all the val datasets, if any diff --git a/scripts/eval/silver/download_videos.py b/scripts/eval/silver/download_videos.py index 9b6f873..d0a1ba8 100644 --- a/scripts/eval/silver/download_videos.py +++ b/scripts/eval/silver/download_videos.py @@ -243,9 +243,9 @@ def download_sav(): def main(): assert len(sys.argv) > 1, "You have to provide the name of the dataset" dataset_name = sys.argv[1] - assert ( - dataset_name in annotation_files - ), f"The dataset can be one of {list(annotation_files.keys())}" + assert dataset_name in annotation_files, ( + f"The dataset can be one of {list(annotation_files.keys())}" + ) if dataset_name == "yt1b": download_youtube()