repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/decode_head.py
annotator/uniformer/mmseg/models/decode_heads/decode_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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/segmentors/cascade_encoder_decoder.py
annotator/uniformer/mmseg/models/segmentors/cascade_encoder_decoder.py
from torch import nn from annotator.uniformer.mmseg.core import add_prefix from annotator.uniformer.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .encoder_decoder import EncoderDecoder @SEGMENTORS.register_module() class CascadeEncoderDecoder(EncoderDecoder): """Cascade Enc...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/segmentors/__init__.py
annotator/uniformer/mmseg/models/segmentors/__init__.py
from .base import BaseSegmentor from .cascade_encoder_decoder import CascadeEncoderDecoder from .encoder_decoder import EncoderDecoder __all__ = ['BaseSegmentor', 'EncoderDecoder', 'CascadeEncoderDecoder']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/segmentors/base.py
annotator/uniformer/mmseg/models/segmentors/base.py
import logging import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict import annotator.uniformer.mmcv as mmcv import numpy as np import torch import torch.distributed as dist import torch.nn as nn from annotator.uniformer.mmcv.runner import auto_fp16 class BaseSegmentor(nn.Module...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/segmentors/encoder_decoder.py
annotator/uniformer/mmseg/models/segmentors/encoder_decoder.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmseg.core import add_prefix from annotator.uniformer.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .base import BaseSegmentor @SEGMENTORS.register_module() class EncoderDecoder(BaseSegm...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/weight_init.py
annotator/uniformer/mmseg/models/utils/weight_init.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/layers/drop.py.""" import math import warnings import torch def _no_grad_trunc_normal_(tensor, mean, std, a, b): """Reference: https://people.sc.fsu.edu/~jburkardt/presentations /truncated_normal.pdf""" def norm...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/drop.py
annotator/uniformer/mmseg/models/utils/drop.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/layers/drop.py.""" import torch from torch import nn class DropPath(nn.Module): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). Args: drop_prob (float): Drop r...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/se_layer.py
annotator/uniformer/mmseg/models/utils/se_layer.py
import annotator.uniformer.mmcv as mmcv import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from .make_divisible import make_divisible class SELayer(nn.Module): """Squeeze-and-Excitation Module. Args: channels (int): The input (and output) channels of the SE layer. rati...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/inverted_residual.py
annotator/uniformer/mmseg/models/utils/inverted_residual.py
from annotator.uniformer.mmcv.cnn import ConvModule from torch import nn from torch.utils import checkpoint as cp from .se_layer import SELayer class InvertedResidual(nn.Module): """InvertedResidual block for MobileNetV2. Args: in_channels (int): The input channels of the InvertedResidual block. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/make_divisible.py
annotator/uniformer/mmseg/models/utils/make_divisible.py
def make_divisible(value, divisor, min_value=None, min_ratio=0.9): """Make divisible function. This function rounds the channel number to the nearest value that can be divisible by the divisor. It is taken from the original tf repo. It ensures that all layers have a channel number that is divisible by ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/__init__.py
annotator/uniformer/mmseg/models/utils/__init__.py
from .drop import DropPath from .inverted_residual import InvertedResidual, InvertedResidualV3 from .make_divisible import make_divisible from .res_layer import ResLayer from .se_layer import SELayer from .self_attention_block import SelfAttentionBlock from .up_conv_block import UpConvBlock from .weight_init import tru...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/self_attention_block.py
annotator/uniformer/mmseg/models/utils/self_attention_block.py
import torch from annotator.uniformer.mmcv.cnn import ConvModule, constant_init from torch import nn as nn from torch.nn import functional as F class SelfAttentionBlock(nn.Module): """General self-attention block/non-local block. Please refer to https://arxiv.org/abs/1706.03762 for details about key, que...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/res_layer.py
annotator/uniformer/mmseg/models/utils/res_layer.py
from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from torch import nn as nn class ResLayer(nn.Sequential): """ResLayer to build ResNet style backbone. Args: block (nn.Module): block used to build ResLayer. inplanes (int): inplanes of block. planes (int): pla...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/utils/up_conv_block.py
annotator/uniformer/mmseg/models/utils/up_conv_block.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, build_upsample_layer class UpConvBlock(nn.Module): """Upsample convolution block in decoder for UNet. This upsample convolution block consists of one upsample module followed by one convolution block. The upsample mod...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/fast_scnn.py
annotator/uniformer/mmseg/models/backbones/fast_scnn.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import (ConvModule, DepthwiseSeparableConvModule, constant_init, kaiming_init) from torch.nn.modules.batchnorm import _BatchNorm from annotator.uniformer.mmseg.models.decode_heads.psp_head import PPM from annotator.uniformer.mms...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/unet.py
annotator/uniformer/mmseg/models/backbones/unet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (UPSAMPLE_LAYERS, ConvModule, build_activation_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.pa...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/mobilenet_v3.py
annotator/uniformer/mmseg/models/backbones/mobilenet_v3.py
import logging import annotator.uniformer.mmcv as mmcv import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.cnn.bricks import Conv2dAdaptivePadding from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/mobilenet_v2.py
annotator/uniformer/mmseg/models/backbones/mobilenet_v2.py
import logging import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from ..utils import InvertedResidual, make_divisible @BA...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/resnest.py
annotator/uniformer/mmseg/models/backbones/resnest.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/hrnet.py
annotator/uniformer/mmseg/models/backbones/hrnet.py
import torch.nn as nn from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper import _BatchNorm from annotator.uniformer.mmseg.ops imp...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/vit.py
annotator/uniformer/mmseg/models/backbones/vit.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/vision_transformer.py.""" import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (Conv2d, Linear, build_activation_layer, bui...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/resnet.py
annotator/uniformer/mmseg/models/backbones/resnet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, build_plugin_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper i...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/uniformer.py
annotator/uniformer/mmseg/models/backbones/uniformer.py
# -------------------------------------------------------- # UniFormer # Copyright (c) 2022 SenseTime X-Lab # Licensed under The MIT License [see LICENSE for details] # Written by Kunchang Li # -------------------------------------------------------- from collections import OrderedDict import math from functools impo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/resnext.py
annotator/uniformer/mmseg/models/backbones/resnext.py
import math from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ResNet class Bottleneck(_Bottleneck): """Bottleneck block for ResNeXt. If style is "pytorch"...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/__init__.py
annotator/uniformer/mmseg/models/backbones/__init__.py
from .cgnet import CGNet # from .fast_scnn import FastSCNN from .hrnet import HRNet from .mobilenet_v2 import MobileNetV2 from .mobilenet_v3 import MobileNetV3 from .resnest import ResNeSt from .resnet import ResNet, ResNetV1c, ResNetV1d from .resnext import ResNeXt from .unet import UNet from .vit import VisionTransfo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/backbones/cgnet.py
annotator/uniformer/mmseg/models/backbones/cgnet.py
import torch import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (ConvModule, build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrap...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/necks/multilevel_neck.py
annotator/uniformer/mmseg/models/necks/multilevel_neck.py
import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule from ..builder import NECKS @NECKS.register_module() class MultiLevelNeck(nn.Module): """MultiLevelNeck. A neck structure connect vit backbone and decoder_heads. Args: in_channels (List[int]...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/necks/__init__.py
annotator/uniformer/mmseg/models/necks/__init__.py
from .fpn import FPN from .multilevel_neck import MultiLevelNeck __all__ = ['FPN', 'MultiLevelNeck']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/necks/fpn.py
annotator/uniformer/mmseg/models/necks/fpn.py
import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule, xavier_init from ..builder import NECKS @NECKS.register_module() class FPN(nn.Module): """Feature Pyramid Network. This is an implementation of - Feature Pyramid Networks for Object Detection (http...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/utils/logger.py
annotator/uniformer/mmseg/utils/logger.py
import logging from annotator.uniformer.mmcv.utils import get_logger def get_root_logger(log_file=None, log_level=logging.INFO): """Get the root logger. The logger will be initialized if it has not been initialized. By default a StreamHandler will be added. If `log_file` is specified, a FileHandler will...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/utils/collect_env.py
annotator/uniformer/mmseg/utils/collect_env.py
from annotator.uniformer.mmcv.utils import collect_env as collect_base_env from annotator.uniformer.mmcv.utils import get_git_hash import annotator.uniformer.mmseg as mmseg def collect_env(): """Collect the information of the running environments.""" env_info = collect_base_env() env_info['MMSegmentation...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/utils/__init__.py
annotator/uniformer/mmseg/utils/__init__.py
from .collect_env import collect_env from .logger import get_root_logger __all__ = ['get_root_logger', 'collect_env']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/__init__.py
annotator/uniformer/mmseg/core/__init__.py
from .evaluation import * # noqa: F401, F403 from .seg import * # noqa: F401, F403 from .utils import * # noqa: F401, F403
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/utils/misc.py
annotator/uniformer/mmseg/core/utils/misc.py
def add_prefix(inputs, prefix): """Add prefix for dict. Args: inputs (dict): The input dict with str keys. prefix (str): The prefix to add. Returns: dict: The dict with keys updated with ``prefix``. """ outputs = dict() for name, value in inputs.items(): outpu...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/utils/__init__.py
annotator/uniformer/mmseg/core/utils/__init__.py
from .misc import add_prefix __all__ = ['add_prefix']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/seg/__init__.py
annotator/uniformer/mmseg/core/seg/__init__.py
from .builder import build_pixel_sampler from .sampler import BasePixelSampler, OHEMPixelSampler __all__ = ['build_pixel_sampler', 'BasePixelSampler', 'OHEMPixelSampler']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/seg/builder.py
annotator/uniformer/mmseg/core/seg/builder.py
from annotator.uniformer.mmcv.utils import Registry, build_from_cfg PIXEL_SAMPLERS = Registry('pixel sampler') def build_pixel_sampler(cfg, **default_args): """Build pixel sampler for segmentation map.""" return build_from_cfg(cfg, PIXEL_SAMPLERS, default_args)
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/seg/sampler/base_pixel_sampler.py
annotator/uniformer/mmseg/core/seg/sampler/base_pixel_sampler.py
from abc import ABCMeta, abstractmethod class BasePixelSampler(metaclass=ABCMeta): """Base class of pixel sampler.""" def __init__(self, **kwargs): pass @abstractmethod def sample(self, seg_logit, seg_label): """Placeholder for sample function."""
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/seg/sampler/ohem_pixel_sampler.py
annotator/uniformer/mmseg/core/seg/sampler/ohem_pixel_sampler.py
import torch import torch.nn.functional as F from ..builder import PIXEL_SAMPLERS from .base_pixel_sampler import BasePixelSampler @PIXEL_SAMPLERS.register_module() class OHEMPixelSampler(BasePixelSampler): """Online Hard Example Mining Sampler for segmentation. Args: context (nn.Module): The contex...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/seg/sampler/__init__.py
annotator/uniformer/mmseg/core/seg/sampler/__init__.py
from .base_pixel_sampler import BasePixelSampler from .ohem_pixel_sampler import OHEMPixelSampler __all__ = ['BasePixelSampler', 'OHEMPixelSampler']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/evaluation/metrics.py
annotator/uniformer/mmseg/core/evaluation/metrics.py
from collections import OrderedDict import annotator.uniformer.mmcv as mmcv import numpy as np import torch def f_score(precision, recall, beta=1): """calcuate the f-score value. Args: precision (float | torch.Tensor): The precision value. recall (float | torch.Tensor): The recall value. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/evaluation/class_names.py
annotator/uniformer/mmseg/core/evaluation/class_names.py
import annotator.uniformer.mmcv as mmcv def cityscapes_classes(): """Cityscapes class names for external use.""" return [ 'road', 'sidewalk', 'building', 'wall', 'fence', 'pole', 'traffic light', 'traffic sign', 'vegetation', 'terrain', 'sky', 'person', 'rider', 'car', 'truck', 'bus', ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/evaluation/__init__.py
annotator/uniformer/mmseg/core/evaluation/__init__.py
from .class_names import get_classes, get_palette from .eval_hooks import DistEvalHook, EvalHook from .metrics import eval_metrics, mean_dice, mean_fscore, mean_iou __all__ = [ 'EvalHook', 'DistEvalHook', 'mean_dice', 'mean_iou', 'mean_fscore', 'eval_metrics', 'get_classes', 'get_palette' ]
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/core/evaluation/eval_hooks.py
annotator/uniformer/mmseg/core/evaluation/eval_hooks.py
import os.path as osp from annotator.uniformer.mmcv.runner import DistEvalHook as _DistEvalHook from annotator.uniformer.mmcv.runner import EvalHook as _EvalHook class EvalHook(_EvalHook): """Single GPU EvalHook, with efficient test support. Args: by_epoch (bool): Determine perform evaluation by epo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/apis/train.py
annotator/uniformer/mmseg/apis/train.py
import random import warnings import numpy as np import torch from annotator.uniformer.mmcv.parallel import MMDataParallel, MMDistributedDataParallel from annotator.uniformer.mmcv.runner import build_optimizer, build_runner from annotator.uniformer.mmseg.core import DistEvalHook, EvalHook from annotator.uniformer.mms...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/apis/inference.py
annotator/uniformer/mmseg/apis/inference.py
import matplotlib.pyplot as plt import annotator.uniformer.mmcv as mmcv import torch from annotator.uniformer.mmcv.parallel import collate, scatter from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmseg.datasets.pipelines import Compose from annotator.uniformer.mmseg.models import b...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/apis/__init__.py
annotator/uniformer/mmseg/apis/__init__.py
from .inference import inference_segmentor, init_segmentor, show_result_pyplot from .test import multi_gpu_test, single_gpu_test from .train import get_root_logger, set_random_seed, train_segmentor __all__ = [ 'get_root_logger', 'set_random_seed', 'train_segmentor', 'init_segmentor', 'inference_segmentor', 'mu...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/apis/test.py
annotator/uniformer/mmseg/apis/test.py
import os.path as osp import pickle import shutil import tempfile import annotator.uniformer.mmcv as mmcv import numpy as np import torch import torch.distributed as dist from annotator.uniformer.mmcv.image import tensor2imgs from annotator.uniformer.mmcv.runner import get_dist_info def np2tmp(array, temp_file_name=...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/ops/wrappers.py
annotator/uniformer/mmseg/ops/wrappers.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 =...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/ops/encoding.py
annotator/uniformer/mmseg/ops/encoding.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 ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/ops/__init__.py
annotator/uniformer/mmseg/ops/__init__.py
from .encoding import Encoding from .wrappers import Upsample, resize __all__ = ['Upsample', 'resize', 'Encoding']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/version.py
annotator/uniformer/mmcv/version.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. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/__init__.py
annotator/uniformer/mmcv/__init__.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....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/alexnet.py
annotator/uniformer/mmcv/cnn/alexnet.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn class AlexNet(nn.Module): """AlexNet backbone. Args: num_classes (int): number of classes for classification. """ def __init__(self, num_classes=-1): super(AlexNet, self).__init__() self.num...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/vgg.py
annotator/uniformer/mmcv/cnn/vgg.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn from .utils import constant_init, kaiming_init, normal_init def conv3x3(in_planes, out_planes, dilation=1): """3x3 convolution with padding.""" return nn.Conv2d( in_planes, out_planes, kernel_size=3,...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/resnet.py
annotator/uniformer/mmcv/cnn/resnet.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn import torch.utils.checkpoint as cp from .utils import constant_init, kaiming_init def conv3x3(in_planes, out_planes, stride=1, dilation=1): """3x3 convolution with padding.""" return nn.Conv2d( in_planes, o...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/__init__.py
annotator/uniformer/mmcv/cnn/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .alexnet import AlexNet # yapf: disable from .bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS, PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS, ContextBlock, Conv2d, Conv3d, ConvAWS2d, ConvModule, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/builder.py
annotator/uniformer/mmcv/cnn/builder.py
# Copyright (c) OpenMMLab. All rights reserved. from ..runner import Sequential from ..utils import Registry, build_from_cfg def build_model_from_cfg(cfg, registry, default_args=None): """Build a PyTorch model from config dict(s). Different from ``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will b...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/activation.py
annotator/uniformer/mmcv/cnn/bricks/activation.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.utils import TORCH_VERSION, build_from_cfg, digit_version from .registry import ACTIVATION_LAYERS for module in [ nn.ReLU, nn.LeakyReLU, nn.PReLU, nn.RReLU, nn.ReLU6...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/conv.py
annotator/uniformer/mmcv/cnn/bricks/conv.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from .registry import CONV_LAYERS CONV_LAYERS.register_module('Conv1d', module=nn.Conv1d) CONV_LAYERS.register_module('Conv2d', module=nn.Conv2d) CONV_LAYERS.register_module('Conv3d', module=nn.Conv3d) CONV_LAYERS.register_module('Conv', module=nn.C...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/drop.py
annotator/uniformer/mmcv/cnn/bricks/drop.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from annotator.uniformer.mmcv import build_from_cfg from .registry import DROPOUT_LAYERS def drop_path(x, drop_prob=0., training=False): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/registry.py
annotator/uniformer/mmcv/cnn/bricks/registry.py
# Copyright (c) OpenMMLab. All rights reserved. from annotator.uniformer.mmcv.utils import Registry CONV_LAYERS = Registry('conv layer') NORM_LAYERS = Registry('norm layer') ACTIVATION_LAYERS = Registry('activation layer') PADDING_LAYERS = Registry('padding layer') UPSAMPLE_LAYERS = Registry('upsample layer') PLUGIN_L...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/wrappers.py
annotator/uniformer/mmcv/cnn/bricks/wrappers.py
# Copyright (c) OpenMMLab. All rights reserved. r"""Modified from https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/wrappers.py # noqa: E501 Wrap some nn modules to support empty tensor input. Currently, these wrappers are mainly used in mask heads like fcn_mask_head and maskiou_heads since...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/conv2d_adaptive_padding.py
annotator/uniformer/mmcv/cnn/bricks/conv2d_adaptive_padding.py
# Copyright (c) OpenMMLab. All rights reserved. import math from torch import nn from torch.nn import functional as F from .registry import CONV_LAYERS @CONV_LAYERS.register_module() class Conv2dAdaptivePadding(nn.Conv2d): """Implementation of 2D convolution in tensorflow with `padding` as "same", which app...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/plugin.py
annotator/uniformer/mmcv/cnn/bricks/plugin.py
import inspect import platform from .registry import PLUGIN_LAYERS if platform.system() == 'Windows': import regex as re else: import re def infer_abbr(class_type): """Infer abbreviation from the class name. This method will infer the abbreviation to map class types to abbreviations. Rule ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/conv_ws.py
annotator/uniformer/mmcv/cnn/bricks/conv_ws.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from .registry import CONV_LAYERS def conv_ws_2d(input, weight, bias=None, stride=1, padding=0, dilation=1, grou...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/non_local.py
annotator/uniformer/mmcv/cnn/bricks/non_local.py
# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta import torch import torch.nn as nn from ..utils import constant_init, normal_init from .conv_module import ConvModule from .registry import PLUGIN_LAYERS class _NonLocalNd(nn.Module, metaclass=ABCMeta): """Basic Non-local module. This ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/upsample.py
annotator/uniformer/mmcv/cnn/bricks/upsample.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.nn.functional as F from ..utils import xavier_init from .registry import UPSAMPLE_LAYERS UPSAMPLE_LAYERS.register_module('nearest', module=nn.Upsample) UPSAMPLE_LAYERS.register_module('bilinear', module=nn.Upsample) @UPSAMPLE_LAYERS....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/generalized_attention.py
annotator/uniformer/mmcv/cnn/bricks/generalized_attention.py
# Copyright (c) OpenMMLab. All rights reserved. import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import kaiming_init from .registry import PLUGIN_LAYERS @PLUGIN_LAYERS.register_module() class GeneralizedAttention(nn.Module): """GeneralizedAttention m...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/hswish.py
annotator/uniformer/mmcv/cnn/bricks/hswish.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class HSwish(nn.Module): """Hard Swish Module. This module applies the hard swish function: .. math:: Hswish(x) = x * ReLU6(x + 3) / 6 Args: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/conv_module.py
annotator/uniformer/mmcv/cnn/bricks/conv_module.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from annotator.uniformer.mmcv.utils import _BatchNorm, _InstanceNorm from ..utils import constant_init, kaiming_init from .activation import build_activation_layer from .conv import build_conv_layer from .norm import build_norm_laye...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/norm.py
annotator/uniformer/mmcv/cnn/bricks/norm.py
# Copyright (c) OpenMMLab. All rights reserved. import inspect import torch.nn as nn from annotator.uniformer.mmcv.utils import is_tuple_of from annotator.uniformer.mmcv.utils.parrots_wrapper import SyncBatchNorm, _BatchNorm, _InstanceNorm from .registry import NORM_LAYERS NORM_LAYERS.register_module('BN', module=nn...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/scale.py
annotator/uniformer/mmcv/cnn/bricks/scale.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn class Scale(nn.Module): """A learnable scale parameter. This layer scales the input by a learnable factor. It multiplies a learnable scale parameter of shape (1,) with input of any shape. Args: scale (float): ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/__init__.py
annotator/uniformer/mmcv/cnn/bricks/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .activation import build_activation_layer from .context_block import ContextBlock from .conv import build_conv_layer from .conv2d_adaptive_padding import Conv2dAdaptivePadding from .conv_module import ConvModule from .conv_ws import ConvAWS2d, ConvWS2d, conv_ws_2d fr...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/swish.py
annotator/uniformer/mmcv/cnn/bricks/swish.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class Swish(nn.Module): """Swish Module. This module applies the swish function: .. math:: Swish(x) = x * Sigmoid(x) Returns: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/depthwise_separable_conv_module.py
annotator/uniformer/mmcv/cnn/bricks/depthwise_separable_conv_module.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .conv_module import ConvModule class DepthwiseSeparableConvModule(nn.Module): """Depthwise separable convolution module. See https://arxiv.org/pdf/1704.04861.pdf for details. This module can replace a ConvModule with the conv bl...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/transformer.py
annotator/uniformer/mmcv/cnn/bricks/transformer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings import torch import torch.nn as nn from annotator.uniformer.mmcv import ConfigDict, deprecated_api_warning from annotator.uniformer.mmcv.cnn import Linear, build_activation_layer, build_norm_layer from annotator.uniformer.mmcv.runner.base_mod...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/context_block.py
annotator/uniformer/mmcv/cnn/bricks/context_block.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn from ..utils import constant_init, kaiming_init from .registry import PLUGIN_LAYERS def last_zero_init(m): if isinstance(m, nn.Sequential): constant_init(m[-1], val=0) else: constant_init(m, val=0) @PLUGIN_LAY...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/padding.py
annotator/uniformer/mmcv/cnn/bricks/padding.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .registry import PADDING_LAYERS PADDING_LAYERS.register_module('zero', module=nn.ZeroPad2d) PADDING_LAYERS.register_module('reflect', module=nn.ReflectionPad2d) PADDING_LAYERS.register_module('replicate', module=nn.ReplicationPad2d) def buil...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/bricks/hsigmoid.py
annotator/uniformer/mmcv/cnn/bricks/hsigmoid.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class HSigmoid(nn.Module): """Hard Sigmoid Module. Apply the hard sigmoid function: Hsigmoid(x) = min(max((x + bias) / divisor, min_value), max_value) Default...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/utils/weight_init.py
annotator/uniformer/mmcv/cnn/utils/weight_init.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import math import warnings import numpy as np import torch import torch.nn as nn from torch import Tensor from annotator.uniformer.mmcv.utils import Registry, build_from_cfg, get_logger, print_log INITIALIZERS = Registry('initializer') def update_init_in...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/utils/fuse_conv_bn.py
annotator/uniformer/mmcv/cnn/utils/fuse_conv_bn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn def _fuse_conv_bn(conv, bn): """Fuse conv and bn into one module. Args: conv (nn.Module): Conv to be fused. bn (nn.Module): BN to be fused. Returns: nn.Module: Fused module. """ conv_w = co...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/utils/flops_counter.py
annotator/uniformer/mmcv/cnn/utils/flops_counter.py
# Modified from flops-counter.pytorch by Vladislav Sovrasov # original repo: https://github.com/sovrasov/flops-counter.pytorch # MIT License # Copyright (c) 2018 Vladislav Sovrasov # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (th...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/utils/sync_bn.py
annotator/uniformer/mmcv/cnn/utils/sync_bn.py
import torch import annotator.uniformer.mmcv as mmcv class _BatchNormXd(torch.nn.modules.batchnorm._BatchNorm): """A general BatchNorm layer without input dimension check. Reproduced from @kapily's work: (https://github.com/pytorch/pytorch/issues/41081#issuecomment-783961547) The only difference bet...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/cnn/utils/__init__.py
annotator/uniformer/mmcv/cnn/utils/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .flops_counter import get_model_complexity_info from .fuse_conv_bn import fuse_conv_bn from .sync_bn import revert_sync_batchnorm from .weight_init import (INITIALIZERS, Caffe2XavierInit, ConstantInit, KaimingInit, NormalInit, PretrainedInit...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/colorspace.py
annotator/uniformer/mmcv/image/colorspace.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np def imconvert(img, src, dst): """Convert an image from the src colorspace to dst colorspace. Args: img (ndarray): The input image. src (str): The source colorspace, e.g., 'rgb', 'hsv'. dst (str): The destina...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/geometric.py
annotator/uniformer/mmcv/image/geometric.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers import cv2 import numpy as np from ..utils import to_2tuple from .io import imread_backend try: from PIL import Image except ImportError: Image = None def _scale_size(size, scale): """Rescale a size by a ratio. Args: size (tupl...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/misc.py
annotator/uniformer/mmcv/image/misc.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import annotator.uniformer.mmcv as mmcv try: import torch except ImportError: torch = None def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): """Convert tensor to 3-channel images. Args: tensor (torch.Tenso...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/photometric.py
annotator/uniformer/mmcv/image/photometric.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np from ..utils import is_tuple_of from .colorspace import bgr2gray, gray2bgr def imnormalize(img, mean, std, to_rgb=True): """Normalize an image with mean and std. Args: img (ndarray): Image to be normalized. mean (n...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/__init__.py
annotator/uniformer/mmcv/image/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .colorspace import (bgr2gray, bgr2hls, bgr2hsv, bgr2rgb, bgr2ycbcr, gray2bgr, gray2rgb, hls2bgr, hsv2bgr, imconvert, rgb2bgr, rgb2gray, rgb2ycbcr, ycbcr2bgr, ycbcr2rgb) from .geometric import (cutout, imcrop, imflip, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/image/io.py
annotator/uniformer/mmcv/image/io.py
# Copyright (c) OpenMMLab. All rights reserved. import io import os.path as osp from pathlib import Path import cv2 import numpy as np from cv2 import (IMREAD_COLOR, IMREAD_GRAYSCALE, IMREAD_IGNORE_ORIENTATION, IMREAD_UNCHANGED) from annotator.uniformer.mmcv.utils import check_file_exist, is_str, mkd...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/parse.py
annotator/uniformer/mmcv/fileio/parse.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/file_client.py
annotator/uniformer/mmcv/fileio/file_client.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
true
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/__init__.py
annotator/uniformer/mmcv/fileio/__init__.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/io.py
annotator/uniformer/mmcv/fileio/io.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/handlers/pickle_handler.py
annotator/uniformer/mmcv/fileio/handlers/pickle_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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/handlers/yaml_handler.py
annotator/uniformer/mmcv/fileio/handlers/yaml_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): ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/handlers/json_handler.py
annotator/uniformer/mmcv/fileio/handlers/json_handler.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/handlers/__init__.py
annotator/uniformer/mmcv/fileio/handlers/__init__.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']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/fileio/handlers/base.py
annotator/uniformer/mmcv/fileio/handlers/base.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false