diff --git a/benchmark/benchmark_vision_models.py b/benchmark/benchmark_vision_models.py index 61aeb17..a4bd29b 100644 --- a/benchmark/benchmark_vision_models.py +++ b/benchmark/benchmark_vision_models.py @@ -36,7 +36,9 @@ tuple[CoreMode, ...], core_modes_for_target_device("aries-rb") ) # Utility-only embedding tasks have no benchmark engine/CLI route yet. -TASK_CHOICES = tuple(task for task in VISION_TASKS if task not in {"person_reid", "face_recognition"}) +TASK_CHOICES = tuple( + task for task in VISION_TASKS if task not in {"person_reid", "face_recognition"} +) SUPPORTED_TARGET_DEVICES = frozenset({"aries-rb", "regulus-ra", "regulus-rb"}) diff --git a/mblt_vision/_hub_validation.py b/mblt_vision/_hub_validation.py index 4c1862a..4631aec 100644 --- a/mblt_vision/_hub_validation.py +++ b/mblt_vision/_hub_validation.py @@ -59,7 +59,9 @@ def check_hub_artifacts( "Hub verification requires nonempty repo_id and revision strings." ) board = normalize_target_device( - files.get("target_device", "aries-rb") if target_device is None else target_device + files.get("target_device", "aries-rb") + if target_device is None + else target_device ) paths = [] for framework in dict.fromkeys(frameworks): diff --git a/mblt_vision/image_classification/__init__.py b/mblt_vision/image_classification/__init__.py index 4bcab7c..29d96ac 100644 --- a/mblt_vision/image_classification/__init__.py +++ b/mblt_vision/image_classification/__init__.py @@ -197,21 +197,35 @@ LeViT_192 = create_model_class("LeViT_192", __name__) LeViT_256 = create_model_class("LeViT_256", __name__) LeViT_384 = create_model_class("LeViT_384", __name__) -ViT_RelPos_Medium_Patch16_RPN_224 = create_model_class("ViT_RelPos_Medium_Patch16_RPN_224", __name__) -ViT_RelPos_Base_Patch32_Plus_RPN_256 = create_model_class("ViT_RelPos_Base_Patch32_Plus_RPN_256", __name__) +ViT_RelPos_Medium_Patch16_RPN_224 = create_model_class( + "ViT_RelPos_Medium_Patch16_RPN_224", __name__ +) +ViT_RelPos_Base_Patch32_Plus_RPN_256 = create_model_class( + "ViT_RelPos_Base_Patch32_Plus_RPN_256", __name__ +) ViT_Base_Patch16_RPN_224 = create_model_class("ViT_Base_Patch16_RPN_224", __name__) ViT_Base_Patch16_CLIP_224 = create_model_class("ViT_Base_Patch16_CLIP_224", __name__) ViT_Base_Patch32_CLIP_448 = create_model_class("ViT_Base_Patch32_CLIP_448", __name__) ViT_Medium_Patch16_GAP_256 = create_model_class("ViT_Medium_Patch16_GAP_256", __name__) ViT_Large_Patch14_CLIP_224 = create_model_class("ViT_Large_Patch14_CLIP_224", __name__) ViT_Base_Patch32_CLIP_224 = create_model_class("ViT_Base_Patch32_CLIP_224", __name__) -ViT_RelPos_Small_Patch16_224 = create_model_class("ViT_RelPos_Small_Patch16_224", __name__) +ViT_RelPos_Small_Patch16_224 = create_model_class( + "ViT_RelPos_Small_Patch16_224", __name__ +) ViT_Base_Patch32_CLIP_384 = create_model_class("ViT_Base_Patch32_CLIP_384", __name__) -ViT_SRelPos_Medium_Patch16_224 = create_model_class("ViT_SRelPos_Medium_Patch16_224", __name__) +ViT_SRelPos_Medium_Patch16_224 = create_model_class( + "ViT_SRelPos_Medium_Patch16_224", __name__ +) ViT_Huge_Patch14_CLIP_224 = create_model_class("ViT_Huge_Patch14_CLIP_224", __name__) -ViT_RelPos_Base_Patch16_224 = create_model_class("ViT_RelPos_Base_Patch16_224", __name__) -ViT_RelPos_Medium_Patch16_224 = create_model_class("ViT_RelPos_Medium_Patch16_224", __name__) -ViT_SRelPos_Small_Patch16_224 = create_model_class("ViT_SRelPos_Small_Patch16_224", __name__) +ViT_RelPos_Base_Patch16_224 = create_model_class( + "ViT_RelPos_Base_Patch16_224", __name__ +) +ViT_RelPos_Medium_Patch16_224 = create_model_class( + "ViT_RelPos_Medium_Patch16_224", __name__ +) +ViT_SRelPos_Small_Patch16_224 = create_model_class( + "ViT_SRelPos_Small_Patch16_224", __name__ +) AlexNet = create_model_class("AlexNet", __name__) CAFormer_B36 = create_model_class("CAFormer_B36", __name__) CAFormer_M36 = create_model_class("CAFormer_M36", __name__) diff --git a/mblt_vision/utils/datasets/readiness.py b/mblt_vision/utils/datasets/readiness.py index 3e7d89f..188b215 100644 --- a/mblt_vision/utils/datasets/readiness.py +++ b/mblt_vision/utils/datasets/readiness.py @@ -1072,7 +1072,11 @@ def _reid_ready(root: Path, dataset: str) -> bool: def _face_ready(root: Path, dataset: str) -> bool: """Validate prepared aligned pairs and image decoding, never realign crops.""" - loader = {"lfw": LFWDataset, "agedb-30": AgeDB30Dataset, "cfp-fp": CFPFPDataset}.get(dataset) + loader = { + "lfw": LFWDataset, + "agedb-30": AgeDB30Dataset, + "cfp-fp": CFPFPDataset, + }.get(dataset) if ( loader is None or _path_has_symlink_component(root) diff --git a/mblt_vision/utils/datasets/reid.py b/mblt_vision/utils/datasets/reid.py index c5bca16..cfe3296 100644 --- a/mblt_vision/utils/datasets/reid.py +++ b/mblt_vision/utils/datasets/reid.py @@ -56,7 +56,9 @@ def __init__( ) pid, camera = map(int, match.groups()) if pid < -1: - raise ValueError(f"Unsupported negative person identity {pid}: {path}") + raise ValueError( + f"Unsupported negative person identity {pid}: {path}" + ) if pid == -1: if self.config["skip_junk"]: continue diff --git a/mblt_vision/utils/postprocess/embedding_post.py b/mblt_vision/utils/postprocess/embedding_post.py index 4a449a1..535526c 100644 --- a/mblt_vision/utils/postprocess/embedding_post.py +++ b/mblt_vision/utils/postprocess/embedding_post.py @@ -92,5 +92,7 @@ def __init__(self, pre_cfg: dict, post_cfg: dict) -> None: super().__init__(pre_cfg, post_cfg) dataset = post_cfg.get("dataset") if not isinstance(dataset, str) or not dataset: - raise ValueError("Face recognition postprocessing requires post_cfg.dataset") + raise ValueError( + "Face recognition postprocessing requires post_cfg.dataset" + ) self.dataset = get_dataset_config_for_task("face_recognition", dataset)["name"] diff --git a/tests/reference/ops_reid_metrics.py b/tests/reference/ops_reid_metrics.py index 78f10fa..ea52304 100644 --- a/tests/reference/ops_reid_metrics.py +++ b/tests/reference/ops_reid_metrics.py @@ -2,9 +2,12 @@ ec537764e36ca10da963fcb7afab157ea60ca022 (mblt-model-ops). Snapshot permits ordinary offline differential tests without sibling repos. """ + import numpy as np + MAX_RANK = 50 + def euclidean_distance(query: np.ndarray, gallery: np.ndarray) -> np.ndarray: """Squared euclidean distance, the reference ``euclidean_distance`` without the sqrt. @@ -16,6 +19,7 @@ def euclidean_distance(query: np.ndarray, gallery: np.ndarray) -> np.ndarray: g2 = np.sum(gallery**2, axis=1, keepdims=True).T return q2 + g2 - 2.0 * (query @ gallery.T) + def evaluate( distmat: np.ndarray, q_pids: np.ndarray, diff --git a/tests/test_reid.py b/tests/test_reid.py index f0cd0f1..6a1178f 100644 --- a/tests/test_reid.py +++ b/tests/test_reid.py @@ -112,7 +112,9 @@ def test_loader_metadata_and_source(tmp_path, dataset, loader): assert cfg["eval_protocol"]["id"] == cfg["evaluation"]["protocol"] -@pytest.mark.parametrize("filename", ["bad.jpg", "1_c9_bad.jpg", "-1_c1_junk.jpg", "-2_c1_bad.jpg"]) +@pytest.mark.parametrize( + "filename", ["bad.jpg", "1_c9_bad.jpg", "-1_c1_junk.jpg", "-2_c1_bad.jpg"] +) def test_duke_invalid_names(tmp_path, filename): (tmp_path / "query").mkdir() (tmp_path / "bounding_box_test").mkdir() diff --git a/tests/test_results.py b/tests/test_results.py index 6107475..1878f9f 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -63,7 +63,9 @@ def test_instance_segmentation_plot_supports_nonzero_coco_labels( cv2.imwrite(str(source_path), image) monkeypatch.setattr(results_module, "scale_boxes", lambda *args, **kwargs: args[1]) - monkeypatch.setattr(results_module, "scale_masks", lambda mask, img0_shape, **kwargs: mask) + monkeypatch.setattr( + results_module, "scale_masks", lambda mask, img0_shape, **kwargs: mask + ) monkeypatch.setattr(results_module, "crop_mask", lambda mask, boxes: mask) box_cls = torch.tensor([[4.0, 6.0, 20.0, 24.0, 0.9, 45.0]], dtype=torch.float32)