Skip to content

Validate against expected files on videos #6077

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

Merged
merged 3 commits into from
May 24, 2022
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
Binary file added test/expect/ModelTester.test_mc3_18_expect.pkl
Binary file not shown.
Binary file added test/expect/ModelTester.test_r2plus1d_18_expect.pkl
Binary file not shown.
Binary file added test/expect/ModelTester.test_r3d_18_expect.pkl
Binary file not shown.
20 changes: 16 additions & 4 deletions test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,24 +822,36 @@ def test_detection_model_validation(model_fn):
@pytest.mark.parametrize("model_fn", get_models_from_module(models.video))
@pytest.mark.parametrize("dev", cpu_and_gpu())
def test_video_model(model_fn, dev):
set_rng_seed(0)
# the default input shape is
# bs * num_channels * clip_len * h *w
input_shape = (1, 3, 4, 112, 112)
defaults = {
"input_shape": (1, 3, 4, 112, 112),
"num_classes": 50,
}
model_name = model_fn.__name__
kwargs = {**defaults, **_model_params.get(model_name, {})}
num_classes = kwargs.get("num_classes")
input_shape = kwargs.pop("input_shape")
# test both basicblock and Bottleneck
model = model_fn(num_classes=50)
model = model_fn(**kwargs)
model.eval().to(device=dev)
# RNG always on CPU, to ensure x in cuda tests is bitwise identical to x in cpu tests
x = torch.rand(input_shape).to(device=dev)
out = model(x)
_assert_expected(out.cpu(), model_name, prec=0.1)
assert out.shape[-1] == num_classes
_check_jit_scriptable(model, (x,), unwrapper=script_model_unwrapper.get(model_name, None), eager_out=out)
_check_fx_compatible(model, x, eager_out=out)
assert out.shape[-1] == 50
assert out.shape[-1] == num_classes

if dev == "cuda":
with torch.cuda.amp.autocast():
out = model(x)
assert out.shape[-1] == 50
# See autocast_flaky_numerics comment at top of file.
if model_name not in autocast_flaky_numerics:
_assert_expected(out.cpu(), model_name, prec=0.1)
assert out.shape[-1] == num_classes

_check_input_backprop(model, x)

Expand Down