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

Improve util error messages and fixed snapshot updates in certain cases #220

Merged
merged 1 commit into from
Mar 27, 2024
Merged
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
17 changes: 14 additions & 3 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ def assert_image_inference(
assert expected_path.exists(), f"Expected {expected_path} to exist."
expected = read_image(expected_path)

if expected.shape != output.shape and update_mode:
# update the snapshot
write_image(expected_path, output)
continue

# Assert that the images are the same within a certain tolerance
# The CI for some reason has a bit of FP precision loss compared to my local machine
# Therefore, a tolerance of 1 is fine enough.
Expand Down Expand Up @@ -474,9 +479,15 @@ def test_size(width: int, height: int) -> None:
with torch.no_grad():
output_tensor = model(input_tensor.to(device))

assert output_tensor.shape[1] == model.output_channels, "Incorrect channels"
assert output_tensor.shape[2] == height * model.scale, "Incorrect height"
assert output_tensor.shape[3] == width * model.scale, "Incorrect width"
expected_shape = (
1,
model.output_channels,
height * model.scale,
width * model.scale,
)
assert (
output_tensor.shape == expected_shape
), f"Expected {expected_shape}, but got {output_tensor.shape}"
except Exception as e:
raise AssertionError(
f"Failed size requirement test for {width=} {height=}"
Expand Down
Loading