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/mmseg/models/decode_heads/gc_head.py
import torch from annotator.uniformer.mmcv.cnn import ContextBlock from ..builder import HEADS from .fcn_head import FCNHead @HEADS.register_module() class GCHead(FCNHead): """GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond. This head is the implementation of `GCNet <https://arxiv....
1,611
32.583333
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/decode_heads/point_head.py
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, normal_init from annotator.uniformer.mmcv.ops import point_sample from annotator.uniformer.mmseg.models...
14,754
41.157143
126
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/se_layer.py
import annotator.uniformer.mmcv as mmcv import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from .make_divisible import make_divisible class SELayer(nn.Module): """Squeeze-and-Excitation Module. Args: channels (int): The input (and output) channels of the SE layer. rati...
2,151
36.103448
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/weight_init.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/layers/drop.py.""" import math import warnings import torch def _no_grad_trunc_normal_(tensor, mean, std, a, b): """Reference: https://people.sc.fsu.edu/~jburkardt/presentations /truncated_normal.pdf""" def norm...
2,327
35.952381
76
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/res_layer.py
from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from torch import nn as nn class ResLayer(nn.Sequential): """ResLayer to build ResNet style backbone. Args: block (nn.Module): block used to build ResLayer. inplanes (int): inplanes of block. planes (int): pla...
3,335
34.115789
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/self_attention_block.py
import torch from annotator.uniformer.mmcv.cnn import ConvModule, constant_init from torch import nn as nn from torch.nn import functional as F class SelfAttentionBlock(nn.Module): """General self-attention block/non-local block. Please refer to https://arxiv.org/abs/1706.03762 for details about key, que...
6,145
37.4125
78
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/up_conv_block.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, build_upsample_layer class UpConvBlock(nn.Module): """Upsample convolution block in decoder for UNet. This upsample convolution block consists of one upsample module followed by one convolution block. The upsample mod...
3,988
38.107843
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/inverted_residual.py
from annotator.uniformer.mmcv.cnn import ConvModule from torch import nn from torch.utils import checkpoint as cp from .se_layer import SELayer class InvertedResidual(nn.Module): """InvertedResidual block for MobileNetV2. Args: in_channels (int): The input channels of the InvertedResidual block. ...
7,025
32.617225
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/utils/drop.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/layers/drop.py.""" import torch from torch import nn class DropPath(nn.Module): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). Args: drop_prob (float): Drop r...
1,015
30.75
78
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/segmentors/base.py
import logging import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict import annotator.uniformer.mmcv as mmcv import numpy as np import torch import torch.distributed as dist import torch.nn as nn from annotator.uniformer.mmcv.runner import auto_fp16 class BaseSegmentor(nn.Module...
10,398
36.952555
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/segmentors/cascade_encoder_decoder.py
from torch import nn from annotator.uniformer.mmseg.core import add_prefix from annotator.uniformer.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .encoder_decoder import EncoderDecoder @SEGMENTORS.register_module() class CascadeEncoderDecoder(EncoderDecoder): """Cascade Enc...
3,708
36.464646
78
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/segmentors/encoder_decoder.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmseg.core import add_prefix from annotator.uniformer.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .base import BaseSegmentor @SEGMENTORS.register_module() class EncoderDecoder(BaseSegm...
11,344
36.943144
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/losses/dice_loss.py
"""Modified from https://github.com/LikeLy-Journey/SegmenTron/blob/master/ segmentron/solver/loss.py (Apache-2.0 License)""" import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weighted_loss @weighted_loss def dice_loss(pred, ...
4,239
34.333333
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/losses/lovasz_loss.py
"""Modified from https://github.com/bermanmaxim/LovaszSoftmax/blob/master/pytor ch/lovasz_losses.py Lovasz-Softmax and Jaccard hinge loss in PyTorch Maxim Berman 2018 ESAT-PSI KU Leuven (MIT License)""" import annotator.uniformer.mmcv as mmcv import torch import torch.nn as nn import torch.nn.functional as F from ..b...
11,419
36.565789
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/losses/utils.py
import functools import annotator.uniformer.mmcv as mmcv import numpy as np import torch.nn.functional as F def get_class_weight(class_weight): """Get class weight for loss function. Args: class_weight (list[float] | str | None): If class_weight is a str, take it as a file name and read ...
3,718
29.483607
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/losses/accuracy.py
import torch.nn as nn def accuracy(pred, target, topk=1, thresh=None): """Calculate accuracy according to the prediction and target. Args: pred (torch.Tensor): The model prediction, shape (N, num_class, ...) target (torch.Tensor): The target of each prediction, shape (N, , ...) topk (...
2,970
36.607595
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weight_reduce_loss def cross_entropy(pred, label, weight=None, class_weight=None, reduction='mean', ...
7,437
36.376884
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/hrnet.py
import torch.nn as nn from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper import _BatchNorm from annotator.uniformer.mmseg.ops imp...
21,226
37.178058
92
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/mobilenet_v2.py
import logging import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from ..utils import InvertedResidual, make_divisible @BA...
6,981
37.574586
80
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/fast_scnn.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import (ConvModule, DepthwiseSeparableConvModule, constant_init, kaiming_init) from torch.nn.modules.batchnorm import _BatchNorm from annotator.uniformer.mmseg.models.decode_heads.psp_head import PPM from annotator.uniformer.mms...
14,436
37.396277
98
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/resnet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, build_plugin_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper i...
24,310
34.28447
97
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/cgnet.py
import torch import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (ConvModule, build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrap...
13,183
34.826087
89
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/vit.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/vision_transformer.py.""" import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (Conv2d, Linear, build_activation_layer, bui...
18,085
38.317391
128
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/resnext.py
import math from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ResNet class Bottleneck(_Bottleneck): """Bottleneck block for ResNeXt. If style is "pytorch"...
5,161
34.356164
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/mobilenet_v3.py
import logging import annotator.uniformer.mmcv as mmcv import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.cnn.bricks import Conv2dAdaptivePadding from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm...
10,390
39.589844
80
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/unet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (UPSAMPLE_LAYERS, ConvModule, build_activation_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.pa...
18,269
41.488372
94
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/resnest.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ...
10,110
31.098413
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/models/backbones/uniformer.py
# -------------------------------------------------------- # UniFormer # Copyright (c) 2022 SenseTime X-Lab # Licensed under The MIT License [see LICENSE for details] # Written by Kunchang Li # -------------------------------------------------------- from collections import OrderedDict import math from functools impo...
18,476
42.680851
145
py
UniControl
UniControl-main/annotator/uniformer/mmseg/datasets/custom.py
import os import os.path as osp from collections import OrderedDict from functools import reduce import annotator.uniformer.mmcv as mmcv import numpy as np from annotator.uniformer.mmcv.utils import print_log from prettytable import PrettyTable from torch.utils.data import Dataset from annotator.uniformer.mmseg.core ...
14,716
35.700748
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/datasets/dataset_wrappers.py
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .builder import DATASETS @DATASETS.register_module() class ConcatDataset(_ConcatDataset): """A wrapper of concatenated dataset. Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but concat the group flag for image aspect rati...
1,499
28.411765
78
py
UniControl
UniControl-main/annotator/uniformer/mmseg/datasets/builder.py
import copy import platform import random from functools import partial import numpy as np from annotator.uniformer.mmcv.parallel import collate from annotator.uniformer.mmcv.runner import get_dist_info from annotator.uniformer.mmcv.utils import Registry, build_from_cfg from annotator.uniformer.mmcv.utils.parrots_wrap...
5,951
34.011765
85
py
UniControl
UniControl-main/annotator/uniformer/mmseg/datasets/pipelines/formating.py
from collections.abc import Sequence import annotator.uniformer.mmcv as mmcv import numpy as np import torch from annotator.uniformer.mmcv.parallel import DataContainer as DC from ..builder import PIPELINES def to_tensor(data): """Convert objects of various python types to :obj:`torch.Tensor`. Supported ty...
9,276
31.100346
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/ops/wrappers.py
import warnings import torch.nn as nn import torch.nn.functional as F def resize(input, size=None, scale_factor=None, mode='nearest', align_corners=None, warning=True): if warning: if size is not None and align_corners: input_h, input_w =...
1,827
34.843137
79
py
UniControl
UniControl-main/annotator/uniformer/mmseg/ops/encoding.py
import torch from torch import nn from torch.nn import functional as F class Encoding(nn.Module): """Encoding Layer: a learnable residual encoder. Input is of shape (batch_size, channels, height, width). Output is of shape (batch_size, num_codes, channels). Args: channels: dimension of the ...
2,788
36.186667
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/apis/inference.py
import warnings import annotator.uniformer.mmcv as mmcv import numpy as np import torch # from annotator.uniformer.mmcv.ops import RoIPool from annotator.uniformer.mmcv.parallel import collate, scatter from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmdet.core import get_classes ...
7,413
32.853881
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/apis/test.py
import os.path as osp import pickle import shutil import tempfile import time import mmcv import torch import torch.distributed as dist from mmcv.image import tensor2imgs from mmcv.runner import get_dist_info from mmdet.core import encode_mask_results def single_gpu_test(model, data_loader, ...
6,826
34.743455
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/apis/train.py
import random import warnings import numpy as np import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, Fp16OptimizerHook, OptimizerHook, build_optimizer, build_runner) fro...
6,899
36.096774
102
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/evaluation/eval_hooks.py
import os.path as osp import warnings from math import inf import annotator.uniformer.mmcv as mmcv import torch.distributed as dist from annotator.uniformer.mmcv.runner import Hook from torch.nn.modules.batchnorm import _BatchNorm from torch.utils.data import DataLoader from annotator.uniformer.mmdet.utils import get...
12,553
40.296053
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/post_processing/merge_augs.py
import copy import warnings import numpy as np import torch from mmcv import ConfigDict from mmcv.ops import nms from ..bbox import bbox_mapping_back def merge_aug_proposals(aug_proposals, img_metas, cfg): """Merge augmented proposals (multiscale, flip, etc.) Args: aug_proposals (list[Tensor]): pro...
5,605
36.125828
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/post_processing/bbox_nms.py
import torch from mmcv.ops.nms import batched_nms from mmdet.core.bbox.iou_calculators import bbox_overlaps def multiclass_nms(multi_bboxes, multi_scores, score_thr, nms_cfg, max_num=-1, score_factors=None, ...
6,269
36.100592
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/mask/structures.py
from abc import ABCMeta, abstractmethod import cv2 import mmcv import numpy as np import pycocotools.mask as maskUtils import torch from mmcv.ops.roi_align import roi_align class BaseInstanceMasks(metaclass=ABCMeta): """Base class for instance masks.""" @abstractmethod def rescale(self, scale, interpola...
38,118
36.189268
141
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/mask/mask_target.py
import numpy as np import torch from torch.nn.modules.utils import _pair def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, cfg): """Compute mask target for positive proposals in multiple images. Args: pos_proposals_list (list[Tensor]): Positive proposals in...
4,958
39.317073
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/export/pytorch2onnx.py
from functools import partial import mmcv import numpy as np import torch from mmcv.runner import load_checkpoint def generate_inputs_and_wrap_model(config_path, checkpoint_path, input_config, cfg_options=None): ...
5,779
36.290323
77
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/export/__init__.py
from .pytorch2onnx import (build_model_from_cfg, generate_inputs_and_wrap_model, preprocess_example_input) __all__ = [ 'build_model_from_cfg', 'generate_inputs_and_wrap_model', 'preprocess_example_input' ]
269
29
61
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/demodata.py
import numpy as np import torch from mmdet.utils.util_random import ensure_rng def random_boxes(num=1, scale=1, rng=None): """Simple version of ``kwimage.Boxes.random`` Returns: Tensor: shape (n, 4) in x1, y1, x2, y2 format. References: https://gitlab.kitware.com/computer-vision/kwimage...
1,133
26
101
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/transforms.py
import numpy as np import torch def bbox_flip(bboxes, img_shape, direction='horizontal'): """Flip bboxes horizontally or vertically. Args: bboxes (Tensor): Shape (..., 4*k) img_shape (tuple): Image shape. direction (str): Flip direction, options are "horizontal", "vertical", ...
7,899
31.780083
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/assign_result.py
import torch from annotator.uniformer.mmdet.utils import util_mixins class AssignResult(util_mixins.NiceRepr): """Stores assignments between predicted and truth boxes. Attributes: num_gts (int): the number of truth boxes considered when computing this assignment gt_inds (LongTen...
7,725
36.687805
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/atss_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class ATSSAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
7,761
42.363128
87
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/center_region_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner def scale_boxes(bboxes, scale): """Expand an array of boxes by a given scale. Args: bboxes (Tensor): Shape (m, 4) ...
15,429
44.922619
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/region_assigner.py
import torch from annotator.uniformer.mmdet.core import anchor_inside_flags from ..builder import BBOX_ASSIGNERS from .assign_result import AssignResult from .base_assigner import BaseAssigner def calc_region(bbox, ratio, stride, featmap_size=None): """Calculate region of the box defined by the ratio, the ratio ...
9,432
41.490991
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/grid_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class GridAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
6,816
42.698718
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/hungarian_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..match_costs import build_match_cost from ..transforms import bbox_cxcywh_to_xyxy from .assign_result import AssignResult from .base_assigner import BaseAssigner try: from scipy.optimize import linear_sum_assignment except ImportError: linear_sum_assignm...
6,617
44.328767
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/point_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class PointAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each point. Each proposals will be assigned with `0`, or a...
5,947
43.38806
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/approx_max_iou_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .max_iou_assigner import MaxIoUAssigner @BBOX_ASSIGNERS.register_module() class ApproxMaxIoUAssigner(MaxIoUAssigner): """Assign a corresponding gt bbox or background to each bbox. Each proposals will be...
6,649
44.547945
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/assigners/max_iou_assigner.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class MaxIoUAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
9,750
44.779343
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/match_costs/match_cost.py
import torch from annotator.uniformer.mmdet.core.bbox.iou_calculators import bbox_overlaps from annotator.uniformer.mmdet.core.bbox.transforms import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh from .builder import MATCH_COST @MATCH_COST.register_module() class BBoxL1Cost(object): """BBoxL1Cost. Args: ...
6,366
33.416216
99
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/yolo_bbox_coder.py
import annotator.uniformer.mmcv as mmcv import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class YOLOBBoxCoder(BaseBBoxCoder): """YOLO BBox coder. Following `YOLO <https://arxiv.org/abs/1506.02640>`_, this coder divide image into grid...
3,515
38.066667
77
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/bucketing_bbox_coder.py
import annotator.uniformer.mmcv as mmcv import numpy as np import torch import torch.nn.functional as F from ..builder import BBOX_CODERS from ..transforms import bbox_rescale from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class BucketingBBoxCoder(BaseBBoxCoder): """Bucketing BBox Code...
14,099
39.17094
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/pseudo_bbox_coder.py
from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class PseudoBBoxCoder(BaseBBoxCoder): """Pseudo bounding box coder.""" def __init__(self, **kwargs): super(BaseBBoxCoder, self).__init__(**kwargs) def encode(self, bboxes, gt_bboxes): ...
529
26.894737
60
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/tblr_bbox_coder.py
import annotator.uniformer.mmcv as mmcv import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class TBLRBBoxCoder(BaseBBoxCoder): """TBLR BBox coder. Following the practice in `FSAF <https://arxiv.org/abs/1903.00621>`_, this coder encode...
8,236
40.39196
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/legacy_delta_xywh_bbox_coder.py
import annotator.uniformer.mmcv as mmcv import numpy as np import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class LegacyDeltaXYWHBBoxCoder(BaseBBoxCoder): """Legacy Delta XYWH BBox coder used in MMDet V1.x. Following the practice in R-C...
8,237
37.138889
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/coder/delta_xywh_bbox_coder.py
import annotator.uniformer.mmcv as mmcv import numpy as np import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class DeltaXYWHBBoxCoder(BaseBBoxCoder): """Delta XYWH BBox coder. Following the practice in `R-CNN <https://arxiv.org/abs/1311....
9,310
38.121849
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/iou_calculators/iou2d_calculator.py
import torch from .builder import IOU_CALCULATORS @IOU_CALCULATORS.register_module() class BboxOverlaps2D(object): """2D Overlaps (e.g. IoUs, GIoUs) Calculator.""" def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False): """Calculate IoU between 2D bboxes. Args: bboxe...
6,182
37.64375
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/instance_balanced_pos_sampler.py
import numpy as np import torch from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler @BBOX_SAMPLERS.register_module() class InstanceBalancedPosSampler(RandomSampler): """Instance balanced sampler that samples equal number of positive samples for each instance.""" def _sample_pos...
2,271
39.571429
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/base_sampler.py
from abc import ABCMeta, abstractmethod import torch from .sampling_result import SamplingResult class BaseSampler(metaclass=ABCMeta): """Base class of samplers.""" def __init__(self, num, pos_fraction, neg_pos_ub=-1, add_gt_as_proposals=T...
3,872
36.970588
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/random_sampler.py
import torch from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module() class RandomSampler(BaseSampler): """Random sampler. Args: num (int): Number of samples pos_fraction (float): Fraction of positive samples neg_pos_up (int, optional...
2,817
34.670886
76
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/ohem_sampler.py
import torch from ..builder import BBOX_SAMPLERS from ..transforms import bbox2roi from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module() class OHEMSampler(BaseSampler): r"""Online Hard Example Mining Sampler described in `Training Region-based Object Detectors with Online Hard Example Mining...
4,098
36.953704
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/iou_balanced_neg_sampler.py
import numpy as np import torch from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler @BBOX_SAMPLERS.register_module() class IoUBalancedNegSampler(RandomSampler): """IoU Balanced Sampling. arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) Sampling proposals according to th...
6,692
41.360759
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/score_hlr_sampler.py
import torch from annotator.uniformer.mmcv.ops import nms_match from ..builder import BBOX_SAMPLERS from ..transforms import bbox2roi from .base_sampler import BaseSampler from .sampling_result import SamplingResult @BBOX_SAMPLERS.register_module() class ScoreHLRSampler(BaseSampler): r"""Importance-based Sample ...
11,207
41.29434
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/sampling_result.py
import torch from annotator.uniformer.mmdet.utils import util_mixins class SamplingResult(util_mixins.NiceRepr): """Bbox sampling result. Example: >>> # xdoctest: +IGNORE_WANT >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA >>> self = SamplingResult.random(rng=10) ...
5,354
34
81
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/bbox/samplers/pseudo_sampler.py
import torch from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler from .sampling_result import SamplingResult @BBOX_SAMPLERS.register_module() class PseudoSampler(BaseSampler): """A pseudo sampler that does not do sampling actually.""" def __init__(self, **kwargs): pass def...
1,415
32.714286
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/utils/dist_utils.py
import warnings from collections import OrderedDict import torch.distributed as dist from mmcv.runner import OptimizerHook from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_dense_tensors) def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): if buck...
2,327
32.257143
77
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/utils/misc.py
from functools import partial import numpy as np import torch from six.moves import map, zip from ..mask.structures import BitmapMasks, PolygonMasks def multi_apply(func, *args, **kwargs): """Apply function to a list of arguments. Note: This function applies the ``func`` to multiple inputs and ...
1,865
29.096774
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/anchor/point_generator.py
import torch from .builder import ANCHOR_GENERATORS @ANCHOR_GENERATORS.register_module() class PointGenerator(object): def _meshgrid(self, x, y, row_major=True): xx = x.repeat(len(y)) yy = y.view(-1, 1).repeat(1, len(x)).view(-1) if row_major: return xx, yy else: ...
1,362
34.868421
70
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/anchor/anchor_generator.py
import annotator.uniformer.mmcv as mmcv import numpy as np import torch from torch.nn.modules.utils import _pair from .builder import ANCHOR_GENERATORS @ANCHOR_GENERATORS.register_module() class AnchorGenerator(object): """Standard anchor generator for 2D anchor-based detectors. Args: strides (list[...
31,213
41.876374
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/core/anchor/utils.py
import torch def images_to_levels(target, num_levels): """Convert targets by image to targets by feature level. [target_img0, target_img1] -> [target_level0, target_level1, ...] """ target = torch.stack(target, 0) level_targets = [] start = 0 for n in num_levels: end = start + n ...
2,497
33.694444
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/builder.py
import warnings from mmcv.utils import Registry, build_from_cfg from torch import nn BACKBONES = Registry('backbone') NECKS = Registry('neck') ROI_EXTRACTORS = Registry('roi_extractor') SHARED_HEADS = Registry('shared_head') HEADS = Registry('head') LOSSES = Registry('loss') DETECTORS = Registry('detector') def bui...
2,094
25.858974
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/two_stage.py
import torch import torch.nn as nn # from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler from ..builder import DETECTORS, build_backbone, build_head, build_neck from .base import BaseDetector @DETECTORS.register_module() class TwoStageDetector(BaseDetector): """Base class for two-stage de...
7,658
34.458333
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/base.py
from abc import ABCMeta, abstractmethod from collections import OrderedDict import mmcv import numpy as np import torch import torch.distributed as dist import torch.nn as nn from mmcv.runner import auto_fp16 from mmcv.utils import print_log from mmdet.core.visualization import imshow_det_bboxes from mmdet.utils impo...
14,245
39.016854
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/single_stage.py
import torch import torch.nn as nn from mmdet.core import bbox2result from ..builder import DETECTORS, build_backbone, build_head, build_neck from .base import BaseDetector @DETECTORS.register_module() class SingleStageDetector(BaseDetector): """Base class for single-stage detectors. Single-stage detectors ...
5,999
37.709677
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/detr.py
from mmdet.core import bbox2result from ..builder import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module() class DETR(SingleStageDetector): r"""Implementation of `DETR: End-to-End Object Detection with Transformers <https://arxiv.org/pdf/2005.12872>`_""" def __init__(se...
1,738
36
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/kd_one_stage.py
import mmcv import torch from mmcv.runner import load_checkpoint from .. import build_detector from ..builder import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module() class KnowledgeDistillationSingleStageDetector(SingleStageDetector): r"""Implementation of `Distilling the Know...
4,102
39.623762
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/yolact.py
import torch from mmdet.core import bbox2result from ..builder import DETECTORS, build_head from .single_stage import SingleStageDetector @DETECTORS.register_module() class YOLACT(SingleStageDetector): """Implementation of `YOLACT <https://arxiv.org/abs/1904.02689>`_""" def __init__(self, b...
6,129
40.70068
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/rpn.py
import mmcv from mmcv.image import tensor2imgs from mmdet.core import bbox_mapping from ..builder import DETECTORS, build_backbone, build_head, build_neck from .base import BaseDetector @DETECTORS.register_module() class RPN(BaseDetector): """Implementation of Region Proposal Network.""" def __init__(self, ...
5,811
36.496774
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/cornernet.py
import torch from mmdet.core import bbox2result, bbox_mapping_back from ..builder import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module() class CornerNet(SingleStageDetector): """CornerNet. This detector is the implementation of the paper `CornerNet: Detecting Objects...
3,578
36.28125
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/detectors/sparse_rcnn.py
from ..builder import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module() class SparseRCNN(TwoStageDetector): r"""Implementation of `Sparse R-CNN: End-to-End Object Detection with Learnable Proposals <https://arxiv.org/abs/2011.12450>`_""" def __init__(self, *args, **kwargs): ...
4,421
38.837838
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/rfp.py
import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import constant_init, kaiming_init, xavier_init from ..builder import NECKS, build_backbone from .fpn import FPN class ASPP(nn.Module): """ASPP (Atrous Spatial Pyramid Pooling) This is an implementation of the ASPP module used ...
4,592
34.604651
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/fpg.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, caffe2_xavier_init, constant_init, is_norm from ..builder import NECKS class Transition(nn.Module): """Base class for transition. Args: in_channels (int): Number of input channels. out_channels (int): Numb...
15,923
38.909774
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/pafpn.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import auto_fp16 from ..builder import NECKS from .fpn import FPN @NECKS.register_module() class PAFPN(FPN): """Path Aggregation Network for Instance Segmentation. This is an implementation of the `PAFPN i...
5,713
38.958042
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/nasfcos_fpn.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, caffe2_xavier_init from mmcv.ops.merge_cells import ConcatCell from ..builder import NECKS @NECKS.register_module() class NASFCOS_FPN(nn.Module): """FPN structure in NASFPN. Implementation of paper `NAS-FCOS: Fast Neural ...
6,164
37.055556
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/fpn_carafe.py
import torch.nn as nn from mmcv.cnn import ConvModule, build_upsample_layer, xavier_init from mmcv.ops.carafe import CARAFEPack from ..builder import NECKS @NECKS.register_module() class FPN_CARAFE(nn.Module): """FPN_CARAFE is a more flexible implementation of FPN. It allows more choice for upsample methods ...
10,671
38.820896
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/fpn.py
import warnings import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, xavier_init from mmcv.runner import auto_fp16 from ..builder import NECKS @NECKS.register_module() class FPN(nn.Module): r"""Feature Pyramid Network. This is an implementation of paper `Feature Pyramid Ne...
9,466
41.644144
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/nas_fpn.py
import torch.nn as nn from mmcv.cnn import ConvModule, caffe2_xavier_init from mmcv.ops.merge_cells import GlobalPoolingCell, SumCell from ..builder import NECKS @NECKS.register_module() class NASFPN(nn.Module): """NAS-FPN. Implementation of `NAS-FPN: Learning Scalable Feature Pyramid Architecture for O...
6,539
39.621118
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/bfp.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, xavier_init from mmcv.cnn.bricks import NonLocal2d from ..builder import NECKS @NECKS.register_module() class BFP(nn.Module): """BFP (Balanced Feature Pyramids) BFP takes multi-level features as inputs and gather them int...
3,744
34.666667
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/yolo_neck.py
# Copyright (c) 2019 Western Digital Corporation or its affiliates. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from ..builder import NECKS class DetectionBlock(nn.Module): """Detection block in YOLO neck. Let out_channels = n, the DetectionBlock conta...
5,089
36.153285
77
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/channel_mapper.py
import torch.nn as nn from mmcv.cnn import ConvModule, xavier_init from ..builder import NECKS @NECKS.register_module() class ChannelMapper(nn.Module): r"""Channel Mapper to reduce/increase channels of backbone features. This is used to reduce/increase channels of backbone features. Args: in_ch...
2,765
35.88
76
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/necks/hrfpn.py
import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, caffe2_xavier_init from torch.utils.checkpoint import checkpoint from ..builder import NECKS @NECKS.register_module() class HRFPN(nn.Module): """HRFPN (High Resolution Feature Pyramids) paper: `High-Resolutio...
3,480
32.796117
79
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/dense_heads/nasfcos_head.py
import copy import torch.nn as nn from mmcv.cnn import (ConvModule, Scale, bias_init_with_prob, caffe2_xavier_init, normal_init) from mmdet.models.dense_heads.fcos_head import FCOSHead from ..builder import HEADS @HEADS.register_module() class NASFCOSHead(FCOSHead): """Anchor-free head use...
2,793
35.763158
78
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/dense_heads/reppoints_head.py
import numpy as np import torch import torch.nn as nn from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init from mmcv.ops import DeformConv2d from mmdet.core import (PointGenerator, build_assigner, build_sampler, images_to_levels, multi_apply, multiclass_nms, unmap) from ..builder i...
35,305
45.212042
101
py
UniControl
UniControl-main/annotator/uniformer/mmdet_null/models/dense_heads/cascade_rpn_head.py
from __future__ import division import copy import warnings import torch import torch.nn as nn from mmcv import ConfigDict from mmcv.cnn import normal_init from mmcv.ops import DeformConv2d, batched_nms from mmdet.core import (RegionAssigner, build_assigner, build_sampler, images_to_levels, mu...
32,988
41.024204
79
py