"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "80ff4ba63eb95400e01626c1767c4e3b9b1cc4aa"
Unverified Commit aec38fc2 authored by vfdev's avatar vfdev Committed by GitHub
Browse files

[proto][tests] added ref tests for resize bboxes (#6879)

parent 1502ed9a
......@@ -288,6 +288,31 @@ def sample_inputs_resize_video():
yield ArgsKwargs(video_loader, size=[min(video_loader.shape[-2:]) + 1])
def reference_resize_bounding_box(bounding_box, *, spatial_size, size, max_size=None):
old_height, old_width = spatial_size
new_height, new_width = F._geometry._compute_resized_output_size(spatial_size, size=size, max_size=max_size)
affine_matrix = np.array(
[
[new_width / old_width, 0, 0],
[0, new_height / old_height, 0],
],
dtype="float32",
)
expected_bboxes = reference_affine_bounding_box_helper(
bounding_box, format=bounding_box.format, affine_matrix=affine_matrix
)
return expected_bboxes, (new_height, new_width)
def reference_inputs_resize_bounding_box():
for bounding_box_loader in make_bounding_box_loaders(extra_dims=((), (4,))):
for size in _get_resize_sizes(bounding_box_loader.spatial_size):
yield ArgsKwargs(bounding_box_loader, size=size, spatial_size=bounding_box_loader.spatial_size)
KERNEL_INFOS.extend(
[
KernelInfo(
......@@ -303,6 +328,8 @@ KERNEL_INFOS.extend(
KernelInfo(
F.resize_bounding_box,
sample_inputs_fn=sample_inputs_resize_bounding_box,
reference_fn=reference_resize_bounding_box,
reference_inputs_fn=reference_inputs_resize_bounding_box,
test_marks=[
xfail_jit_python_scalar_arg("size"),
],
......@@ -459,7 +486,7 @@ def reference_affine_bounding_box_helper(bounding_box, *, format, affine_matrix)
],
)
out_bbox = F.convert_format_bounding_box(
out_bbox, old_format=features.BoundingBoxFormat.XYXY, new_format=format, inplace=True
out_bbox, old_format=features.BoundingBoxFormat.XYXY, new_format=format_, inplace=True
)
return out_bbox.to(dtype=in_dtype)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment