Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion benchmark/benchmark_vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})


Expand Down
4 changes: 3 additions & 1 deletion mblt_vision/_hub_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
28 changes: 21 additions & 7 deletions mblt_vision/image_classification/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
6 changes: 5 additions & 1 deletion mblt_vision/utils/datasets/readiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion mblt_vision/utils/datasets/reid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion mblt_vision/utils/postprocess/embedding_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 4 additions & 0 deletions tests/reference/ops_reid_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_reid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading