You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_model_misc.py 805 B

2 years ago
123456789101112131415161718192021222324252627
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. import numpy as np
  3. import torch
  4. from mmdet.models.utils import interpolate_as
  5. def test_interpolate_as():
  6. source = torch.rand((1, 5, 4, 4))
  7. target = torch.rand((1, 1, 16, 16))
  8. # Test 4D source and target
  9. result = interpolate_as(source, target)
  10. assert result.shape == torch.Size((1, 5, 16, 16))
  11. # Test 3D target
  12. result = interpolate_as(source, target.squeeze(0))
  13. assert result.shape == torch.Size((1, 5, 16, 16))
  14. # Test 3D source
  15. result = interpolate_as(source.squeeze(0), target)
  16. assert result.shape == torch.Size((5, 16, 16))
  17. # Test type(target) == np.ndarray
  18. target = np.random.rand(16, 16)
  19. result = interpolate_as(source.squeeze(0), target)
  20. assert result.shape == torch.Size((5, 16, 16))

No Description

Contributors (1)