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 |
|---|---|---|---|---|---|---|
OBBDetection | OBBDetection-master/mmdet/core/post_processing/merge_augs.py | import numpy as np
import torch
from mmdet.ops import nms
from ..bbox import bbox_mapping_back
def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg):
"""Merge augmented proposals (multiscale, flip, etc.)
Args:
aug_proposals (list[Tensor]): proposals from different testing
schem... | 4,171 | 34.965517 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/core/post_processing/bbox_nms.py | import torch
from mmdet.ops.nms import batched_nms
def multiclass_nms(multi_bboxes,
multi_scores,
score_thr,
nms_cfg,
max_num=-1,
score_factors=None):
"""NMS for multi-class bboxes.
Args:
multi_bboxes (Ten... | 1,892 | 31.637931 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/core/post_processing/obb/obb_merge_augs.py | import numpy as np
import torch
from mmdet.ops import nms, obb_nms, poly_nms
from mmdet.core import regular_theta, choice_by_type
from mmdet.core import hbb_mapping_back, obb_mapping_back, poly_mapping_back
pi = 3.141592
def merge_rotate_aug_proposals(aug_proposals, img_metas, rpn_test_cfg):
recovered_proposals... | 8,721 | 39.009174 | 83 | py |
OBBDetection | OBBDetection-master/mmdet/core/post_processing/obb/obb_nms.py | import torch
from mmdet.ops.nms_rotated import arb_batched_nms
from mmdet.core.bbox.transforms_obb import get_bbox_dim
def multiclass_arb_nms(multi_bboxes,
multi_scores,
score_thr,
nms_cfg,
max_num=-1,
... | 1,349 | 30.395349 | 72 | py |
OBBDetection | OBBDetection-master/mmdet/core/mask/structures.py | from abc import ABCMeta, abstractmethod
import mmcv
import numpy as np
import pycocotools.mask as maskUtils
import torch
from mmdet.ops.roi_align import roi_align
from mmdet.ops.roi_align_rotated import roi_align_rotated
class BaseInstanceMasks(metaclass=ABCMeta):
@abstractmethod
def rescale(self, scale, i... | 19,952 | 33.107692 | 136 | py |
OBBDetection | OBBDetection-master/mmdet/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 i... | 2,355 | 36.396825 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/core/mask/obb/obb_mask_target.py | import numpy as np
import torch
from torch.nn.modules.utils import _pair
def obb_mask_target(pos_proposals_list, pos_assigned_gt_inds_list,
gt_masks_list, cfg, bbox_type='hbb'):
""" Compute mask target for positive proposals in multiple images.
Args:
pos_proposals_list (list[Tenso... | 2,549 | 37.059701 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/fp16/hooks.py | import copy
import torch
import torch.nn as nn
from mmcv.runner import OptimizerHook
from ..utils.dist_utils import allreduce_grads
from .utils import cast_tensor_type
class Fp16OptimizerHook(OptimizerHook):
"""FP16 optimizer hook.
The steps of fp16 optimizer is as follows.
1. Scale the loss value.
... | 5,631 | 34.421384 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/fp16/utils.py | from collections import abc
import numpy as np
import torch
def cast_tensor_type(inputs, src_type, dst_type):
"""Recursively convert Tensor in inputs from src_type to dst_type.
Args:
inputs: Inputs that to be casted.
src_type (torch.dtype): Source type..
dst_type (torch.dtype): Desti... | 983 | 27.941176 | 76 | py |
OBBDetection | OBBDetection-master/mmdet/core/fp16/decorators.py | import functools
from inspect import getfullargspec
import torch
from .utils import cast_tensor_type
def auto_fp16(apply_to=None, out_fp32=False):
"""Decorator to enable fp16 training automatically.
This decorator is useful when you write custom modules and want to support
mixed precision training. If ... | 6,471 | 38.224242 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/demodata.py | import numpy as np
import torch
def ensure_rng(rng=None):
"""
Simple version of the ``kwarray.ensure_rng``
Args:
rng (int | numpy.random.RandomState | None):
if None, then defaults to the global rng. Otherwise this can be an
integer or a RandomState class
Returns:
... | 1,836 | 25.242857 | 101 | py |
OBBDetection | OBBDetection-master/mmdet/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" and
"verti... | 5,072 | 30.70625 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/assigners/assign_result.py | import torch
from 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 (LongTensor): for each ... | 7,707 | 36.417476 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,110 | 42.09697 | 87 | py |
OBBDetection | OBBDetection-master/mmdet/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)
... | 14,622 | 44.272446 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/assigners/obb2hbb_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
from ..transforms_obb import obb2hbb
@BBOX_ASSIGNERS.register_module()
class OBB2HBBMaxIoUAssigner(BaseAssigner):
"""Assign a corre... | 9,881 | 44.539171 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,948 | 43.066667 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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 |
OBBDetection | OBBDetection-master/mmdet/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 |
OBBDetection | OBBDetection-master/mmdet/core/bbox/transforms_obb/misc.py | import numpy as np
import torch
pi = 3.141592
def get_bbox_type(bboxes, with_score=False):
dim = bboxes.size(-1)
if with_score:
dim -= 1
if dim == 4:
return 'hbb'
if dim == 5:
return 'obb'
if dim == 8:
return 'poly'
return 'notype'
def get_bbox_dim(bbox_typ... | 4,381 | 28.213333 | 86 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/transforms_obb/form.py | import cv2
import numpy as np
import torch
from .misc import get_bbox_type, regular_obb
pi = 3.141592
def poly2obb(polys):
polys_np = polys.detach().cpu().numpy()
order = polys_np.shape[:-1]
num_points = polys_np.shape[-1] // 2
polys_np = polys_np.reshape(-1, num_points, 2)
polys_np = polys_np.... | 3,854 | 28.653846 | 71 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/transforms_obb/mapping.py | import numpy as np
import torch
from .form import hbb2poly, poly2hbb
from .misc import regular_theta
import pdb
pi = 3.141592
def hbb_flip(bboxes, img_shape, direction='horizontal'):
assert bboxes.shape[-1] % 4 == 0
assert direction in ['horizontal', 'vertical']
flipped = bboxes.clone()
if direction... | 10,397 | 32.326923 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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):
... | 528 | 26.842105 | 60 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/tblr_bbox_coder.py | 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 encodes gt bboxes (x1, y1, x2, y2) into (top, b... | 6,572 | 38.596386 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py | 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-CNN [1]_, this coder encodes bbox (x1, y1,... | 8,130 | 36.995327 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py | 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.2524>`_,
this coder encodes bbox (x1,... | 7,321 | 35.79397 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/obb/midpoint_offset_coder.py | import numpy as np
import torch
from ..base_bbox_coder import BaseBBoxCoder
from mmdet.core.bbox.transforms_obb import obb2hbb, obb2poly, rectpoly2obb
from mmdet.core.bbox.builder import BBOX_CODERS
@BBOX_CODERS.register_module()
class MidpointOffsetCoder(BaseBBoxCoder):
def __init__(self,
targ... | 4,569 | 33.621212 | 86 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/obb/obb2obb_delta_xywht_coder.py | import numpy as np
import torch
from ..base_bbox_coder import BaseBBoxCoder
from mmdet.core.bbox.transforms_obb import regular_theta, regular_obb
from mmdet.core.bbox.builder import BBOX_CODERS
pi = 3.141592
@BBOX_CODERS.register_module()
class OBB2OBBDeltaXYWHTCoder(BaseBBoxCoder):
def __init__(self,
... | 3,440 | 33.41 | 84 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/obb/hbb2obb_delta_xywht_coder.py | import numpy as np
import torch
from ..base_bbox_coder import BaseBBoxCoder
from mmdet.core.bbox.transforms_obb import regular_theta, regular_obb
from mmdet.core.bbox.builder import BBOX_CODERS
import pdb
pi = 3.141592
@BBOX_CODERS.register_module()
class HBB2OBBDeltaXYWHTCoder(BaseBBoxCoder):
def __init__(sel... | 3,695 | 32.6 | 101 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/coder/obb/gliding_vertex_coders.py | import numpy as np
import torch
from ..base_bbox_coder import BaseBBoxCoder
from mmdet.core.bbox.transforms_obb import poly2hbb
from mmdet.core.bbox.builder import BBOX_CODERS
@BBOX_CODERS.register_module()
class GVFixCoder(BaseBBoxCoder):
def encode(self, polys):
assert polys.size(1) == 8
max_x... | 3,031 | 34.255814 | 75 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/iou_calculators/iou2d_calculator.py | import torch
from .builder import IOU_CALCULATORS
@IOU_CALCULATORS.register_module()
class BboxOverlaps2D(object):
"""2D IoU Calculator"""
def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate IoU between 2D bboxes
Args:
bboxes1 (Tensor): bboxes have s... | 4,632 | 34.366412 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/iou_calculators/obb/obbiou_calculator.py | import torch
import BboxToolkit as bt
from mmdet.ops import obb_overlaps
from ..builder import IOU_CALCULATORS
@IOU_CALCULATORS.register_module()
class OBBOverlaps(object):
"""2D IoU Calculator"""
def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate IoU between 2D bboxes
... | 2,665 | 36.027778 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,270 | 39.553571 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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=Tr... | 3,869 | 36.941176 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,710 | 34.671053 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/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):
"""
Online Hard Example Mining Sampler described in [1]_.
References:
.. [1] https://arxiv.org/pdf/1604.03540.... | 4,031 | 35.990826 | 77 | py |
OBBDetection | OBBDetection-master/mmdet/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 the... | 6,689 | 41.341772 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/score_hlr_sampler.py | import torch
from mmdet.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):
"""Importance-based Sample Reweighting (ISR_N),... | 11,128 | 40.996226 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/sampling_result.py | import torch
from 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)
>>> print(f'... | 5,331 | 33.849673 | 81 | py |
OBBDetection | OBBDetection-master/mmdet/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,412 | 32.642857 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/obb/obb_ohem_sampler.py | import torch
from mmdet.core.bbox.builder import BBOX_SAMPLERS
from mmdet.core.bbox.transforms_obb import arb2roi
from .obb_base_sampler import OBBBaseSampler
@BBOX_SAMPLERS.register_module()
class OBBOHEMSampler(OBBBaseSampler):
"""
Online Hard Example Mining Sampler described in [1]_.
References:
... | 4,112 | 36.733945 | 77 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/obb/obb_random_sampler.py | import torch
from mmdet.core.bbox.builder import BBOX_SAMPLERS
from .obb_base_sampler import OBBBaseSampler
@BBOX_SAMPLERS.register_module()
class OBBRandomSampler(OBBBaseSampler):
"""Random sampler
Args:
num (int): Number of samples
pos_fraction (float): Fraction of positive samples
... | 2,743 | 35.105263 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/obb/obb_sampling_result.py | import torch
from mmdet.utils import util_mixins
class OBBSamplingResult(util_mixins.NiceRepr):
"""Bbox sampling result.
Example:
>>> # xdoctest: +IGNORE_WANT
>>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA
>>> self = SamplingResult.random(rng=10)
>>> print... | 5,352 | 33.986928 | 84 | py |
OBBDetection | OBBDetection-master/mmdet/core/bbox/samplers/obb/obb_base_sampler.py | from abc import ABCMeta, abstractmethod
import torch
from .obb_sampling_result import OBBSamplingResult
class OBBBaseSampler(metaclass=ABCMeta):
"""Base class of samplers"""
def __init__(self,
num,
pos_fraction,
neg_pos_ub=-1,
add_gt_as_pr... | 3,885 | 37.098039 | 82 | py |
OBBDetection | OBBDetection-master/mmdet/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,036 | 32.393443 | 75 | py |
OBBDetection | OBBDetection-master/mmdet/core/utils/misc.py | from functools import partial
import mmcv
import numpy as np
import torch
from six.moves import map, zip
def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
"""Convert tensor to images
Args:
tensor (torch.Tensor): Tensor that contains multiple images
mean (tuple[float], opti... | 2,191 | 31.235294 | 77 | py |
OBBDetection | OBBDetection-master/mmdet/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 |
OBBDetection | OBBDetection-master/mmdet/core/anchor/anchor_generator.py | import 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[int] | list[tuple[int, int]])... | 25,501 | 42.370748 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,494 | 33.652778 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/core/anchor/obb/theta0_anchor_generator.py | import torch
from ..builder import ANCHOR_GENERATORS
from ..anchor_generator import AnchorGenerator
@ANCHOR_GENERATORS.register_module()
class Theta0AnchorGenerator(AnchorGenerator):
def single_level_grid_anchors(self,
base_anchors,
featmap_size... | 832 | 33.708333 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/builder.py | 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 build(cfg, registry,... | 1,623 | 22.882353 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/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,471 | 34.079812 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/base.py | import warnings
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.utils import print_log
from mmdet.core import auto_fp16
from mmdet.utils import get_root_logger
class BaseDetector(... | 13,434 | 37.82948 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/single_stage.py | 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 directly and ... | 4,363 | 34.770492 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/reppoints_detector.py | import torch
from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms
from ..builder import DETECTORS
from .single_stage import SingleStageDetector
@DETECTORS.register_module()
class RepPointsDetector(SingleStageDetector):
"""RepPoints: Point Set Representation for Object Detection.
This de... | 3,628 | 36.802083 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/rpn.py | import mmcv
from mmdet.core import bbox_mapping, tensor2imgs
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,
backbo... | 5,796 | 36.4 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/obb/obb_single_stage.py | import torch.nn as nn
from mmdet.core import arb2result
from mmdet.models.builder import DETECTORS, build_backbone, build_head, build_neck
from .obb_base import OBBBaseDetector
@DETECTORS.register_module()
class OBBSingleStageDetector(OBBBaseDetector):
"""Base class for single-stage detectors.
Single-stage ... | 4,548 | 35.392 | 85 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/obb/obb_rpn.py | import BboxToolkit as bt
import mmcv
import numpy as np
from mmdet.core import arb_mapping, tensor2imgs
from mmdet.models.builder import DETECTORS, build_backbone, build_head, build_neck
from .obb_base import OBBBaseDetector
from .obb_test_mixins import RotateAugRPNTestMixin
@DETECTORS.register_module()
class OBBRPN... | 7,411 | 36.816327 | 85 | py |
OBBDetection | OBBDetection-master/mmdet/models/detectors/obb/obb_two_stage.py | import torch
import torch.nn as nn
# from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler
from mmdet.models.builder import DETECTORS, build_backbone, build_head, build_neck
from .obb_base import OBBBaseDetector
from .obb_test_mixins import RotateAugRPNTestMixin
@DETECTORS.register_module()
cla... | 8,263 | 35.087336 | 85 | py |
OBBDetection | OBBDetection-master/mmdet/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
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 in DetectoRS
... | 4,212 | 33.252033 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/necks/pafpn.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmdet.core 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 in... | 5,431 | 38.362319 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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 mmdet.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,162 | 37.04321 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,668 | 38.809701 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/necks/fpn.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, xavier_init
from mmdet.core import auto_fp16
from ..builder import NECKS
@NECKS.register_module()
class FPN(nn.Module):
"""
Feature Pyramid Network.
This is an implementation of - Feature Pyramid Networks for Object
... | 9,275 | 41.550459 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/necks/nas_fpn.py | import torch.nn as nn
from mmcv.cnn import ConvModule, caffe2_xavier_init
from mmdet.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 ... | 6,538 | 39.614907 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/necks/bfp.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, xavier_init
from mmdet.ops import NonLocal2D
from ..builder import NECKS
@NECKS.register_module()
class BFP(nn.Module):
"""BFP (Balanced Feature Pyrmamids)
BFP takes multi-level features as inputs and gather them into a s... | 3,662 | 34.221154 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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 Pyrmamids)
arXiv: https://arxiv.... | 3,405 | 32.392157 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/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,798 | 35.350649 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/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 mmdet.core import (PointGenerator, build_assigner, build_sampler,
images_to_levels, multi_apply, multiclass_nms, unmap)
from mmcv.ops import DeformConv2d
from ..builder i... | 34,964 | 45.25 | 101 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/fsaf_head.py | import numpy as np
import torch
from mmcv.cnn import normal_init
from mmdet.core import (anchor_inside_flags, force_fp32, images_to_levels,
multi_apply, unmap)
from ..builder import HEADS
from ..losses.utils import weight_reduce_loss
from .retina_head import RetinaHead
@HEADS.register_module(... | 17,893 | 43.401985 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/atss_head.py | import torch
import torch.distributed as dist
import torch.nn as nn
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmdet.core import (anchor_inside_flags, build_assigner, build_sampler,
force_fp32, images_to_levels, multi_apply,
multiclass_... | 27,723 | 42.25117 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/rpn_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import normal_init
from mmdet.ops import batched_nms
from ..builder import HEADS
from .anchor_head import AnchorHead
from .rpn_test_mixin import RPNTestMixin
@HEADS.register_module()
class RPNHead(RPNTestMixin, AnchorHead):
"""RPN h... | 7,025 | 40.573964 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/anchor_head.py | import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
force_fp32, images_to_levels, multi_apply,
multiclass_nms, un... | 29,672 | 44.650769 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/retina_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from ..builder import HEADS
from .anchor_head import AnchorHead
@HEADS.register_module()
class RetinaHead(AnchorHead):
"""An anchor-based head used in
`RetinaNet <https://arxiv.org/pdf/1708.02002.pdf>`_.
The head con... | 4,050 | 34.226087 | 76 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/ga_rpn_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import normal_init
from mmdet.ops import nms
from ..builder import HEADS
from .guided_anchor_head import GuidedAnchorHead
from .rpn_test_mixin import RPNTestMixin
@HEADS.register_module()
class GARPNHead(RPNTestMixin, GuidedAnchorHead):... | 5,325 | 38.161765 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/ga_retina_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmdet.ops import MaskedConv2d
from ..builder import HEADS
from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead
@HEADS.register_module()
class GARetinaHead(GuidedAnchorHead):
"""Guided-Anchor-based RetinaNet ... | 3,893 | 34.4 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/ssd_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import xavier_init
from mmdet.core import (build_anchor_generator, build_assigner,
build_bbox_coder, build_sampler, multi_apply)
from ..builder import HEADS
from ..losses import smooth_l1_loss
from .anchor_head imp... | 10,994 | 40.179775 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/fcos_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import Scale, normal_init
from mmdet.core import distance2bbox, force_fp32, multi_apply, multiclass_nms
from ..builder import HEADS, build_loss
from .anchor_free_head import AnchorFreeHead
INF = 1e8
@HEADS.register_module()
class FCOSH... | 24,964 | 43.660107 | 113 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/retina_sepbn_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from ..builder import HEADS
from .anchor_head import AnchorHead
@HEADS.register_module()
class RetinaSepBNHead(AnchorHead):
""""RetinaHead with separate BN.
In RetinaHead, conv/norm layers are shared across different FPN... | 4,288 | 36.622807 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/anchor_free_head.py | from abc import abstractmethod
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmdet.core import force_fp32, multi_apply
from ..builder import HEADS, build_loss
from .base_dense_head import BaseDenseHead
@HEADS.register_module()
class AnchorFreeHead(BaseDens... | 13,101 | 38.70303 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/pisa_ssd_head.py | import torch
from mmdet.core import multi_apply
from ..builder import HEADS
from ..losses import CrossEntropyLoss, SmoothL1Loss, carl_loss, isr_p
from .ssd_head import SSDHead
# TODO: add loss evaluator for SSD
@HEADS.register_module()
class PISASSDHead(SSDHead):
def loss(self,
cls_scores,
... | 5,551 | 38.657143 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/pisa_retinanet_head.py | import torch
from mmdet.core import force_fp32, images_to_levels
from ..builder import HEADS
from ..losses import carl_loss, isr_p
from .retina_head import RetinaHead
@HEADS.register_module()
class PISARetinaHead(RetinaHead):
"""PISA Retinanet Head.
The head owns the same structure with Retinanet Head, but ... | 6,197 | 39.246753 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/gfl_head.py | import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmdet.core import (anchor_inside_flags, bbox2distance, bbox_overlaps,
build_assigner, build_sampler, distance2bbox,
... | 27,152 | 41.895735 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/base_dense_head.py | from abc import ABCMeta, abstractmethod
import torch.nn as nn
class BaseDenseHead(nn.Module, metaclass=ABCMeta):
"""Base class for DenseHeads"""
def __init__(self):
super(BaseDenseHead, self).__init__()
@abstractmethod
def loss(self, **kwargs):
"""Compute losses of the head."""
... | 2,050 | 33.183333 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/free_anchor_retina_head.py | import torch
import torch.nn.functional as F
from mmdet.core import bbox_overlaps
from ..builder import HEADS
from .retina_head import RetinaHead
@HEADS.register_module()
class FreeAnchorRetinaHead(RetinaHead):
"""FreeAnchor RetinaHead used in https://arxiv.org/abs/1909.02466.
Args:
num_classes (int... | 10,967 | 40.233083 | 94 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/guided_anchor_head.py | import torch
import torch.nn as nn
from mmcv.cnn import bias_init_with_prob, normal_init
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
calc_region, force_fp32, images_to_levels, multi_apply,
... | 36,801 | 41.496536 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/fovea_head.py | import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmdet.core import multi_apply, multiclass_nms
from mmcv.ops import DeformConv2d
from ..builder import HEADS
from .anchor_free_head import AnchorFreeHead
INF = 1e8
class FeatureAlign(nn.Module):
def __init__(self,
... | 14,447 | 41.122449 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/s2a_head.py | from copy import deepcopy
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmcv.ops import DeformConv2dPack, DeformConv2d
from mmdet.core import get_bbox_dim
from mmdet.models.builder import HEADS, build_head
from ..base_dense_head import BaseDenseHead
class AlignConv(nn.Module):... | 10,715 | 38.397059 | 100 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/obb_anchor_head.py | import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
force_fp32, images_to_levels, multi_apply, unmap,
get_bbox_ty... | 31,430 | 45.019034 | 87 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/obb_fcos_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import Scale, normal_init
from mmdet.core import (distance2obb, force_fp32, multi_apply, multiclass_arb_nms,
mintheta_obb)
from mmdet.models.builder import HEADS, build_loss
from .obb_anchor_free_head import OBBAnc... | 25,860 | 43.434708 | 113 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/odm_head.py | import torch
from mmcv.cnn import ConvModule, normal_init, bias_init_with_prob
from mmdet.ops.orn import ORConv2d, RotationInvariantPooling
from torch import nn
from mmdet.core import get_bbox_dim, build_bbox_coder, build_assigner, build_sampler, build_anchor_generator, \
multi_apply, images_to_levels, force_fp32
... | 11,783 | 37.891089 | 111 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/obb_anchor_free_head.py | from abc import abstractmethod
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmdet.core import force_fp32, multi_apply, get_bbox_dim
from mmdet.models.builder import HEADS, build_loss
from ..base_dense_head import BaseDenseHead
@HEADS.register_module()
cla... | 13,346 | 38.841791 | 81 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/oriented_rpn_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import normal_init
from mmdet.ops import arb_batched_nms
from mmdet.core import obb2hbb
from mmdet.models.builder import HEADS
from .obb_anchor_head import OBBAnchorHead
from ..rpn_test_mixin import RPNTestMixin
@HEADS.register_module()... | 7,288 | 39.949438 | 84 | py |
OBBDetection | OBBDetection-master/mmdet/models/dense_heads/obb/obb_retina_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmdet.models.builder import HEADS
from .obb_anchor_head import OBBAnchorHead
@HEADS.register_module()
class OBBRetinaHead(OBBAnchorHead):
def __init__(self,
num_classes,
in_channels,
... | 3,432 | 33.33 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/utils/res_layer.py | from 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): planes of block.
... | 3,655 | 34.495146 | 77 | py |
OBBDetection | OBBDetection-master/mmdet/models/roi_heads/standard_roi_head.py | import torch
from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler
from ..builder import HEADS, build_head, build_roi_extractor
from .base_roi_head import BaseRoIHead
from .test_mixins import BBoxTestMixin, MaskTestMixin
@HEADS.register_module()
class StandardRoIHead(BaseRoIHead, BBoxTestMixin,... | 12,234 | 41.044674 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/roi_heads/grid_roi_head.py | import torch
from mmdet.core import bbox2result, bbox2roi
from ..builder import HEADS, build_head, build_roi_extractor
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class GridRoIHead(StandardRoIHead):
"""Grid roi head for Grid R-CNN.
https://arxiv.org/abs/1811.12030
"""
de... | 6,579 | 38.878788 | 78 | py |
OBBDetection | OBBDetection-master/mmdet/models/roi_heads/cascade_roi_head.py | import torch
import torch.nn as nn
from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner,
build_sampler, merge_aug_bboxes, merge_aug_masks,
multiclass_nms)
from ..builder import HEADS, build_head, build_roi_extractor
from .base_roi_head import BaseR... | 19,429 | 42.273942 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/roi_heads/dynamic_roi_head.py | import numpy as np
import torch
from mmdet.core import bbox2roi
from mmdet.models.losses import SmoothL1Loss
from ..builder import HEADS
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class DynamicRoIHead(StandardRoIHead):
"""RoI head for `Dynamic R-CNN <https://arxiv.org/abs/2004.06002>... | 6,484 | 41.94702 | 79 | py |
OBBDetection | OBBDetection-master/mmdet/models/roi_heads/point_rend_roi_head.py | # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa
import torch
import torch.nn.functional as F
from mmdet.core import bbox2roi, bbox_mapping, merge_aug_masks
from mmdet.ops import point_sample, rel_roi_point_to_rel_img_point
from .. import builder
from ..builder imp... | 9,096 | 45.651282 | 101 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.