From 2b8e5a56a8f0be2f2a9a957bcc7ebefbeba63a49 Mon Sep 17 00:00:00 2001 From: shaoxiongduan Date: Wed, 6 May 2026 00:51:00 +0000 Subject: [PATCH] [refactor] eval: drop batch_unit/trial_forward from remaining metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completes the d1bc1413 cleanup pass on the five files that were skipped because dataloader had pending modifications. With those modifications now landed (commits 7cdbcc94 + c2a22560), the dead code in optical_flow + the four aux-using vbench metrics (color/multiple_objects/object_class/spatial_relationship) can go. Mechanical removal of batch_unit class attrs and trial_forward method overrides — neither is read anywhere since calibrate() was deleted in 502f061d. Parity verified on fs-mbz-gpu-085: byte-identical to v3 baseline. --- .../eval/metrics/common/optical_flow/metric.py | 17 ----------------- fastvideo/eval/metrics/vbench/color/metric.py | 1 - .../metrics/vbench/multiple_objects/metric.py | 1 - .../eval/metrics/vbench/object_class/metric.py | 1 - .../vbench/spatial_relationship/metric.py | 1 - 5 files changed, 21 deletions(-) diff --git a/fastvideo/eval/metrics/common/optical_flow/metric.py b/fastvideo/eval/metrics/common/optical_flow/metric.py index 9b158463e..6e74cf3d3 100644 --- a/fastvideo/eval/metrics/common/optical_flow/metric.py +++ b/fastvideo/eval/metrics/common/optical_flow/metric.py @@ -251,7 +251,6 @@ class OpticalFlowMetric(BaseMetric): needs_gpu = True backbone = "optical_flow" dependencies = ["ptlflow"] - batch_unit = "frame_pair" def __init__( self, @@ -284,22 +283,6 @@ class OpticalFlowMetric(BaseMetric): self._model.eval() self._model = self._model.to(self.device) - def trial_forward(self, batch_size, *, height, width, num_frames): - from ptlflow.utils.io_adapter import IOAdapter - io_adapter = IOAdapter( - output_stride=self._model.output_stride, - input_size=(height, width), - cuda=(self.device.type == "cuda"), - ) - dummy_bgr = np.random.randint(0, 255, (height, width, 3), dtype=np.uint8) - pair_tensors = [] - for _ in range(batch_size): - inputs = io_adapter.prepare_inputs([dummy_bgr, dummy_bgr]) - pair_tensors.append(inputs["images"]) - batched = torch.cat(pair_tensors, dim=0) - with torch.no_grad(): - self._model({"images": batched}) - def _compute_flows_batched( self, pair_frames: list[tuple[np.ndarray, np.ndarray]], io_adapter, ) -> list[np.ndarray]: diff --git a/fastvideo/eval/metrics/vbench/color/metric.py b/fastvideo/eval/metrics/vbench/color/metric.py index 58618c5d6..6c7a9a246 100644 --- a/fastvideo/eval/metrics/vbench/color/metric.py +++ b/fastvideo/eval/metrics/vbench/color/metric.py @@ -26,7 +26,6 @@ class ColorMetric(BaseMetric): requires_reference = False higher_is_better = True needs_gpu = True - batch_unit = "video" dependencies = ["detectron2"] def __init__(self) -> None: diff --git a/fastvideo/eval/metrics/vbench/multiple_objects/metric.py b/fastvideo/eval/metrics/vbench/multiple_objects/metric.py index 78e854e44..ac8bdac83 100644 --- a/fastvideo/eval/metrics/vbench/multiple_objects/metric.py +++ b/fastvideo/eval/metrics/vbench/multiple_objects/metric.py @@ -20,7 +20,6 @@ class MultipleObjectsMetric(BaseMetric): requires_reference = False higher_is_better = True needs_gpu = True - batch_unit = "video" dependencies = ["detectron2"] def __init__(self) -> None: diff --git a/fastvideo/eval/metrics/vbench/object_class/metric.py b/fastvideo/eval/metrics/vbench/object_class/metric.py index aa8eba8a6..7fb092c21 100644 --- a/fastvideo/eval/metrics/vbench/object_class/metric.py +++ b/fastvideo/eval/metrics/vbench/object_class/metric.py @@ -20,7 +20,6 @@ class ObjectClassMetric(BaseMetric): requires_reference = False higher_is_better = True needs_gpu = True - batch_unit = "video" dependencies = ["detectron2"] def __init__(self) -> None: diff --git a/fastvideo/eval/metrics/vbench/spatial_relationship/metric.py b/fastvideo/eval/metrics/vbench/spatial_relationship/metric.py index 7fd119bc3..4b6ab8572 100644 --- a/fastvideo/eval/metrics/vbench/spatial_relationship/metric.py +++ b/fastvideo/eval/metrics/vbench/spatial_relationship/metric.py @@ -57,7 +57,6 @@ class SpatialRelationshipMetric(BaseMetric): requires_reference = False higher_is_better = True needs_gpu = True - batch_unit = "video" dependencies = ["detectron2"] def __init__(self) -> None: