repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
RSP | RSP-main/Semantic Segmentation/tests/test_metrics.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
from mmseg.core.evaluation import (eval_metrics, mean_dice, mean_fscore,
mean_iou)
from mmseg.core.evaluation.metrics import f_score
def get_confusion_matrix(pred_label, label, num_classes, ignore_index):
"""Int... | 13,239 | 36.720798 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_forward.py | # Copyright (c) OpenMMLab. All rights reserved.
"""pytest tests/test_forward.py."""
import copy
from os.path import dirname, exists, join
from unittest.mock import patch
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.cnn.utils import revert_sync_batchnorm
def _demo_mm_inputs(input_shap... | 6,534 | 26.690678 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_twins.py | import pytest
import torch
from mmseg.models.backbones.twins import (PCPVT, SVT,
ConditionalPositionEncoding,
LocallyGroupedSelfAttention)
def test_pcpvt():
# Test normal input
H, W = (224, 224)
temp = torch.randn((1, 3, ... | 5,919 | 33.619883 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_vit.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones.vit import VisionTransformer
from .utils import check_norm_state
def test_vit_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = VisionTransformer()
mo... | 5,826 | 31.920904 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_unet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.cnn import ConvModule
from mmseg.models.backbones.unet import (BasicConvBlock, DeconvModule,
InterpConv, UNet, UpConvBlock)
from mmseg.ops import Upsample
from .utils import check_norm_state
... | 30,122 | 35.601458 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_mobilenet_v3.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import MobileNetV3
def test_mobilenet_v3():
with pytest.raises(AssertionError):
# check invalid arch
MobileNetV3('big')
with pytest.raises(AssertionError):
# check invalid reduction... | 1,961 | 27.852941 | 76 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_blocks.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import pytest
import torch
from mmseg.models.utils import (InvertedResidual, InvertedResidualV3, SELayer,
make_divisible)
def test_make_divisible():
# test with min_value = None
assert make_divisible(10, 4) == 12
... | 6,617 | 37.701754 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_swin.py | import pytest
import torch
from mmseg.models.backbones.swin import SwinBlock, SwinTransformer
def test_swin_block():
# test SwinBlock structure and forward
block = SwinBlock(embed_dims=32, num_heads=4, feedforward_channels=128)
assert block.ffn.embed_dims == 32
assert block.attn.w_msa.num_heads == 4
... | 3,161 | 30.62 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_timm_backbone.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import TIMMBackbone
from .utils import check_norm_state
def test_timm_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = TIMMBackbone()
model.init_weig... | 4,674 | 33.88806 | 77 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_stdc.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import STDCContextPathNet
from mmseg.models.backbones.stdc import (AttentionRefinementModule,
FeatureFusionModule, STDCModule,
STDCNet... | 4,458 | 32.780303 | 73 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_resnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import DeformConv2dPack
from mmcv.utils.parrots_wrapper import _BatchNorm
from torch.nn.modules import AvgPool2d, GroupNorm
from mmseg.models.backbones import ResNet, ResNetV1d
from mmseg.models.backbones.resnet import BasicBlock,... | 20,399 | 34.416667 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_cgnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import CGNet
from mmseg.models.backbones.cgnet import (ContextGuidedBlock,
GlobalContextExtractor)
def test_cgnet_GlobalContextExtractor():
block = GlobalContextExtract... | 5,214 | 33.309211 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_bisenetv2.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import ConvModule
from mmseg.models.backbones import BiSeNetV2
from mmseg.models.backbones.bisenetv2 import (BGALayer, DetailBranch,
SemanticBranch)
def test_bisenetv2_backbone():
# Test BiSeN... | 1,843 | 30.793103 | 73 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmseg.models.backbones.resnet import BasicBlock, Bottleneck
from mmseg.models.backbones.resnext import Bottleneck as BottleneckX
def is_block(modules):
"""Che... | 1,306 | 28.704545 | 71 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_hrnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmseg.models.backbones.hrnet import HRModule, HRNet
from mmseg.models.backbones.resnet import BasicBlock, Bottleneck
@pytest.mark.parametrize('block', [BasicBlock, Bottleneck])
def test_h... | 4,266 | 28.427586 | 68 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_bisenetv1.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import BiSeNetV1
from mmseg.models.backbones.bisenetv1 import (AttentionRefinementModule,
ContextPath, FeatureFusionModule,
... | 3,410 | 30.009091 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_resnest.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import ResNeSt
from mmseg.models.backbones.resnest import Bottleneck as BottleneckS
def test_resnest_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
Bot... | 1,468 | 31.644444 | 76 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_resnext.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import ResNeXt
from mmseg.models.backbones.resnext import Bottleneck as BottleneckX
from .utils import is_block
def test_renext_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pyt... | 1,982 | 30.47619 | 72 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_mit.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import MixVisionTransformer
from mmseg.models.backbones.mit import EfficientMultiheadAttention, MixFFN
def test_mit():
with pytest.raises(TypeError):
# Pretrained represents pretrain url and must be str... | 3,991 | 34.017544 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_erfnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import ERFNet
from mmseg.models.backbones.erfnet import (DownsamplerBlock, NonBottleneck1d,
UpsamplerBlock)
def test_erfnet_backbone():
# Test ERFNet Standard Forward.... | 5,419 | 35.870748 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_fast_scnn.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import FastSCNN
def test_fastscnn_backbone():
with pytest.raises(AssertionError):
# Fast-SCNN channel constraints.
FastSCNN(
3, (32, 48),
64, (64, 96, 128), (2, 2, 1),
... | 1,189 | 26.674419 | 63 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_backbones/test_icnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import ICNet
def test_icnet_backbone():
with pytest.raises(TypeError):
# Must give backbone dict in config file.
ICNet(
in_channels=3,
layer_channels=(128, 512),
... | 1,526 | 28.941176 | 74 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_losses/test_focal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn.functional as F
from mmseg.models import build_loss
# test focal loss with use_sigmoid=False
def test_use_sigmoid():
# can't init with use_sigmoid=True
with pytest.raises(AssertionError):
loss_cfg = dict(type='... | 7,673 | 34.364055 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_losses/test_dice_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
def test_dice_lose():
from mmseg.models import build_loss
# test dice loss with loss_type = 'multi_class'
loss_cfg = dict(
type='DiceLoss',
reduction='none',
class_weight=[1.0, 2.0, 3.0],
loss_weight=1.0,
... | 2,206 | 27.294872 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_losses/test_ce_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
def test_ce_loss():
from mmseg.models import build_loss
# use_mask and use_sigmoid cannot be true at the same time
with pytest.raises(AssertionError):
loss_cfg = dict(
type='CrossEntropyLoss',
use_m... | 2,944 | 32.089888 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_losses/test_lovasz_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
def test_lovasz_loss():
from mmseg.models import build_loss
# loss_type should be 'binary' or 'multi_class'
with pytest.raises(AssertionError):
loss_cfg = dict(
type='LovaszLoss',
loss_type='Binary'... | 3,631 | 29.779661 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_losses/test_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmseg.models.losses import Accuracy, reduce_loss, weight_reduce_loss
def test_weight_reduce_loss():
loss = torch.rand(1, 3, 4, 4)
weight = torch.zeros(1, 3, 4, 4)
weight[:, :, :2, :2] = 1
# test reduce... | 3,157 | 30.58 | 74 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_cc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import CCHead
from .utils import to_cuda
def test_cc_head():
head = CCHead(in_channels=16, channels=8, num_classes=19)
assert len(head.convs) == 2
assert hasattr(head, 'cca')
if not torch.cuda.is... | 546 | 27.789474 | 61 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_ocr_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import FCNHead, OCRHead
from .utils import to_cuda
def test_ocr_head():
inputs = [torch.randn(1, 8, 23, 23)]
ocr_head = OCRHead(
in_channels=8, channels=4, num_classes=19, ocr_channels=8)
fcn_head = FCNHe... | 637 | 30.9 | 66 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_ema_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import EMAHead
from .utils import to_cuda
def test_emanet_head():
head = EMAHead(
in_channels=4,
ema_channels=3,
channels=2,
num_stages=3,
num_bases=2,
num_classes=19)
f... | 647 | 26 | 57 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_decode_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import pytest
import torch
from mmseg.models.decode_heads.decode_head import BaseDecodeHead
from .utils import to_cuda
@patch.multiple(BaseDecodeHead, __abstractmethods__=set())
def test_decode_head():
with pytest.raises(AssertionE... | 6,151 | 36.060241 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_segformer_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import SegformerHead
def test_segformer_head():
with pytest.raises(AssertionError):
# `in_channels` must have same length as `in_index`
SegformerHead(
in_channels=(1, 2, 3), in_in... | 1,204 | 28.390244 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_apc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import APCHead
from .utils import _conv_has_norm, to_cuda
def test_apc_head():
with pytest.raises(AssertionError):
# pool_scales must be list|tuple
APCHead(in_channels=8, channels=2, num_cla... | 1,751 | 28.2 | 73 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_psp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import PSPHead
from .utils import _conv_has_norm, to_cuda
def test_psp_head():
with pytest.raises(AssertionError):
# pool_scales must be list|tuple
PSPHead(in_channels=4, channels=2, num_cla... | 1,131 | 29.594595 | 73 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_lraspp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import LRASPPHead
def test_lraspp_head():
with pytest.raises(ValueError):
# check invalid input_transform
LRASPPHead(
in_channels=(4, 4, 123),
in_index=(0, 1, 2),
... | 2,093 | 29.347826 | 77 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_gc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import GCHead
from .utils import to_cuda
def test_gc_head():
head = GCHead(in_channels=4, channels=4, num_classes=19)
assert len(head.convs) == 2
assert hasattr(head, 'gc_block')
inputs = [torch.randn(1, 4, 23... | 491 | 27.941176 | 60 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_setr_up_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import SETRUPHead
from .utils import to_cuda
def test_setr_up_head(capsys):
with pytest.raises(AssertionError):
# kernel_size must be [1/3]
SETRUPHead(num_classes=19, kernel_size=2)
wit... | 1,616 | 27.368421 | 67 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_enc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import EncHead
from .utils import to_cuda
def test_enc_head():
# with se_loss, w.o. lateral
inputs = [torch.randn(1, 8, 21, 21)]
head = EncHead(in_channels=[8], channels=4, num_classes=19, in_index=[-1])
if to... | 1,613 | 32.625 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_da_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import DAHead
from .utils import to_cuda
def test_da_head():
inputs = [torch.randn(1, 16, 23, 23)]
head = DAHead(in_channels=16, channels=8, num_classes=19, pam_channels=8)
if torch.cuda.is_available():
h... | 649 | 31.5 | 77 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_isa_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import ISAHead
from .utils import to_cuda
def test_isa_head():
inputs = [torch.randn(1, 8, 23, 23)]
isa_head = ISAHead(
in_channels=8,
channels=4,
num_classes=19,
isa_channels=4,
... | 521 | 23.857143 | 60 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_segmenter_mask_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import SegmenterMaskTransformerHead
from .utils import _conv_has_norm, to_cuda
def test_segmenter_mask_transformer_head():
head = SegmenterMaskTransformerHead(
in_channels=2,
channels=2,
num_classe... | 697 | 26.92 | 66 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_uper_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import UPerHead
from .utils import _conv_has_norm, to_cuda
def test_uper_head():
with pytest.raises(AssertionError):
# fpn_in_channels must be list|tuple
UPerHead(in_channels=4, channels=2, ... | 1,066 | 28.638889 | 74 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_dm_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import DMHead
from .utils import _conv_has_norm, to_cuda
def test_dm_head():
with pytest.raises(AssertionError):
# filter_sizes must be list|tuple
DMHead(in_channels=8, channels=4, num_class... | 1,754 | 28.25 | 73 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_nl_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import NLHead
from .utils import to_cuda
def test_nl_head():
head = NLHead(in_channels=8, channels=4, num_classes=19)
assert len(head.convs) == 2
assert hasattr(head, 'nl_block')
inputs = [torch.randn(1, 8, 23... | 491 | 27.941176 | 60 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_dpt_head.py | import pytest
import torch
from mmseg.models.decode_heads import DPTHead
def test_dpt_head():
with pytest.raises(AssertionError):
# input_transform must be 'multiple_select'
head = DPTHead(
in_channels=[768, 768, 768, 768],
channels=4,
num_classes=19,
... | 1,320 | 25.959184 | 54 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_aspp_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import ASPPHead, DepthwiseSeparableASPPHead
from .utils import _conv_has_norm, to_cuda
def test_aspp_head():
with pytest.raises(AssertionError):
# pool_scales must be list|tuple
ASPPHead(in_... | 2,577 | 32.480519 | 74 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_point_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.utils import ConfigDict
from mmseg.models.decode_heads import FCNHead, PointHead
from .utils import to_cuda
def test_point_head():
inputs = [torch.randn(1, 32, 45, 45)]
point_head = PointHead(
in_channels=[32], in_index=[0], chan... | 2,340 | 36.758065 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_ann_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import ANNHead
from .utils import to_cuda
def test_ann_head():
inputs = [torch.randn(1, 4, 45, 45), torch.randn(1, 8, 21, 21)]
head = ANNHead(
in_channels=[4, 8],
channels=2,
num_classes=19,
... | 538 | 24.666667 | 67 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_fcn_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from mmcv.utils.parrots_wrapper import SyncBatchNorm
from mmseg.models.decode_heads import DepthwiseSeparableFCNHead, FCNHead
from .utils import to_cuda
def test_fcn_head():
w... | 4,511 | 33.181818 | 76 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_psa_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import PSAHead
from .utils import _conv_has_norm, to_cuda
def test_psa_head():
with pytest.raises(AssertionError):
# psa_type must be in 'bi-direction', 'collect', 'distribute'
PSAHead(
... | 3,617 | 28.414634 | 70 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_setr_mla_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.decode_heads import SETRMLAHead
from .utils import to_cuda
def test_setr_mla_head(capsys):
with pytest.raises(AssertionError):
# MLA requires input multiple stage feature information.
SETRMLAHead(in_chan... | 1,887 | 28.5 | 77 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_dnl_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import DNLHead
from .utils import to_cuda
def test_dnl_head():
# DNL with 'embedded_gaussian' mode
head = DNLHead(in_channels=8, channels=4, num_classes=19)
assert len(head.convs) == 2
assert hasattr(head, 'dn... | 1,584 | 34.222222 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_heads/test_stdc_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models.decode_heads import STDCHead
from .utils import to_cuda
def test_stdc_head():
inputs = [torch.randn(1, 32, 21, 21)]
head = STDCHead(
in_channels=32,
channels=8,
num_convs=1,
num_classes=2,
i... | 1,068 | 32.40625 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_utils/test_embed.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.utils.embed import AdaptivePadding, PatchEmbed, PatchMerging
def test_adaptive_padding():
for padding in ('same', 'corner'):
kernel_size = 16
stride = 16
dilation = 1
input = torch.rand(1... | 12,979 | 27.095238 | 78 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_necks/test_multilevel_neck.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models import MultiLevelNeck
def test_multilevel_neck():
# Test init_weights
MultiLevelNeck([266], 32).init_weights()
# Test multi feature maps
in_channels = [32, 64, 128, 256]
inputs = [torch.randn(1, c, 14, 14) for i, c i... | 1,051 | 30.878788 | 75 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_necks/test_fpn.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models import FPN
def test_fpn():
in_channels = [64, 128, 256, 512]
inputs = [
torch.randn(1, c, 56 // 2**i, 56 // 2**i)
for i, c in enumerate(in_channels)
]
fpn = FPN(in_channels, 64, len(in_channels))
outpu... | 967 | 30.225806 | 60 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_necks/test_mla_neck.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmseg.models import MLANeck
def test_mla():
in_channels = [4, 4, 4, 4]
mla = MLANeck(in_channels, 32)
inputs = [torch.randn(1, c, 12, 12) for i, c in enumerate(in_channels)]
outputs = mla(inputs)
assert outputs[0].shape == torch.S... | 518 | 29.529412 | 75 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_necks/test_jpu.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.necks import JPU
def test_fastfcn_neck():
# Test FastFCN Standard Forward
model = JPU(
in_channels=(64, 128, 256),
mid_channels=64,
start_level=0,
end_level=-1,
dilations=(1, 2... | 1,415 | 29.12766 | 72 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_necks/test_ic_neck.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.necks import ICNeck
from mmseg.models.necks.ic_neck import CascadeFeatureFusion
from ..test_heads.utils import _conv_has_norm, to_cuda
def test_ic_neck():
# test with norm_cfg
neck = ICNeck(
in_channels=(4, 1... | 1,559 | 27.888889 | 59 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_models/test_segmentors/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from torch import nn
from mmseg.models import BACKBONES, HEADS
from mmseg.models.decode_heads.cascade_decode_head import BaseCascadeDecodeHead
from mmseg.models.decode_heads.decode_head import BaseDecodeHead
def _demo_mm_inputs(input_sha... | 4,174 | 28.609929 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_apis/test_single_gpu.py | import shutil
from unittest.mock import MagicMock
import numpy as np
import pytest
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, Dataset, dataloader
from mmseg.apis import single_gpu_test
class ExampleDataset(Dataset):
def __getitem__(self, idx):
results = dict(img=torch.t... | 1,884 | 24.821918 | 70 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_data/test_dataset.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import shutil
import tempfile
from typing import Generator
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
import torch
from PIL import Image
from mmseg.core.evaluation import get_classes, get_palette
from mmse... | 30,590 | 35.901086 | 79 | py |
RSP | RSP-main/Semantic Segmentation/tests/test_data/test_dataset_builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import os.path as osp
import pytest
from torch.utils.data import (DistributedSampler, RandomSampler,
SequentialSampler)
from mmseg.datasets import (DATASETS, ConcatDataset, MultiImageMixDataset,
build... | 6,416 | 30.925373 | 78 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r101b-d8_769x769_80k_cityscapes.py | _base_ = './pspnet_r50-d8_769x769_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 154 | 30 | 52 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r50b-d8_769x769_80k_cityscapes.py | _base_ = './pspnet_r50-d8_769x769_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 133 | 43.666667 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r101b-d8_512x1024_80k_dark.py | _base_ = './pspnet_r50-d8_512x1024_80k_dark.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 149 | 29 | 47 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r101b-d8_512x1024_80k_cityscapes.py | _base_ = './pspnet_r50-d8_512x1024_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 155 | 30.2 | 53 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r50b-d8_512x1024_80k_cityscapes.py | _base_ = './pspnet_r50-d8_512x1024_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 134 | 44 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r18b-d8_769x769_80k_cityscapes.py | _base_ = './pspnet_r50-d8_769x769_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet18',
backbone=dict(type='ResNet', depth=18),
decode_head=dict(
in_channels=512,
channels=128,
),
auxiliary_head=dict(in_channels=256, channels=64))
| 283 | 27.4 | 54 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r101b-d8_512x1024_80k_night_driving.py | _base_ = './pspnet_r50-d8_512x1024_80k_night_driving.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 158 | 30.8 | 56 | py |
RSP | RSP-main/Semantic Segmentation/configs/pspnet/pspnet_r18b-d8_512x1024_80k_cityscapes.py | _base_ = './pspnet_r50-d8_512x1024_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet18',
backbone=dict(type='ResNet', depth=18),
decode_head=dict(
in_channels=512,
channels=128,
),
auxiliary_head=dict(in_channels=256, channels=64))
| 284 | 27.5 | 54 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_d6_r50b-d16_512x1024_80k_cityscapes.py | _base_ = './fcn_d6_r50-d16_512x1024_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 135 | 44.333333 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r101b-d8_512x1024_80k_cityscapes.py | _base_ = './fcn_r50-d8_512x1024_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 152 | 29.6 | 50 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r50b-d8_769x769_80k_cityscapes.py | _base_ = './fcn_r50-d8_769x769_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 130 | 42.666667 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_d6_r101b-d16_512x1024_80k_cityscapes.py | _base_ = './fcn_d6_r50b-d16_512x1024_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 157 | 30.6 | 55 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_d6_r50b-d16_769x769_80k_cityscapes.py | _base_ = './fcn_d6_r50-d16_769x769_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 134 | 44 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_d6_r101b-d16_769x769_80k_cityscapes.py | _base_ = './fcn_d6_r50b-d16_769x769_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 156 | 30.4 | 54 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r18b-d8_512x1024_80k_cityscapes.py | _base_ = './fcn_r50-d8_512x1024_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet18',
backbone=dict(type='ResNet', depth=18),
decode_head=dict(
in_channels=512,
channels=128,
),
auxiliary_head=dict(in_channels=256, channels=64))
| 281 | 27.2 | 54 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r101b-d8_769x769_80k_cityscapes.py | _base_ = './fcn_r50-d8_769x769_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet101',
backbone=dict(type='ResNet', depth=101))
| 151 | 29.4 | 49 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r18b-d8_769x769_80k_cityscapes.py | _base_ = './fcn_r50-d8_769x769_80k_cityscapes.py'
model = dict(
pretrained='torchvision://resnet18',
backbone=dict(type='ResNet', depth=18),
decode_head=dict(
in_channels=512,
channels=128,
),
auxiliary_head=dict(in_channels=256, channels=64))
| 280 | 27.1 | 54 | py |
RSP | RSP-main/Semantic Segmentation/configs/fcn/fcn_r50b-d8_512x1024_80k_cityscapes.py | _base_ = './fcn_r50-d8_512x1024_80k_cityscapes.py'
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
| 131 | 43 | 79 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/icnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='ICNet',
backbone_cfg=dict(
type='ResNetV1c',
in_channels=3,
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
... | 2,154 | 27.733333 | 78 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/ccnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,258 | 26.977778 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/ann_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,346 | 27.659574 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/gcnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,326 | 27.234043 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/encnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,435 | 28.306122 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/danet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,261 | 27.044444 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/dnl_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,316 | 27.021277 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/pspnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,271 | 27.266667 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/upernet_r50.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 1, 1),
strides=... | 1,301 | 27.933333 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/apcnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,302 | 27.955556 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/psanet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,406 | 27.14 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
dilations=(1, 1, 2, 4),
strides=(1, 2, 2, 2),
out_indices=... | 1,502 | 26.833333 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/deeplabv3plus_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,343 | 27.595745 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/emanet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,329 | 26.708333 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/dmnet_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,302 | 27.955556 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/fpn_r50.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 1, 1),
strides=... | 1,056 | 27.567568 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/deeplabv3_r50-d8.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=... | 1,273 | 27.311111 | 74 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/bisenetv1_r18-d32.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='BiSeNetV1',
in_channels=3,
context_channels=(128, 256, 512),
spatial_channels=(64, 64, 64, 128),
out_indices=(0, 1, 2),
out_channels=256,
... | 2,014 | 28.202899 | 78 | py |
RSP | RSP-main/Semantic Segmentation/configs/_base_/models/pointrend_r50.py | # model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='CascadeEncoderDecoder',
num_stages=2,
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1... | 1,704 | 28.912281 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.