python_code stringlengths 0 679k | repo_name stringlengths 9 41 | file_path stringlengths 6 149 |
|---|---|---|
import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from torch import nn
from ..builder import HEADS
from .fcn_head import FCNHead
class DisentangledNonLocal2d(NonLocal2d):
"""Disentangled Non-Local Blocks.
Args:
temperature (float): Temperature to adjust attention. Default: 0.05
""... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/dnl_head.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
try:
from annotator.uniformer.mmcv.ops import PSAMask
except ModuleNotFoundErr... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/psa_head.py |
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .aspp_head import ASPPHead, ASPPModule
class DepthwiseSeparableASPPModule(ASPPModule):
"""Atrous Spatial Pyramid P... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/sep_aspp_head.py |
import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class NLHead(FCNHead):
"""Non-local Neural Networks.
This head is the implementation of `NLNet
<https://arxiv.org/abs/1711.07971>`_.
Args:
redu... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/nl_head.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ACM(nn.Module):
"""Adaptive Context Module used in APCNet.
Args:
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/apc_head.py |
from annotator.uniformer.mmcv.cnn import DepthwiseSeparableConvModule
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class DepthwiseSeparableFCNHead(FCNHead):
"""Depthwise-Separable Fully Convolutional Network for Semantic
Segmentation.
This head is implemented accord... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/sep_fcn_head.py |
from .ann_head import ANNHead
from .apc_head import APCHead
from .aspp_head import ASPPHead
from .cc_head import CCHead
from .da_head import DAHead
from .dm_head import DMHead
from .dnl_head import DNLHead
from .ema_head import EMAHead
from .enc_head import EncHead
from .fcn_head import FCNHead
from .fpn_head import FP... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/__init__.py |
from abc import ABCMeta, abstractmethod
from .decode_head import BaseDecodeHead
class BaseCascadeDecodeHead(BaseDecodeHead, metaclass=ABCMeta):
"""Base class for cascade decode head used in
:class:`CascadeEncoderDecoder."""
def __init__(self, *args, **kwargs):
super(BaseCascadeDecodeHead, self).... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/cascade_decode_head.py |
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that only concat the features of each ... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/ann_head.py |
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FCNHead(BaseDecodeHead):
"""Fully Convolution Networks for Semantic Segmentation.
This head is implemented of `FCNNet <htt... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/fcn_head.py |
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, normal_init
from annotator.uniformer.mmcv.ops import point_sample
from annotator.uniformer.mmseg.models... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/point_head.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, build_norm_layer
from annotator.uniformer.mmseg.ops import Encoding, resize
from ..builder import HEADS, build_loss
from .decode_head import BaseDecodeHead
class EncModule(nn.Module):
"""Encodi... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/enc_head.py |
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ASPPModule(nn.ModuleList):
"""Atrous Spatial Pyramid Pooling (ASPP) Module.
Args:
dilation... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/aspp_head.py |
from abc import ABCMeta, abstractmethod
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import normal_init
from annotator.uniformer.mmcv.runner import auto_fp16, force_fp32
from annotator.uniformer.mmseg.core import build_pixel_sampler
from annotator.uniformer.mmseg.ops import resize
from ..build... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/decode_head.py |
import torch
from ..builder import HEADS
from .fcn_head import FCNHead
try:
from annotator.uniformer.mmcv.ops import CrissCrossAttention
except ModuleNotFoundError:
CrissCrossAttention = None
@HEADS.register_module()
class CCHead(FCNHead):
"""CCNet: Criss-Cross Attention for Semantic Segmentation.
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/cc_head.py |
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class PPM(nn.ModuleList):
"""Pooling Pyramid Module used in PSPNet.
Args:
pool_scales (tuple[int... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/psp_head.py |
import torch
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, Scale
from torch import nn
from annotator.uniformer.mmseg.core import add_prefix
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PA... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/da_head.py |
import numpy as np
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FPNHead(BaseDecodeHead):
"""Panoptic Feature Pyramid Networks.
This... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/models/decode_heads/fpn_head.py |
import torch
from torch import nn
from torch.nn import functional as F
class Encoding(nn.Module):
"""Encoding Layer: a learnable residual encoder.
Input is of shape (batch_size, channels, height, width).
Output is of shape (batch_size, num_codes, channels).
Args:
channels: dimension of the ... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/ops/encoding.py |
from .encoding import Encoding
from .wrappers import Upsample, resize
__all__ = ['Upsample', 'resize', 'Encoding']
| trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/ops/__init__.py |
import warnings
import torch.nn as nn
import torch.nn.functional as F
def resize(input,
size=None,
scale_factor=None,
mode='nearest',
align_corners=None,
warning=True):
if warning:
if size is not None and align_corners:
input_h, input_w =... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmseg/ops/wrappers.py |
# Copyright (c) Open-MMLab. All rights reserved.
import io
import os
import os.path as osp
import pkgutil
import time
import warnings
from collections import OrderedDict
from importlib import import_module
from tempfile import TemporaryDirectory
import torch
import torchvision
from torch.optim import Optimizer
from to... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv_custom/checkpoint.py |
# -*- coding: utf-8 -*-
from .checkpoint import load_checkpoint
__all__ = ['load_checkpoint'] | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv_custom/__init__.py |
# yapf:disable
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook', by_epoch=False),
# dict(type='TensorboardLoggerHook')
])
# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
cudnn_benchmark = True... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/default_runtime.py |
# dataset settings
dataset_type = 'CityscapesDataset'
data_root = 'data/cityscapes/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (512, 1024)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize',... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/cityscapes.py |
# dataset settings
dataset_type = 'PascalContextDataset'
data_root = 'data/VOCdevkit/VOC2010/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (520, 520)
crop_size = (480, 480)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnno... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/pascal_context.py |
_base_ = './pascal_voc12.py'
# dataset settings
data = dict(
train=dict(
ann_dir=['SegmentationClass', 'SegmentationClassAug'],
split=[
'ImageSets/Segmentation/train.txt',
'ImageSets/Segmentation/aug.txt'
]))
| trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/pascal_voc12_aug.py |
# dataset settings
dataset_type = 'PascalContextDataset59'
data_root = 'data/VOCdevkit/VOC2010/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (520, 520)
crop_size = (480, 480)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAn... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/pascal_context_59.py |
# dataset settings
dataset_type = 'HRFDataset'
data_root = 'data/HRF'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (2336, 3504)
crop_size = (256, 256)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/hrf.py |
# dataset settings
dataset_type = 'ADE20KDataset'
data_root = 'data/ade/ADEChallengeData2016'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (512, 512)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', reduce_zero_labe... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/ade20k.py |
# dataset settings
dataset_type = 'ChaseDB1Dataset'
data_root = 'data/CHASE_DB1'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (960, 999)
crop_size = (128, 128)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
d... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/chase_db1.py |
_base_ = './cityscapes.py'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (769, 769)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize', img_scale=(2049, 1025), ratio_range=(0.5, 2.0)),
dict(... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/cityscapes_769x769.py |
# dataset settings
dataset_type = 'STAREDataset'
data_root = 'data/STARE'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (605, 700)
crop_size = (128, 128)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(typ... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/stare.py |
# dataset settings
dataset_type = 'DRIVEDataset'
data_root = 'data/DRIVE'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
img_scale = (584, 565)
crop_size = (64, 64)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/drive.py |
# dataset settings
dataset_type = 'PascalVOCDataset'
data_root = 'data/VOCdevkit/VOC2012'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (512, 512)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resi... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/datasets/pascal_voc12.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/fcn_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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/nonlocal_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://msra/hrnetv2_w18',
backbone=dict(
type='HRNet',
norm_cfg=norm_cfg,
norm_eval=False,
extra=dict(
stage1=dict(
num_modul... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/fcn_hr18.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/encnet_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', eps=1e-03, requires_grad=True)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='CGNet',
norm_cfg=norm_cfg,
in_channels=3,
num_channels=(32, 64, 128),
num_blocks=(3, 21),
dilations=(2, 4),
reductions=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/cgnet.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/gcnet_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='UNet',
in_channels=3,
base_channels=64,
num_stages=5,
strides=(1, 1, 1, 1, 1),
enc_num_convs=(2, 2, 2, 2, 2),
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/deeplabv3_unet_s5-d16.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/dnl_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True, momentum=0.01)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='FastSCNN',
downsample_dw_channels=(32, 48),
global_in_channels=64,
global_block_channels=(64, 96, 128),
global_block_strides=(2, 2,... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/fast_scnn.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/upernet_r50.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='UNet',
in_channels=3,
base_channels=64,
num_stages=5,
strides=(1, 1, 1, 1, 1),
enc_num_convs=(2, 2, 2, 2, 2),
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/pspnet_unet_s5-d16.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='UNet',
in_channels=3,
base_channels=64,
num_stages=5,
strides=(1, 1, 1, 1, 1),
enc_num_convs=(2, 2, 2, 2, 2),
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/fcn_unet_s5-d16.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/danet_r50-d8.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... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/ocrnet_r50-d8.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... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/pointrend_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, 2, 4),
strides=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/psanet_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='CascadeEncoderDecoder',
num_stages=2,
pretrained='open-mmlab://msra/hrnetv2_w18',
backbone=dict(
type='HRNet',
norm_cfg=norm_cfg,
norm_eval=False,
extra=dict(
stage1=dict(
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/ocrnet_hr18.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/dmnet_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', eps=0.001, requires_grad=True)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='MobileNetV3',
arch='large',
out_indices=(1, 3, 16),
norm_cfg=norm_cfg),
decode_head=dict(
type='LRASPPHead',
in_channels=(1... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/lraspp_m-v3-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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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, 1, 1),
strides=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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, 2, 4),
strides=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/ann_r50-d8.py |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
backbone=dict(
type='UniFormer',
embed_dim=[64, 128, 320, 512],
layers=[3, 4, 8, 3],
head_dim=64,
mlp_ratio=4.,
qkv_bias=True,
drop_rate=0.,
at... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/fpn_uniformer.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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/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=... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/emanet_r50-d8.py |
# model settings
norm_cfg = dict(type='BN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='UniFormer',
embed_dim=[64, 128, 320, 512],
layers=[3, 4, 8, 3],
head_dim=64,
mlp_ratio=4.,
qkv_bias=True,
drop_ra... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/models/upernet_uniformer.py |
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=160000)
checkpoint_config = dict(by_epoch=False, int... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/schedules/schedule_160k.py |
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=80000)
checkpoint_config = dict(by_epoch=False, inte... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/schedules/schedule_80k.py |
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=40000)
checkpoint_config = dict(by_epoch=False, inte... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/schedules/schedule_40k.py |
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=20000)
checkpoint_config = dict(by_epoch=False, inte... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/configs/_base_/schedules/schedule_20k.py |
# Copyright (c) OpenMMLab. All rights reserved.
__version__ = '1.3.17'
def parse_version_info(version_str: str, length: int = 4) -> tuple:
"""Parse a version string into a tuple.
Args:
version_str (str): The version string.
length (int): The maximum number of version levels. Default: 4.
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/version.py |
# Copyright (c) OpenMMLab. All rights reserved.
# flake8: noqa
from .arraymisc import *
from .fileio import *
from .image import *
from .utils import *
from .version import *
from .video import *
from .visualization import *
# The following modules are not imported to this level, so mmcv may be used
# without PyTorch.... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
def quantize(arr, min_val, max_val, levels, dtype=np.int64):
"""Quantize an array of (-inf, inf) to [0, levels-1].
Args:
arr (ndarray): Input array.
min_val (scalar): Minimum value to be clipped.
max_val (scalar): Maxi... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/arraymisc/quantization.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .quantization import dequantize, quantize
__all__ = ['quantize', 'dequantize']
| trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/arraymisc/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
from enum import Enum
import numpy as np
from annotator.uniformer.mmcv.utils import is_str
class Color(Enum):
"""An enum that defines common colors.
Contains red, green, blue, cyan, yellow, magenta, white and black.
"""
red = (0, 0, 255)
green = (... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/visualization/color.py |
# Copyright (c) OpenMMLab. All rights reserved.
from __future__ import division
import numpy as np
from annotator.uniformer.mmcv.image import rgb2bgr
from annotator.uniformer.mmcv.video import flowread
from .image import imshow
def flowshow(flow, win_name='', wait_time=0):
"""Show optical flow.
Args:
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/visualization/optflow.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .color import Color, color_val
from .image import imshow, imshow_bboxes, imshow_det_bboxes
from .optflow import flow2rgb, flowshow, make_color_wheel
__all__ = [
'Color', 'color_val', 'imshow', 'imshow_bboxes', 'imshow_det_bboxes',
'flowshow', 'flow2rgb', 'ma... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/visualization/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import cv2
import numpy as np
from annotator.uniformer.mmcv.image import imread, imwrite
from .color import color_val
def imshow(img, win_name='', wait_time=0):
"""Show an image.
Args:
img (str or ndarray): The image to be displayed.
win_name (... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/visualization/image.py |
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
import cv2
import numpy as np
from annotator.uniformer.mmcv.arraymisc import dequantize, quantize
from annotator.uniformer.mmcv.image import imread, imwrite
from annotator.uniformer.mmcv.utils import is_str
def flowread(flow_or_path, quantize=False, co... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/video/optflow.py |
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from collections import OrderedDict
import cv2
from cv2 import (CAP_PROP_FOURCC, CAP_PROP_FPS, CAP_PROP_FRAME_COUNT,
CAP_PROP_FRAME_HEIGHT, CAP_PROP_FRAME_WIDTH,
CAP_PROP_POS_FRAMES, VideoWriter_fourcc)
from annota... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/video/io.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .io import Cache, VideoReader, frames2video
from .optflow import (dequantize_flow, flow_from_bytes, flow_warp, flowread,
flowwrite, quantize_flow, sparse_flow_from_bytes)
from .processing import concat_video, convert_video, cut_video, resize_vid... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/video/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import subprocess
import tempfile
from annotator.uniformer.mmcv.utils import requires_executable
@requires_executable('ffmpeg')
def convert_video(in_file,
out_file,
print_cmd=False,
p... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/video/processing.py |
# Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.distributed as dist
import torch.nn as nn
from torch._utils import (_flatten_dense_tensors, _take_tensors,
_unflatten_dense_tensors)
from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version
from .registry... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/distributed_deprecated.py |
# Copyright (c) OpenMMLab. All rights reserved.
from collections.abc import Mapping, Sequence
import torch
import torch.nn.functional as F
from torch.utils.data.dataloader import default_collate
from .data_container import DataContainer
def collate(batch, samples_per_gpu=1):
"""Puts each data field into a tenso... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/collate.py |
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.parallel._functions import Scatter as OrigScatter
from ._functions import Scatter
from .data_container import DataContainer
def scatter(inputs, target_gpus, dim=0):
"""Scatter inputs to target gpus.
The only difference from original ... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/scatter_gather.py |
# Copyright (c) OpenMMLab. All rights reserved.
from torch.nn.parallel import DataParallel, DistributedDataParallel
from annotator.uniformer.mmcv.utils import Registry
MODULE_WRAPPERS = Registry('module wrapper')
MODULE_WRAPPERS.register_module(module=DataParallel)
MODULE_WRAPPERS.register_module(module=DistributedDa... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/registry.py |
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.parallel._functions import _get_stream
def scatter(input, devices, streams=None):
"""Scatters tensor across multiple GPUs."""
if streams is None:
streams = [None] * len(devices)
if isinstance(input, list):
chunk_si... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/_functions.py |
# Copyright (c) OpenMMLab. All rights reserved.
from itertools import chain
from torch.nn.parallel import DataParallel
from .scatter_gather import scatter_kwargs
class MMDataParallel(DataParallel):
"""The DataParallel module that supports DataContainer.
MMDataParallel has two main differences with PyTorch ... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/data_parallel.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .collate import collate
from .data_container import DataContainer
from .data_parallel import MMDataParallel
from .distributed import MMDistributedDataParallel
from .registry import MODULE_WRAPPERS
from .scatter_gather import scatter, scatter_kwargs
from .utils import... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.parallel.distributed import (DistributedDataParallel,
_find_tensors)
from annotator.uniformer.mmcv import print_log
from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version
from .scatter... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/distributed.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .registry import MODULE_WRAPPERS
def is_module_wrapper(module):
"""Check if a module is a module wrapper.
The following 3 modules in MMCV (and their subclasses) are regarded as
module wrappers: DataParallel, DistributedDataParallel,
MMDistributedDa... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/utils.py |
# Copyright (c) OpenMMLab. All rights reserved.
import functools
import torch
def assert_tensor_type(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not isinstance(args[0].data, torch.Tensor):
raise AttributeError(
f'{args[0].__class__.__name__} has no attr... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/parallel/data_container.py |
# Copyright (c) OpenMMLab. All rights reserved.
from io import BytesIO, StringIO
from pathlib import Path
from ..utils import is_list_of, is_str
from .file_client import FileClient
from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler
file_handlers = {
'json': JsonHandler(),
'yaml': Y... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/io.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .file_client import BaseStorageBackend, FileClient
from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler
from .io import dump, load, register_handler
from .parse import dict_from_file, list_from_file
__all__ = [
'BaseStorageBackend', 'Fi... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import inspect
import os
import os.path as osp
import re
import tempfile
import warnings
from abc import ABCMeta, abstractmethod
from contextlib import contextmanager
from pathlib import Path
from typing import Iterable, Iterator, Optional, Tuple, Union
from urllib.reques... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/file_client.py |
# Copyright (c) OpenMMLab. All rights reserved.
from io import StringIO
from .file_client import FileClient
def list_from_file(filename,
prefix='',
offset=0,
max_num=0,
encoding='utf-8',
file_client_args=None):
"""Loa... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/parse.py |
# Copyright (c) OpenMMLab. All rights reserved.
from .base import BaseFileHandler
from .json_handler import JsonHandler
from .pickle_handler import PickleHandler
from .yaml_handler import YamlHandler
__all__ = ['BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler']
| trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/handlers/__init__.py |
# Copyright (c) OpenMMLab. All rights reserved.
import json
import numpy as np
from .base import BaseFileHandler
def set_default(obj):
"""Set default json values for non-serializable values.
It helps convert ``set``, ``range`` and ``np.ndarray`` data types to list.
It also converts ``np.generic`` (incl... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/handlers/json_handler.py |
# Copyright (c) OpenMMLab. All rights reserved.
import pickle
from .base import BaseFileHandler
class PickleHandler(BaseFileHandler):
str_like = False
def load_from_fileobj(self, file, **kwargs):
return pickle.load(file, **kwargs)
def load_from_path(self, filepath, **kwargs):
return su... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/handlers/pickle_handler.py |
# Copyright (c) OpenMMLab. All rights reserved.
import yaml
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
from .base import BaseFileHandler # isort:skip
class YamlHandler(BaseFileHandler):
def load_from_fileobj(self, file, **kwargs):
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/handlers/yaml_handler.py |
# Copyright (c) OpenMMLab. All rights reserved.
from abc import ABCMeta, abstractmethod
class BaseFileHandler(metaclass=ABCMeta):
# `str_like` is a flag to indicate whether the type of file object is
# str-like object or bytes-like object. Pickle only processes bytes-like
# objects but json only processes... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/fileio/handlers/base.py |
from .builder import RUNNER_BUILDERS, RUNNERS
@RUNNER_BUILDERS.register_module()
class DefaultRunnerConstructor:
"""Default constructor for runners.
Custom existing `Runner` like `EpocBasedRunner` though `RunnerConstructor`.
For example, We can inject some new properties and functions for `Runner`.
... | trt-samples-for-hackathon-cn-master | Hackathon2023/controlnet/annotator/uniformer/mmcv/runner/default_constructor.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.