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 EMAHead
|
|
|
|
from .utils import to_cuda
|
|
|
|
|
|
|
|
|
|
|
|
def test_emanet_head():
|
|
|
|
head = EMAHead(
|
2021-11-01 22:47:43 +08:00
|
|
|
in_channels=4,
|
|
|
|
ema_channels=3,
|
|
|
|
channels=2,
|
2021-03-31 08:55:09 +08:00
|
|
|
num_stages=3,
|
2021-11-01 22:47:43 +08:00
|
|
|
num_bases=2,
|
2021-03-31 08:55:09 +08:00
|
|
|
num_classes=19)
|
|
|
|
for param in head.ema_mid_conv.parameters():
|
|
|
|
assert not param.requires_grad
|
|
|
|
assert hasattr(head, 'ema_module')
|
2021-11-01 22:47:43 +08:00
|
|
|
inputs = [torch.randn(1, 4, 23, 23)]
|
2021-03-31 08:55:09 +08:00
|
|
|
if torch.cuda.is_available():
|
|
|
|
head, inputs = to_cuda(head, inputs)
|
|
|
|
outputs = head(inputs)
|
2021-11-01 22:47:43 +08:00
|
|
|
assert outputs.shape == (1, head.num_classes, 23, 23)
|