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/mmcv/visualization/image.py
annotator/uniformer/mmcv/visualization/image.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 (...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/visualization/optflow.py
annotator/uniformer/mmcv/visualization/optflow.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: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/visualization/__init__.py
annotator/uniformer/mmcv/visualization/__init__.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/visualization/color.py
annotator/uniformer/mmcv/visualization/color.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 = (...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/parrots_jit.py
annotator/uniformer/mmcv/utils/parrots_jit.py
# Copyright (c) OpenMMLab. All rights reserved. import os from .parrots_wrapper import TORCH_VERSION parrots_jit_option = os.getenv('PARROTS_JIT_OPTION') if TORCH_VERSION == 'parrots' and parrots_jit_option == 'ON': from parrots.jit import pat as jit else: def jit(func=None, check_input=None, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/parrots_wrapper.py
annotator/uniformer/mmcv/utils/parrots_wrapper.py
# Copyright (c) OpenMMLab. All rights reserved. from functools import partial import torch TORCH_VERSION = torch.__version__ def is_rocm_pytorch() -> bool: is_rocm = False if TORCH_VERSION != 'parrots': try: from torch.utils.cpp_extension import ROCM_HOME is_rocm = True if ((...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/path.py
annotator/uniformer/mmcv/utils/path.py
# Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp from pathlib import Path from .misc import is_str def is_filepath(x): return is_str(x) or isinstance(x, Path) def fopen(filepath, *args, **kwargs): if is_str(filepath): return open(filepath, *args, **kwargs) elif is...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/registry.py
annotator/uniformer/mmcv/utils/registry.py
# Copyright (c) OpenMMLab. All rights reserved. import inspect import warnings from functools import partial from .misc import is_seq_of def build_from_cfg(cfg, registry, default_args=None): """Build a module from config dict. Args: cfg (dict): Config dict. It should at least contain the key "type"....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/testing.py
annotator/uniformer/mmcv/utils/testing.py
# Copyright (c) Open-MMLab. import sys from collections.abc import Iterable from runpy import run_path from shlex import split from typing import Any, Dict, List from unittest.mock import patch def check_python_script(cmd): """Run the python cmd script with `__main__`. The difference between `os.system` is 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/utils/timer.py
annotator/uniformer/mmcv/utils/timer.py
# Copyright (c) OpenMMLab. All rights reserved. from time import time class TimerError(Exception): def __init__(self, message): self.message = message super(TimerError, self).__init__(message) class Timer: """A flexible Timer class. :Example: >>> import time >>> import annotat...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/trace.py
annotator/uniformer/mmcv/utils/trace.py
import warnings import torch from annotator.uniformer.mmcv.utils import digit_version def is_jit_tracing() -> bool: if (torch.__version__ != 'parrots' and digit_version(torch.__version__) >= digit_version('1.6.0')): on_trace = torch.jit.is_tracing() # In PyTorch 1.6, torch.jit.is_tra...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/version_utils.py
annotator/uniformer/mmcv/utils/version_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import os import subprocess import warnings from packaging.version import parse def digit_version(version_str: str, length: int = 4): """Convert a version string into a tuple of integers. This method is usually used for comparing two versions. For pre-release ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/progressbar.py
annotator/uniformer/mmcv/utils/progressbar.py
# Copyright (c) OpenMMLab. All rights reserved. import sys from collections.abc import Iterable from multiprocessing import Pool from shutil import get_terminal_size from .timer import Timer class ProgressBar: """A progress bar which can print the progress.""" def __init__(self, task_num=0, bar_width=50, st...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/ext_loader.py
annotator/uniformer/mmcv/utils/ext_loader.py
# Copyright (c) OpenMMLab. All rights reserved. import importlib import os import pkgutil import warnings from collections import namedtuple import torch if torch.__version__ != 'parrots': def load_ext(name, funcs): ext = importlib.import_module('mmcv.' + name) for fun in funcs: asser...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/misc.py
annotator/uniformer/mmcv/utils/misc.py
# Copyright (c) OpenMMLab. All rights reserved. import collections.abc import functools import itertools import subprocess import warnings from collections import abc from importlib import import_module from inspect import getfullargspec from itertools import repeat # From PyTorch internals def _ntuple(n): def p...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/logging.py
annotator/uniformer/mmcv/utils/logging.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.distributed as dist logger_initialized = {} def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'): """Initialize and get a logger by name. If the logger has not been initialized, this method will initialize the...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/config.py
annotator/uniformer/mmcv/utils/config.py
# Copyright (c) OpenMMLab. All rights reserved. import ast import copy import os import os.path as osp import platform import shutil import sys import tempfile import uuid import warnings from argparse import Action, ArgumentParser from collections import abc from importlib import import_module from addict import Dict...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/__init__.py
annotator/uniformer/mmcv/utils/__init__.py
# flake8: noqa # Copyright (c) OpenMMLab. All rights reserved. from .config import Config, ConfigDict, DictAction from .misc import (check_prerequisites, concat_list, deprecated_api_warning, has_method, import_modules_from_strings, is_list_of, is_method_overridden, is_seq_of, is_st...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/utils/env.py
annotator/uniformer/mmcv/utils/env.py
# Copyright (c) OpenMMLab. All rights reserved. """This file holding some environment constant for sharing by other files.""" import os.path as osp import subprocess import sys from collections import defaultdict import cv2 import torch import annotator.uniformer.mmcv as mmcv from .parrots_wrapper import get_build_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/runner/priority.py
annotator/uniformer/mmcv/runner/priority.py
# Copyright (c) OpenMMLab. All rights reserved. from enum import Enum class Priority(Enum): """Hook priority levels. +--------------+------------+ | Level | Value | +==============+============+ | HIGHEST | 0 | +--------------+------------+ | VERY_HIGH | 10 ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/log_buffer.py
annotator/uniformer/mmcv/runner/log_buffer.py
# Copyright (c) OpenMMLab. All rights reserved. from collections import OrderedDict import numpy as np class LogBuffer: def __init__(self): self.val_history = OrderedDict() self.n_history = OrderedDict() self.output = OrderedDict() self.ready = False def clear(self): ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/base_runner.py
annotator/uniformer/mmcv/runner/base_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import logging import os.path as osp import warnings from abc import ABCMeta, abstractmethod import torch from torch.optim import Optimizer import annotator.uniformer.mmcv as mmcv from ..parallel import is_module_wrapper from .checkpoint import load_checkpoi...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/checkpoint.py
annotator/uniformer/mmcv/runner/checkpoint.py
# Copyright (c) OpenMMLab. All rights reserved. import io import os import os.path as osp import pkgutil import re 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 Optimize...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/fp16_utils.py
annotator/uniformer/mmcv/runner/fp16_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allr...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/dist_utils.py
annotator/uniformer/mmcv/runner/dist_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import os import subprocess from collections import OrderedDict import torch import torch.multiprocessing as mp from torch import distributed as dist from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_de...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/utils.py
annotator/uniformer/mmcv/runner/utils.py
# Copyright (c) OpenMMLab. All rights reserved. import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import annotator.uniformer.mmcv as mmcv def get_host_info(): """Get hostname and username. Return empty s...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/iter_based_runner.py
annotator/uniformer/mmcv/runner/iter_based_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import platform import shutil import time import warnings import torch from torch.optim import Optimizer import annotator.uniformer.mmcv as mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoin...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/__init__.py
annotator/uniformer/mmcv/runner/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .base_module import BaseModule, ModuleList, Sequential from .base_runner import BaseRunner from .builder import RUNNERS, build_runner from .checkpoint import (CheckpointLoader, _load_checkpoint, _load_checkpoint_with_prefix, load_checkpoint, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/epoch_based_runner.py
annotator/uniformer/mmcv/runner/epoch_based_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import platform import shutil import time import warnings import torch import annotator.uniformer.mmcv as mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoint from .utils import get_host_info...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/base_module.py
annotator/uniformer/mmcv/runner/base_module.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings from abc import ABCMeta from collections import defaultdict from logging import FileHandler import torch.nn as nn from annotator.uniformer.mmcv.runner.dist_utils import master_only from annotator.uniformer.mmcv.utils.logging import get_logger...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/builder.py
annotator/uniformer/mmcv/runner/builder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from ..utils import Registry RUNNERS = Registry('runner') RUNNER_BUILDERS = Registry('runner builder') def build_runner_constructor(cfg): return RUNNER_BUILDERS.build(cfg) def build_runner(cfg, default_args=None): runner_cfg = copy.deepcopy(cfg) ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/default_constructor.py
annotator/uniformer/mmcv/runner/default_constructor.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`. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/sync_buffer.py
annotator/uniformer/mmcv/runner/hooks/sync_buffer.py
# Copyright (c) OpenMMLab. All rights reserved. from ..dist_utils import allreduce_params from .hook import HOOKS, Hook @HOOKS.register_module() class SyncBuffersHook(Hook): """Synchronize model buffers such as running_mean and running_var in BN at the end of each epoch. Args: distributed (bool):...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/ema.py
annotator/uniformer/mmcv/runner/hooks/ema.py
# Copyright (c) OpenMMLab. All rights reserved. from ...parallel import is_module_wrapper from ..hooks.hook import HOOKS, Hook @HOOKS.register_module() class EMAHook(Hook): r"""Exponential Moving Average Hook. Use Exponential Moving Average on all parameters of model in training process. All parameters h...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/memory.py
annotator/uniformer/mmcv/runner/hooks/memory.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from .hook import HOOKS, Hook @HOOKS.register_module() class EmptyCacheHook(Hook): def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): self._before_epoch = before_epoch self._after_epoch = after_epoch se...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/profiler.py
annotator/uniformer/mmcv/runner/hooks/profiler.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings from typing import Callable, List, Optional, Union import torch from ..dist_utils import master_only from .hook import HOOKS, Hook @HOOKS.register_module() class ProfilerHook(Hook): """Profiler to analyze performance during training. PyTorch P...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/optimizer.py
annotator/uniformer/mmcv/runner/hooks/optimizer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from collections import defaultdict from itertools import chain from torch.nn.utils import clip_grad from annotator.uniformer.mmcv.utils import TORCH_VERSION, _BatchNorm, digit_version from ..dist_utils import allreduce_grads from ..fp16_utils import LossSca...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/checkpoint.py
annotator/uniformer/mmcv/runner/hooks/checkpoint.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import warnings from annotator.uniformer.mmcv.fileio import FileClient from ..dist_utils import allreduce_params, master_only from .hook import HOOKS, Hook @HOOKS.register_module() class CheckpointHook(Hook): """Save checkpoints periodically. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/iter_timer.py
annotator/uniformer/mmcv/runner/hooks/iter_timer.py
# Copyright (c) OpenMMLab. All rights reserved. import time from .hook import HOOKS, Hook @HOOKS.register_module() class IterTimerHook(Hook): def before_epoch(self, runner): self.t = time.time() def before_iter(self, runner): runner.log_buffer.update({'data_time': time.time() - self.t}) ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/closure.py
annotator/uniformer/mmcv/runner/hooks/closure.py
# Copyright (c) OpenMMLab. All rights reserved. from .hook import HOOKS, Hook @HOOKS.register_module() class ClosureHook(Hook): def __init__(self, fn_name, fn): assert hasattr(self, fn_name) assert callable(fn) setattr(self, fn_name, fn)
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/evaluation.py
annotator/uniformer/mmcv/runner/hooks/evaluation.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import warnings from math import inf import torch.distributed as dist from torch.nn.modules.batchnorm import _BatchNorm from torch.utils.data import DataLoader from annotator.uniformer.mmcv.fileio import FileClient from annotator.uniformer.mmcv.uti...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/__init__.py
annotator/uniformer/mmcv/runner/hooks/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .checkpoint import CheckpointHook from .closure import ClosureHook from .ema import EMAHook from .evaluation import DistEvalHook, EvalHook from .hook import HOOKS, Hook from .iter_timer import IterTimerHook from .logger import (DvcliveLoggerHook, LoggerHook, MlflowLo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/sampler_seed.py
annotator/uniformer/mmcv/runner/hooks/sampler_seed.py
# Copyright (c) OpenMMLab. All rights reserved. from .hook import HOOKS, Hook @HOOKS.register_module() class DistSamplerSeedHook(Hook): """Data-loading sampler for distributed training. When distributed training, it is only useful in conjunction with :obj:`EpochBasedRunner`, while :obj:`IterBasedRunner` ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/momentum_updater.py
annotator/uniformer/mmcv/runner/hooks/momentum_updater.py
# Copyright (c) OpenMMLab. All rights reserved. import annotator.uniformer.mmcv as mmcv from .hook import HOOKS, Hook from .lr_updater import annealing_cos, annealing_linear, format_param class MomentumUpdaterHook(Hook): def __init__(self, by_epoch=True, warmup=None, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/hook.py
annotator/uniformer/mmcv/runner/hooks/hook.py
# Copyright (c) OpenMMLab. All rights reserved. from annotator.uniformer.mmcv.utils import Registry, is_method_overridden HOOKS = Registry('hook') class Hook: stages = ('before_run', 'before_train_epoch', 'before_train_iter', 'after_train_iter', 'after_train_epoch', 'before_val_epoch', ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/lr_updater.py
annotator/uniformer/mmcv/runner/hooks/lr_updater.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers from math import cos, pi import annotator.uniformer.mmcv as mmcv from .hook import HOOKS, Hook class LrUpdaterHook(Hook): """LR Scheduler in MMCV. Args: by_epoch (bool): LR changes epoch by epoch warmup (string): Type of warmup u...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/neptune.py
annotator/uniformer/mmcv/runner/hooks/logger/neptune.py
# Copyright (c) OpenMMLab. All rights reserved. from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class NeptuneLoggerHook(LoggerHook): """Class to log metrics to NeptuneAI. It requires `neptune-client` to be installed. Args: init...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/dvclive.py
annotator/uniformer/mmcv/runner/hooks/logger/dvclive.py
# Copyright (c) OpenMMLab. All rights reserved. from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class DvcliveLoggerHook(LoggerHook): """Class to log metrics with dvclive. It requires `dvclive`_ to be installed. Args: path (str)...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/tensorboard.py
annotator/uniformer/mmcv/runner/hooks/logger/tensorboard.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class TensorboardLoggerHook(LoggerHook): def __init__...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/mlflow.py
annotator/uniformer/mmcv/runner/hooks/logger/mlflow.py
# Copyright (c) OpenMMLab. All rights reserved. from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class MlflowLoggerHook(LoggerHook): def __init__(self, exp_name=None, tags=None, log_model=True, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/pavi.py
annotator/uniformer/mmcv/runner/hooks/logger/pavi.py
# Copyright (c) OpenMMLab. All rights reserved. import json import os import os.path as osp import torch import yaml import annotator.uniformer.mmcv as mmcv from ....parallel.utils import is_module_wrapper from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_mo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/__init__.py
annotator/uniformer/mmcv/runner/hooks/logger/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .base import LoggerHook from .dvclive import DvcliveLoggerHook from .mlflow import MlflowLoggerHook from .neptune import NeptuneLoggerHook from .pavi import PaviLoggerHook from .tensorboard import TensorboardLoggerHook from .text import TextLoggerHook from .wandb imp...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/text.py
annotator/uniformer/mmcv/runner/hooks/logger/text.py
# Copyright (c) OpenMMLab. All rights reserved. import datetime import os import os.path as osp from collections import OrderedDict import torch import torch.distributed as dist import annotator.uniformer.mmcv as mmcv from annotator.uniformer.mmcv.fileio.file_client import FileClient from annotator.uniformer.mmcv.uti...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/base.py
annotator/uniformer/mmcv/runner/hooks/logger/base.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers from abc import ABCMeta, abstractmethod import numpy as np import torch from ..hook import Hook class LoggerHook(Hook): """Base class for logger hooks. Args: interval (int): Logging interval (every k iterations). ignore_last (bo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/hooks/logger/wandb.py
annotator/uniformer/mmcv/runner/hooks/logger/wandb.py
# Copyright (c) OpenMMLab. All rights reserved. from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class WandbLoggerHook(LoggerHook): def __init__(self, init_kwargs=None, interval=10, ignore_last=...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/optimizer/__init__.py
annotator/uniformer/mmcv/runner/optimizer/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .builder import (OPTIMIZER_BUILDERS, OPTIMIZERS, build_optimizer, build_optimizer_constructor) from .default_constructor import DefaultOptimizerConstructor __all__ = [ 'OPTIMIZER_BUILDERS', 'OPTIMIZERS', 'DefaultOptimizerConstructor', '...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/optimizer/builder.py
annotator/uniformer/mmcv/runner/optimizer/builder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import inspect import torch from ...utils import Registry, build_from_cfg OPTIMIZERS = Registry('optimizer') OPTIMIZER_BUILDERS = Registry('optimizer builder') def register_torch_optimizers(): torch_optimizers = [] for module_name in dir(torch.opt...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/runner/optimizer/default_constructor.py
annotator/uniformer/mmcv/runner/optimizer/default_constructor.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from torch.nn import GroupNorm, LayerNorm from annotator.uniformer.mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg, is_list_of from annotator.uniformer.mmcv.utils.ext_loader import check_ops_exist from .builder import OPTIMIZER_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/arraymisc/quantization.py
annotator/uniformer/mmcv/arraymisc/quantization.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/arraymisc/__init__.py
annotator/uniformer/mmcv/arraymisc/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .quantization import dequantize, quantize __all__ = ['quantize', 'dequantize']
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/registry.py
annotator/uniformer/mmcv/parallel/registry.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/data_parallel.py
annotator/uniformer/mmcv/parallel/data_parallel.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 ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/data_container.py
annotator/uniformer/mmcv/parallel/data_container.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/distributed_deprecated.py
annotator/uniformer/mmcv/parallel/distributed_deprecated.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/collate.py
annotator/uniformer/mmcv/parallel/collate.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/distributed.py
annotator/uniformer/mmcv/parallel/distributed.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/utils.py
annotator/uniformer/mmcv/parallel/utils.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/scatter_gather.py
annotator/uniformer/mmcv/parallel/scatter_gather.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 ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/__init__.py
annotator/uniformer/mmcv/parallel/__init__.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/parallel/_functions.py
annotator/uniformer/mmcv/parallel/_functions.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/engine/__init__.py
annotator/uniformer/mmcv/engine/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .test import (collect_results_cpu, collect_results_gpu, multi_gpu_test, single_gpu_test) __all__ = [ 'collect_results_cpu', 'collect_results_gpu', 'multi_gpu_test', 'single_gpu_test' ]
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/engine/test.py
annotator/uniformer/mmcv/engine/test.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pickle import shutil import tempfile import time import torch import torch.distributed as dist import annotator.uniformer.mmcv as mmcv from annotator.uniformer.mmcv.runner import get_dist_info def single_gpu_test(model, data_loader): "...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/video/optflow.py
annotator/uniformer/mmcv/video/optflow.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/video/__init__.py
annotator/uniformer/mmcv/video/__init__.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/video/processing.py
annotator/uniformer/mmcv/video/processing.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/video/io.py
annotator/uniformer/mmcv/video/io.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...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/roi_align_rotated.py
annotator/uniformer/mmcv/ops/roi_align_rotated.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['roi_align_rotated_forward', 'roi_align_rotated_backward']) class RoIAlignRotatedFunction(Function): @staticmethod def symb...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/assign_score_withk.py
annotator/uniformer/mmcv/ops/assign_score_withk.py
from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['assign_score_withk_forward', 'assign_score_withk_backward']) class AssignScoreWithK(Function): r"""Perform weighted sum to generate output features according to scores. Modified from `PAConv <h...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/points_sampler.py
annotator/uniformer/mmcv/ops/points_sampler.py
from typing import List import torch from torch import nn as nn from annotator.uniformer.mmcv.runner import force_fp32 from .furthest_point_sample import (furthest_point_sample, furthest_point_sample_with_dist) def calc_square_dist(point_feat_a, point_feat_b, norm=True): """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/ops/merge_cells.py
annotator/uniformer/mmcv/ops/merge_cells.py
# Copyright (c) OpenMMLab. All rights reserved. from abc import abstractmethod import torch import torch.nn as nn import torch.nn.functional as F from ..cnn import ConvModule class BaseMergeCell(nn.Module): """The basic class for cells used in NAS-FPN and NAS-FCOS. BaseMergeCell takes 2 inputs. After apply...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/tin_shift.py
annotator/uniformer/mmcv/ops/tin_shift.py
# Copyright (c) OpenMMLab. All rights reserved. # Code reference from "Temporal Interlacing Network" # https://github.com/deepcs233/TIN/blob/master/cuda_shift/rtc_wrap.py # Hao Shao, Shengju Qian, Yu Liu # shaoh19@mails.tsinghua.edu.cn, sjqian@cse.cuhk.edu.hk, yuliu@ee.cuhk.edu.hk import torch import torch.nn as nn 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/ops/masked_conv.py
annotator/uniformer/mmcv/ops/masked_conv.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['masked_im2...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/saconv.py
annotator/uniformer/mmcv/ops/saconv.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import CONV_LAYERS, ConvAWS2d, constant_init from annotator.uniformer.mmcv.ops.deform_conv import deform_conv2d from annotator.uniformer.mmcv.utils import TORCH_VERSION, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/points_in_boxes.py
annotator/uniformer/mmcv/ops/points_in_boxes.py
import torch from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'points_in_boxes_part_forward', 'points_in_boxes_cpu_forward', 'points_in_boxes_all_forward' ]) def points_in_boxes_part(points, boxes): """Find the box in which each point is (CUDA). Args: points (torch....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/modulated_deform_conv.py
annotator/uniformer/mmcv/ops/modulated_deform_conv.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair, _single from annotator.uniformer.mmcv.utils import deprecated_api_warning from ..cnn impo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/furthest_point_sample.py
annotator/uniformer/mmcv/ops/furthest_point_sample.py
import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'furthest_point_sampling_forward', 'furthest_point_sampling_with_dist_forward' ]) class FurthestPointSampling(Function): """Uses iterative furthest point sampling to select a set of...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/carafe.py
annotator/uniformer/mmcv/ops/carafe.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function from torch.nn.modules.module import Module from ..cnn import UPSAMPLE_LAYERS, normal_init, xavier_init from ..utils import ext_loader ext_module = ext_loader.load_ext(...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/knn.py
annotator/uniformer/mmcv/ops/knn.py
import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['knn_forward']) class KNN(Function): r"""KNN (CUDA) based on heap data structure. Modified from `PAConv <https://github.com/CVMI-Lab/PAConv/tree/main/ scene_seg/lib/pointops/src/knnq...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/roiaware_pool3d.py
annotator/uniformer/mmcv/ops/roiaware_pool3d.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn as nn from torch.autograd import Function import annotator.uniformer.mmcv as mmcv from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['roiaware_pool3d_forward', 'roiaware_pool3d_backward']) class RoIAwarePool...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/multi_scale_deform_attn.py
annotator/uniformer/mmcv/ops/multi_scale_deform_attn.py
# Copyright (c) OpenMMLab. All rights reserved. import math import warnings import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd.function import Function, once_differentiable from annotator.uniformer.mmcv import deprecated_api_warning from annotator.uniformer.mmcv.cnn import constant...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/roi_align.py
annotator/uniformer/mmcv/ops/roi_align.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import deprecated_api_warning, ext_loader ext_module = ext_loader.load_ext('_ext', ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/roipoint_pool3d.py
annotator/uniformer/mmcv/ops/roipoint_pool3d.py
from torch import nn as nn from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['roipoint_pool3d_forward']) class RoIPointPool3d(nn.Module): """Encode the geometry-specific features of each 3D proposal. Please refer to `Paper of PartA2 <https://arxiv....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/ball_query.py
annotator/uniformer/mmcv/ops/ball_query.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['ball_query_forward']) class BallQuery(Function): """Find nearby points in spherical space.""" @staticmethod def forward(ctx, min_rad...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/sync_bn.py
annotator/uniformer/mmcv/ops/sync_bn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.distributed as dist import torch.nn.functional as F from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.module import Module from torch.nn.parameter import Parameter from annotator.un...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/voxelize.py
annotator/uniformer/mmcv/ops/voxelize.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn from torch.autograd import Function from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['dynamic_voxelize_forward', 'hard_voxelize_forward']) class _Voxelization(Funct...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/contour_expand.py
annotator/uniformer/mmcv/ops/contour_expand.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['contour_expand']) def contour_expand(kernel_mask, internal_kernel_label, min_kernel_area, kernel_num): """Expand kernel contours so that fo...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/deform_roi_pool.py
annotator/uniformer/mmcv/ops/deform_roi_pool.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['deform_roi_pool_forward', 'deform_roi...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/cc_attention.py
annotator/uniformer/mmcv/ops/cc_attention.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import PLUGIN_LAYERS, Scale def NEG_INF_DIAG(n, device): """Returns a diagonal matrix of size [n, n]. The diagonal are all "-inf". This is for avoiding calcula...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/focal_loss.py
annotator/uniformer/mmcv/ops/focal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'sigmoid_focal_loss_forward', 'sigmoid_focal_loss_backward', ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmcv/ops/deprecated_wrappers.py
annotator/uniformer/mmcv/ops/deprecated_wrappers.py
# Copyright (c) OpenMMLab. All rights reserved. # This file is for backward compatibility. # Module wrappers for empty tensor have been moved to mmcv.cnn.bricks. import warnings from ..cnn.bricks.wrappers import Conv2d, ConvTranspose2d, Linear, MaxPool2d class Conv2d_deprecated(Conv2d): def __init__(self, *args...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false