Update tests for bboxes in kornia 0.6.3 (#381)

* Update tests for newest version of kornia

* Comments explaining the bounding box format
This commit is contained in:
Caleb Robinson 2022-01-31 23:56:07 +00:00 коммит произвёл GitHub
Родитель 3f7e525fbd
Коммит d79cd18952
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 24 удалений

Просмотреть файл

@ -12,22 +12,7 @@ from torch import Tensor
from torchgeo.transforms import indices, transforms
# Tests require newer version of Kornia for newer bounding box behavior
pytest.importorskip("kornia", minversion="0.6.2")
@pytest.fixture
def sample() -> Dict[str, Tensor]:
return {
"image": torch.tensor( # type: ignore[attr-defined]
[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
),
"mask": torch.tensor( # type: ignore[attr-defined]
[[0, 0, 1], [0, 1, 1], [1, 1, 1]]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[0, 0, 2, 2], [1, 1, 3, 3]]]
),
}
pytest.importorskip("kornia", minversion="0.6.3")
@pytest.fixture
@ -41,8 +26,10 @@ def batch_gray() -> Dict[str, Tensor]:
[[[[0, 0, 1], [0, 1, 1], [1, 1, 1]]]],
dtype=torch.long, # type: ignore[attr-defined]
),
# This is a list of 4 (y,x) points of the corners of a bounding box.
# kornia expects something with (B, 4, 2) shape
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[0, 0, 0, 0], [1, 1, 2, 2]]],
[[[0, 0], [0, 1], [1, 1], [1, 0]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -67,7 +54,7 @@ def batch_rgb() -> Dict[str, Tensor]:
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[0, 0, 0, 0], [1, 1, 2, 2]]],
[[[0, 0], [0, 1], [1, 1], [1, 0]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -94,7 +81,7 @@ def batch_multispectral() -> Dict[str, Tensor]:
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[0, 0, 0, 0], [1, 1, 2, 2]]],
[[[0, 0], [0, 1], [1, 1], [1, 0]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -119,7 +106,7 @@ def test_augmentation_sequential_gray(batch_gray: Dict[str, Tensor]) -> None:
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[2, 0, 2, 0], [0, 1, 1, 2]]],
[[[1, 0], [2, 0], [2, 1], [1, 1]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -148,7 +135,7 @@ def test_augmentation_sequential_rgb(batch_rgb: Dict[str, Tensor]) -> None:
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[2, 0, 2, 0], [0, 1, 1, 2]]],
[[[1, 0], [2, 0], [2, 1], [1, 1]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -181,7 +168,7 @@ def test_augmentation_sequential_multispectral(
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[2, 0, 2, 0], [0, 1, 1, 2]]],
[[[1, 0], [2, 0], [2, 1], [1, 1]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -214,7 +201,7 @@ def test_augmentation_sequential_image_only(
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[0, 0, 0, 0], [1, 1, 2, 2]]],
[[[0, 0], [0, 1], [1, 1], [1, 0]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]
@ -252,7 +239,7 @@ def test_sequential_transforms_augmentations(
dtype=torch.long, # type: ignore[attr-defined]
),
"boxes": torch.tensor( # type: ignore[attr-defined]
[[[2, 0, 2, 0], [0, 1, 1, 2]]],
[[[1, 0], [2, 0], [2, 1], [1, 1]]],
dtype=torch.float, # type: ignore[attr-defined]
),
"labels": torch.tensor([[0, 1]]), # type: ignore[attr-defined]