repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
UniControl | UniControl-main/annotator/uniformer_base/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... | 2,936 | 30.244681 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 11,062 | 39.375912 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 20,846 | 37.392265 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 15,784 | 37.406326 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 7,502 | 37.280612 | 92 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 7,565 | 39.244681 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 657 | 24.307692 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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` ... | 847 | 39.380952 | 76 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 26,034 | 37.800298 | 108 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 22,448 | 43.017647 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 8,041 | 43.430939 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 21,652 | 41.540275 | 83 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 5,451 | 31.646707 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 4,378 | 36.110169 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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,
... | 2,838 | 34.936709 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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__... | 2,077 | 34.827586 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 10,684 | 40.575875 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 11,803 | 46.216 | 96 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 1,346 | 28.933333 | 73 | py |
UniControl | UniControl-main/annotator/uniformer_base/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 ((... | 3,536 | 31.75 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 3,986 | 34.918919 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 4,289 | 29.425532 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 2,021 | 27.083333 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 3,915 | 54.942857 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 795 | 32.166667 | 76 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 3,367 | 34.083333 | 97 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 7,410 | 35.15122 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/nms.py | import os
import numpy as np
import torch
from annotator.uniformer.mmcv.utils import deprecated_api_warning
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated'])
# This function is modified from: https://github.com/pytorch/vision/
class NMSop(t... | 16,237 | 37.84689 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 1,695 | 29.285714 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 4,256 | 36.017391 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 3,041 | 35.214286 | 78 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/deform_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair, _single
from... | 15,603 | 37.433498 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 2,599 | 32.333333 | 75 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/correlation.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import Tensor, 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', ['correlation_forw... | 6,697 | 33 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/roi_pool.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 ext_loader
ext_module = ext_loader.load_ext('_ext',
... | 2,517 | 27.942529 | 75 | py |
UniControl | UniControl-main/annotator/uniformer_base/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',
... | 8,519 | 37.035714 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 11,267 | 39.242857 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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.... | 2,990 | 37.346154 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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, ... | 5,804 | 38.760274 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/point_sample.py | # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa
from os import path as osp
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.utils import _pair
from torch.onnx.operators import shape_as_tensor
def bilinear_grid_sample(im, g... | 12,287 | 35.462908 | 101 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/upfirdn2d.py | # modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/upfirdn2d.py # noqa:E501
# Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
# NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator
# Augmentation (ADA)
# =========================================================... | 11,800 | 34.652568 | 104 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/fused_bias_leakyrelu.py | # modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/fused_act.py # noqa:E501
# Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
# NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator
# Augmentation (ADA)
# ==========================================================... | 10,027 | 36.27881 | 103 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/group_points.py | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Tuple
import torch
from torch import nn as nn
from torch.autograd import Function
from ..utils import ext_loader
from .ball_query import ball_query
from .knn import knn
ext_module = ext_loader.load_ext(
'_ext', ['group_points_forward', 'group_poi... | 8,135 | 35.16 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/iou3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'iou3d_boxes_iou_bev_forward', 'iou3d_nms_forward',
'iou3d_nms_normal_forward'
])
def boxes_iou_bev(boxes_a, boxes_b):
"""Calculate boxes IoU in the Bird's Eye View.
... | 2,988 | 33.755814 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/border_align.py | # Copyright (c) OpenMMLab. All rights reserved.
# modified from
# https://github.com/Megvii-BaseDetection/cvpods/blob/master/cvpods/layers/border_align.py
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_... | 3,725 | 32.872727 | 90 | py |
UniControl | UniControl-main/annotator/uniformer_base/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(... | 9,873 | 33.284722 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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.... | 5,241 | 38.119403 | 78 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/three_interpolate.py | from typing import Tuple
import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['three_interpolate_forward', 'three_interpolate_backward'])
class ThreeInterpolate(Function):
"""Performs weighted linear interpolation on 3 features.
Ple... | 2,147 | 30.130435 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/corner_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'top_pool_forward', 'top_pool_backward', 'bottom_pool_forward',
'bottom_pool_backward', 'left_pool_forward', 'left_poo... | 4,697 | 28 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 2,141 | 30.043478 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 4,344 | 34.040323 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/three_nn.py | from typing import Tuple
import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['three_nn_forward'])
class ThreeNN(Function):
"""Find the top-3 nearest neighbors of the target set from the source set.
Please refer to `Paper of PointNet++ <... | 1,515 | 28.153846 | 78 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/bbox.py | # Copyright (c) OpenMMLab. All rights reserved.
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
"""Calculate overlap between two set of bboxes.
If ``aligned`` is ``False``, then calculate the... | 2,508 | 33.369863 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 15,175 | 41.272981 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/psa_mask.py | # Modified from https://github.com/hszhao/semseg/blob/master/lib/psa
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',
['psamask_forward', 'psamask_backward'])
cla... | 2,773 | 28.827957 | 73 | py |
UniControl | UniControl-main/annotator/uniformer_base/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',
... | 6,582 | 29.906103 | 76 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 6,063 | 33.067416 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 5,286 | 38.75188 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 3,761 | 32.589286 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 2,550 | 29.369048 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 10,574 | 36.367491 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/info.py | # Copyright (c) OpenMMLab. All rights reserved.
import glob
import os
import torch
if torch.__version__ == 'parrots':
import parrots
def get_compiler_version():
return 'GCC ' + parrots.version.compiler
def get_compiling_cuda_version():
return parrots.version.cuda
else:
from ..utils i... | 887 | 23 | 71 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/pixel_group.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', ['pixel_group'])
def pixel_group(score, mask, embedding, kernel_label, kernel_contour,
kernel_region_num, distance_threshold):
"""Group pixels i... | 3,113 | 39.973684 | 79 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 1,795 | 34.92 | 77 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/gather_points.py | import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['gather_points_forward', 'gather_points_backward'])
class GatherPoints(Function):
"""Gather points with given index."""
@staticmethod
def forward(ctx, features: torch.Tensor,
... | 1,607 | 26.724138 | 69 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 6,434 | 35.151685 | 78 | py |
UniControl | UniControl-main/annotator/uniformer_base/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... | 5,403 | 35.026667 | 78 | py |
UniControl | UniControl-main/annotator/uniformer_base/mmcv/ops/scatter_points.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext',
['dynamic_point_to_voxel_forward', 'dynamic_point_to_voxel_backward'])
class _DynamicScatter(Function):
@staticm... | 5,201 | 37.25 | 79 | py |
UniControl | UniControl-main/annotator/openpose/hand.py | '''
* Copyright (c) 2023 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: Apache License 2.0
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/
* By Can Qin
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet
* Copyright (c) 2... | 3,788 | 38.46875 | 110 | py |
UniControl | UniControl-main/annotator/openpose/model.py | '''
* Copyright (c) 2023 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: Apache License 2.0
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/
* By Can Qin
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet
* Copyright (c) 2... | 9,107 | 38.6 | 98 | py |
UniControl | UniControl-main/annotator/openpose/util.py | '''
* Copyright (c) 2023 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: Apache License 2.0
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/
* By Can Qin
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet
* Copyright (c) 2... | 7,870 | 43.721591 | 133 | py |
UniControl | UniControl-main/annotator/openpose/__init__.py | '''
* Copyright (c) 2023 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: Apache License 2.0
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/
* By Can Qin
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet
* Copyright (c) 2... | 2,494 | 40.583333 | 113 | py |
UniControl | UniControl-main/annotator/openpose/body.py | '''
* Copyright (c) 2023 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: Apache License 2.0
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/
* By Can Qin
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet
* Copyright (c) 2... | 11,356 | 48.378261 | 137 | py |
UniControl | UniControl-main/annotator/uniformer/mmcv_custom/checkpoint.py | # Copyright (c) Open-MMLab. All rights reserved.
import io
import os
import os.path as osp
import pkgutil
import time
import warnings
from collections import OrderedDict
from importlib import import_module
from tempfile import TemporaryDirectory
import torch
import torchvision
from torch.optim import Optimizer
from to... | 19,091 | 37.184 | 110 | py |
UniControl | UniControl-main/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... | 4,729 | 33.525547 | 79 | py |
UniControl | UniControl-main/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=... | 8,288 | 33.682008 | 79 | py |
UniControl | UniControl-main/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... | 4,035 | 33.495726 | 87 | py |
UniControl | UniControl-main/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.
... | 13,079 | 39 | 79 | py |
UniControl | UniControl-main/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... | 3,155 | 39.987013 | 103 | py |
UniControl | UniControl-main/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]... | 2,454 | 33.577465 | 76 | py |
UniControl | UniControl-main/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... | 9,159 | 42.004695 | 79 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/fcn_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FCNHead(BaseDecodeHead):
"""Fully Convolution Networks for Semantic Segmentation.
This head is implemented of `FCNNet <htt... | 2,817 | 33.365854 | 77 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/sep_aspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .aspp_head import ASPPHead, ASPPModule
class DepthwiseSeparableASPPModule(ASPPModule):
"""Atrous Spatial Pyramid P... | 3,527 | 33.588235 | 81 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/ann_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that only concat the features of each ... | 9,194 | 36.378049 | 77 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/apc_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ACM(nn.Module):
"""Adaptive Context Module used in APCNet.
Args:
... | 5,572 | 34.050314 | 76 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/ocr_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .cascade_decode_head import BaseCascadeDecodeHead
clas... | 4,319 | 32.75 | 76 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/dm_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, build_activation_layer, build_norm_layer
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class DCM(nn.Module):
"""Dynamic Convolutional Module used in DMNet.
Args:
... | 5,004 | 34.496454 | 93 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/ema_head.py | import math
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
def reduce_mean(tensor):
"""Reduce mean when distributed training."""
if not... | 5,796 | 33.301775 | 77 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/da_head.py | import torch
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, Scale
from torch import nn
from annotator.uniformer.mmseg.core import add_prefix
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PA... | 5,585 | 30.206704 | 77 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/psp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class PPM(nn.ModuleList):
"""Pooling Pyramid Module used in PSPNet.
Args:
pool_scales (tuple[int... | 3,352 | 31.872549 | 78 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/cc_head.py | import torch
from ..builder import HEADS
from .fcn_head import FCNHead
try:
from annotator.uniformer.mmcv.ops import CrissCrossAttention
except ModuleNotFoundError:
CrissCrossAttention = None
@HEADS.register_module()
class CCHead(FCNHead):
"""CCNet: Criss-Cross Attention for Semantic Segmentation.
... | 1,303 | 29.325581 | 71 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/enc_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, build_norm_layer
from annotator.uniformer.mmseg.ops import Encoding, resize
from ..builder import HEADS, build_loss
from .decode_head import BaseDecodeHead
class EncModule(nn.Module):
"""Encodi... | 6,784 | 35.090426 | 78 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/fpn_head.py | import numpy as np
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FPNHead(BaseDecodeHead):
"""Panoptic Feature Pyramid Networks.
This... | 2,422 | 34.115942 | 79 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/nl_head.py | import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class NLHead(FCNHead):
"""Non-local Neural Networks.
This head is the implementation of `NLNet
<https://arxiv.org/abs/1711.07971>`_.
Args:
redu... | 1,577 | 30.56 | 78 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/dnl_head.py | import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from torch import nn
from ..builder import HEADS
from .fcn_head import FCNHead
class DisentangledNonLocal2d(NonLocal2d):
"""Disentangled Non-Local Blocks.
Args:
temperature (float): Temperature to adjust attention. Default: 0.05
""... | 4,591 | 33.787879 | 78 | py |
UniControl | UniControl-main/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... | 9,240 | 38.323404 | 78 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/lraspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv import is_tuple_of
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class LRASPPHead(BaseDecodeHead):
"... | 3,098 | 33.054945 | 77 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/uper_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
from .psp_head import PPM
@HEADS.register_module()
class UPerHead(BaseDecodeHead):
"""Unified Perceptual Pars... | 4,012 | 30.598425 | 72 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/aspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ASPPModule(nn.ModuleList):
"""Atrous Spatial Pyramid Pooling (ASPP) Module.
Args:
dilation... | 3,459 | 31.037037 | 76 | py |
UniControl | UniControl-main/annotator/uniformer/mmseg/models/decode_heads/psa_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
try:
from annotator.uniformer.mmcv.ops import PSAMask
except ModuleNotFoundErr... | 7,544 | 37.299492 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.