Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression test for missing frames after exporting a CVAT dataset #8827

Merged
merged 12 commits into from
Dec 19, 2024
Prev Previous commit
Next Next commit
factor out end_frame calculations to utils
  • Loading branch information
Oleg Valiulin committed Dec 19, 2024
commit d9f0d5f6764dde6811bb2c0d9da9fda9672a1c48
8 changes: 3 additions & 5 deletions tests/python/rest_api/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
export_task_dataset,
parse_frame_step,
wait_until_task_is_created,
calc_end_frame,
)


Expand Down Expand Up @@ -3111,7 +3112,7 @@ def _compute_annotation_segment_params(self, task_spec: _TaskSpec) -> list[tuple
stop_frame = getattr(task_spec, "stop_frame", None) or (
start_frame + (task_spec.size - 1) * frame_step
)
end_frame = stop_frame - ((stop_frame - start_frame) % frame_step) + frame_step
end_frame = calc_end_frame(start_frame, stop_frame, frame_step)

validation_params = getattr(task_spec, "validation_params", None)
if validation_params and validation_params.mode.value == "gt_pool":
Expand Down Expand Up @@ -6410,10 +6411,7 @@ def get_img_index(zinfo: zipfile.ZipInfo) -> int:
task_meta["stop_frame"],
spec.frame_step,
)
src_end_frame = (
src_stop_frame - ((src_stop_frame - src_start_frame) % src_frame_step) + src_frame_step
) # taken from TestTaskData._compute_annotation_segment_params

src_end_frame = calc_end_frame(src_start_frame, src_stop_frame, src_frame_step)
assert len(frames) == spec.size == task_meta["size"], "Some frames were lost"
assert np.all(
frames == np.arange(src_start_frame, src_end_frame, src_frame_step)
Expand Down
4 changes: 4 additions & 0 deletions tests/python/rest_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,7 @@ def _exclude_cb(obj, path):

def parse_frame_step(frame_filter: str) -> int:
return int((frame_filter or "step=1").split("=")[1])


def calc_end_frame(start_frame: int, stop_frame: int, frame_step: int) -> int:
return stop_frame - ((stop_frame - start_frame) % frame_step) + frame_step
Loading