2021-08-17 14:16:55 +08:00
|
|
|
# Copyright (c) OpenMMLab. All rights reserved.
|
2021-03-31 08:55:09 +08:00
|
|
|
import torch
|
|
|
|
|
|
|
|
from mmseg.models.decode_heads import DAHead
|
|
|
|
from .utils import to_cuda
|
|
|
|
|
|
|
|
|
|
|
|
def test_da_head():
|
|
|
|
|
2021-11-01 22:47:43 +08:00
|
|
|
inputs = [torch.randn(1, 16, 23, 23)]
|
|
|
|
head = DAHead(in_channels=16, channels=8, num_classes=19, pam_channels=8)
|
2021-03-31 08:55:09 +08:00
|
|
|
if torch.cuda.is_available():
|
|
|
|
head, inputs = to_cuda(head, inputs)
|
|
|
|
outputs = head(inputs)
|
|
|
|
assert isinstance(outputs, tuple) and len(outputs) == 3
|
|
|
|
for output in outputs:
|
2021-11-01 22:47:43 +08:00
|
|
|
assert output.shape == (1, head.num_classes, 23, 23)
|
2021-03-31 08:55:09 +08:00
|
|
|
test_output = head.forward_test(inputs, None, None)
|
2021-11-01 22:47:43 +08:00
|
|
|
assert test_output.shape == (1, head.num_classes, 23, 23)
|