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 |
|---|---|---|---|---|---|---|
detpro | detpro-main/mmdet/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... | 30,134 | 35.394928 | 141 | py |
detpro | detpro-main/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 in... | 2,354 | 36.380952 | 78 | py |
detpro | detpro-main/mmdet/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):
"""Prepare sample input and wrap model for ONNX export.
The ONNX export API only accept args, and all inputs shoul... | 5,329 | 36.013889 | 79 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/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,748 | 26.328125 | 101 | py |
detpro | detpro-main/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", "vertical",
... | 7,176 | 30.897778 | 79 | py |
detpro | detpro-main/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 predi... | 7,705 | 36.590244 | 79 | py |
detpro | detpro-main/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,760 | 42.357542 | 87 | py |
detpro | detpro-main/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)
... | 15,429 | 44.922619 | 79 | py |
detpro | detpro-main/mmdet/core/bbox/assigners/region_assigner.py | import torch
from 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 is from the
cent... | 8,714 | 41.512195 | 79 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/mmdet/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,621 | 44.356164 | 79 | py |
detpro | detpro-main/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,947 | 43.38806 | 79 | py |
detpro | detpro-main/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 |
detpro | detpro-main/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 |
detpro | detpro-main/mmdet/core/bbox/match_costs/match_cost.py | import torch
from mmdet.core.bbox.iou_calculators import bbox_overlaps
from 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:
weight (int | float, optional): loss_w... | 6,328 | 33.210811 | 79 | py |
detpro | detpro-main/mmdet/core/bbox/coder/yolo_bbox_coder.py | 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 grids, and encode bbox (x1, y1, x2, y2) into... | 3,417 | 38.287356 | 77 | py |
detpro | detpro-main/mmdet/core/bbox/coder/bucketing_bbox_coder.py | 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 Coder for Side-Aware Bounday Localization (S... | 13,982 | 39.29683 | 79 | py |
detpro | detpro-main/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):
... | 529 | 26.894737 | 60 | py |
detpro | detpro-main/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, ... | 6,993 | 39.427746 | 78 | py |
detpro | detpro-main/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,147 | 37.253521 | 79 | py |
detpro | detpro-main/mmdet/core/bbox/coder/delta_xywh_bbox_coder1.py | import 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.2524>`_,
this coder enco... | 10,897 | 39.066176 | 79 | py |
detpro | detpro-main/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,861 | 36.617225 | 79 | py |
detpro | detpro-main/mmdet/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,184 | 37.65625 | 78 | py |
detpro | detpro-main/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,271 | 39.571429 | 79 | py |
detpro | detpro-main/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=T... | 3,872 | 36.970588 | 79 | py |
detpro | detpro-main/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,817 | 34.670886 | 76 | py |
detpro | detpro-main/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):
r"""Online Hard Example Mining Sampler described in `Training Region-based
Object Detectors with Online Hard Example Mining... | 4,098 | 36.953704 | 79 | py |
detpro | detpro-main/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 th... | 6,692 | 41.360759 | 79 | py |
detpro | detpro-main/mmdet/core/bbox/samplers/score_hlr_sampler.py | import torch
from 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 Reweighting (ISR_N),... | 11,187 | 41.218868 | 79 | py |
detpro | detpro-main/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,334 | 33.869281 | 81 | py |
detpro | detpro-main/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,415 | 32.714286 | 79 | py |
detpro | detpro-main/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,327 | 32.257143 | 77 | py |
detpro | detpro-main/mmdet/core/utils/misc.py | from functools import partial
import torch
from six.moves import map, zip
def multi_apply(func, *args, **kwargs):
"""Apply function to a list of arguments.
Note:
This function applies the ``func`` to multiple inputs and
map the multiple outputs of the ``func`` into different
list. Ea... | 1,206 | 29.175 | 79 | py |
detpro | detpro-main/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 |
detpro | detpro-main/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]]... | 31,168 | 41.75583 | 79 | py |
detpro | detpro-main/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,497 | 33.694444 | 79 | py |
detpro | detpro-main/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,631 | 23 | 78 | py |
detpro | detpro-main/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,476 | 34.604762 | 91 | py |
detpro | detpro-main/mmdet/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.utils import get_root_logger
class BaseDetector(nn.Module, meta... | 14,209 | 38.91573 | 90 | py |
detpro | detpro-main/mmdet/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,729 | 37.2 | 78 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/mmdet/models/detectors/single_stage_analysis.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.utils import save_image
from mmdet.core import bbox2result
from ..builder import DETECTORS, build_backbone, build_head, build_neck
from .base_analysis import BaseDetectorAnalysis
@DETECTORS.register_module()
class SingleStageDetector... | 7,848 | 41.89071 | 137 | py |
detpro | detpro-main/mmdet/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,114 | 40.598639 | 79 | py |
detpro | detpro-main/mmdet/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,863 | 36.832258 | 78 | py |
detpro | detpro-main/mmdet/models/detectors/base_analysis.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.utils import get_root_logger
class BaseDetectorAnalysis(nn.Modu... | 14,154 | 38.64986 | 79 | py |
detpro | detpro-main/mmdet/models/detectors/rpn_head_only.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 RPNHeadOnly(BaseDetector):
"""Implementation of Region Proposal Network."""
def __init_... | 7,132 | 38.627778 | 127 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/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, 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 |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/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 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 |
detpro | detpro-main/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,671 | 38.820896 | 79 | py |
detpro | detpro-main/mmdet/models/necks/fpn_analysis.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 FPNAnalysis(nn.Module):
r"""Feature Pyramid Network.
This is an implementation of paper `Feature Py... | 9,482 | 41.716216 | 79 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/mmdet/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 Pyrmamids)
BFP takes multi-level features as inputs and gather them in... | 3,745 | 34.67619 | 79 | py |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/mmdet/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 |
detpro | detpro-main/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)
paper: `High-Resoluti... | 3,481 | 32.805825 | 79 | py |
detpro | detpro-main/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,793 | 35.763158 | 78 | py |
detpro | detpro-main/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 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 |
detpro | detpro-main/mmdet/models/dense_heads/cascade_rpn_head.py | from __future__ import division
import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmcv.ops import DeformConv2d
from mmdet.core import (RegionAssigner, build_assigner, build_sampler,
images_to_levels, multi_apply)
from ..builder import HEADS, build_head
from .base_dense_h... | 26,464 | 39.77812 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/vfnet_head.py | import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmcv.ops import DeformConv2d
from mmcv.runner import force_fp32
from mmdet.core import (bbox2distance, bbox_overlaps, build_anchor_generator,
build_assigner, build... | 35,403 | 43.533333 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/fsaf_head.py | import numpy as np
import torch
from mmcv.cnn import normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, images_to_levels, multi_apply,
unmap)
from ..builder import HEADS
from ..losses.accuracy import accuracy
from ..losses.utils import weight_reduce_loss... | 18,614 | 43.427208 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/atss_head.py | import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, build_assigner, build_sampler,
images_to_levels, multi_apply, multiclass_nms,
reduc... | 28,356 | 42.492331 | 79 | py |
detpro | detpro-main/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 mmcv.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 he... | 7,333 | 41.149425 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/anchor_head.py | import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
images_to_levels, multi_apply, multiclass_nms, unm... | 31,146 | 44.603221 | 79 | py |
detpro | detpro-main/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):
r"""An anchor-based head used in `RetinaNet
<https://arxiv.org/pdf/1708.02002.pdf>`_.
The head co... | 4,051 | 34.234783 | 76 | py |
detpro | detpro-main/mmdet/models/dense_heads/fcos_head_analysis.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.utils import save_image
from mmcv.cnn import Scale, normal_init
from mmcv.runner import force_fp32
from mmdet.core import distance2bbox, multi_apply, multiclass_nms
from ..builder import HEADS, build_loss
from .anchor_free_head_analys... | 26,377 | 43.557432 | 148 | py |
detpro | detpro-main/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 mmcv.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,247 | 38.164179 | 79 | py |
detpro | detpro-main/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 mmcv.ops import MaskedConv2d
from ..builder import HEADS
from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead
@HEADS.register_module()
class GARetinaHead(GuidedAnchorHead):
"""Guided-Anchor-based RetinaNet h... | 3,876 | 34.245455 | 78 | py |
detpro | detpro-main/mmdet/models/dense_heads/base_dense_head_analysis.py | from abc import ABCMeta, abstractmethod
import torch.nn as nn
class BaseDenseHeadAnalysis(nn.Module, metaclass=ABCMeta):
"""Base class for DenseHeads."""
def __init__(self):
super(BaseDenseHeadAnalysis, self).__init__()
@abstractmethod
def loss(self, **kwargs):
"""Compute losses of ... | 2,692 | 38.028986 | 127 | py |
detpro | detpro-main/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 mmcv.runner import force_fp32
from mmdet.core import (build_anchor_generator, build_assigner,
build_bbox_coder, build_sampler, multi_apply)
from ..builder import HEADS
from ..losses import s... | 10,606 | 39.796154 | 79 | py |
detpro | detpro-main/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 mmcv.runner import force_fp32
from mmdet.core import distance2bbox, multi_apply, multiclass_nms
from ..builder import HEADS, build_loss
from .anchor_free_head import AnchorFreeHead
INF = 1e8
@HEADS.regist... | 25,553 | 43.441739 | 113 | py |
detpro | detpro-main/mmdet/models/dense_heads/yolo_head.py | # Copyright (c) 2019 Western Digital Corporation or its affiliates.
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, normal_init
from mmcv.runner import force_fp32
from mmdet.core import (build_anchor_generator, build_assigner,
... | 22,663 | 41.204842 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/centripetal_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmcv.ops import DeformConv2d
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from .corner_head import CornerHead
@HEADS.register_module()
class CentripetalHead(CornerHead):
"""Head of CentripetalNet: Pursuing High-... | 19,469 | 45.137441 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/paa_head.py | import numpy as np
import torch
from mmcv.runner import force_fp32
from mmdet.core import multi_apply, multiclass_nms
from mmdet.core.bbox.iou_calculators import bbox_overlaps
from mmdet.models import HEADS
from mmdet.models.dense_heads import ATSSHead
EPS = 1e-12
try:
import sklearn.mixture as skm
except ImportE... | 28,818 | 43.065749 | 79 | py |
detpro | detpro-main/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 |
detpro | detpro-main/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 mmcv.runner import force_fp32
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from .base_dense_head import BaseDenseHead
from .dense_test_mixins import BB... | 13,494 | 38.57478 | 79 | py |
detpro | detpro-main/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 |
detpro | detpro-main/mmdet/models/dense_heads/anchor_head_analysis.py | import torch
import torch.nn as nn
from torchvision.utils import save_image
from mmcv.cnn import normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
images_... | 33,418 | 45.415278 | 143 | py |
detpro | detpro-main/mmdet/models/dense_heads/pisa_retinanet_head.py | import torch
from mmcv.runner import force_fp32
from mmdet.core import 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 wi... | 6,220 | 39.135484 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/gfl_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, bbox2distance, bbox_overlaps,
build_assigner, build_sampler, distance2bbox,... | 27,306 | 42.139021 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/corner_head.py | from math import ceil, log
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, bias_init_with_prob
from mmcv.ops import CornerPool, batched_nms
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from ..utils import gaussian_radius, gen_gaussian_t... | 46,260 | 42.437559 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/yolact_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, xavier_init
from mmcv.runner import force_fp32
from mmdet.core import build_sampler, fast_nms, images_to_levels, multi_apply
from ..builder import HEADS, build_loss
from .anchor_head import AnchorHead... | 39,435 | 40.953191 | 79 | py |
detpro | detpro-main/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,051 | 33.2 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/anchor_free_head_analysis.py | from abc import abstractmethod
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from .base_dense_head_analysis import BaseDenseHeadAnalysis
from .dense_test... | 13,651 | 38.686047 | 79 | py |
detpro | detpro-main/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
EPS = 1e-12
@HEADS.register_module()
class FreeAnchorRetinaHead(RetinaHead):
"""FreeAnchor RetinaHead used in https://arxiv.org/abs/1909.02466.
Args:
num... | 11,148 | 40.140221 | 94 | py |
detpro | detpro-main/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 mmcv.ops import DeformConv2d, MaskedConv2d
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
... | 36,268 | 41.370327 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/sabl_retina_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.runner import force_fp32
from mmdet.core import (build_anchor_generator, build_assigner,
build_bbox_coder, build_sampler, images_to_levels,
m... | 26,915 | 42.483037 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/fovea_head.py | import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmcv.ops import DeformConv2d
from mmdet.core import multi_apply, multiclass_nms
from ..builder import HEADS
from .anchor_free_head import AnchorFreeHead
INF = 1e8
class FeatureAlign(nn.Module):
def __init__(self,
... | 14,405 | 41.122807 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/retina_head_analysis.py | from mmdet.core.bbox.transforms import bbox_flip
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from ..builder import HEADS
from .anchor_head_analysis import AnchorHeadAnalysis
@HEADS.register_module()
class RetinaHeadAnalysis(AnchorHeadAnalysis):
r"""An anchor-based head... | 4,161 | 34.87931 | 76 | py |
detpro | detpro-main/mmdet/models/dense_heads/dense_test_mixins.py | from inspect import signature
import torch
from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms
class BBoxTestMixin(object):
"""Mixin class for test time augmentation of bboxes."""
def merge_aug_bboxes(self, aug_bboxes, aug_scores, img_metas):
"""Merge augmented detection bboxes an... | 3,983 | 39.653061 | 79 | py |
detpro | detpro-main/mmdet/models/dense_heads/transformer_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import Conv2d, Linear, build_activation_layer
from mmcv.runner import force_fp32
from mmdet.core import (bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh,
build_assigner, build_sampler, multi_apply,
... | 30,956 | 46.262595 | 79 | py |
detpro | detpro-main/mmdet/models/utils/gaussian_target.py | from math import sqrt
import torch
def gaussian2D(radius, sigma=1, dtype=torch.float32, device='cpu'):
"""Generate 2D gaussian kernel.
Args:
radius (int): Radius of gaussian kernel.
sigma (int): Sigma of gaussian function. Default: 1.
dtype (torch.dtype): Dtype of gaussian tensor. De... | 5,784 | 30.102151 | 79 | py |
detpro | detpro-main/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,639 | 34.339806 | 77 | py |
detpro | detpro-main/mmdet/models/utils/transformer.py | import torch
import torch.nn as nn
from mmcv.cnn import (Linear, build_activation_layer, build_norm_layer,
xavier_init)
from .builder import TRANSFORMER
class MultiheadAttention(nn.Module):
"""A warpper for torch.nn.MultiheadAttention.
This module implements MultiheadAttention with res... | 32,038 | 42.005369 | 79 | py |
detpro | detpro-main/mmdet/models/utils/positional_encoding.py | import math
import torch
import torch.nn as nn
from mmcv.cnn import uniform_init
from .builder import POSITIONAL_ENCODING
@POSITIONAL_ENCODING.register_module()
class SinePositionalEncoding(nn.Module):
"""Position encoding with sine and cosine functions.
See `End-to-End Object Detection with Transformers
... | 5,800 | 37.417219 | 79 | py |
detpro | detpro-main/mmdet/models/roi_heads/standard_roi_head.py | from re import S
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
import torch.nn as nn
import torch
import clip
import time
f... | 50,278 | 49.028856 | 259 | py |
detpro | detpro-main/mmdet/models/roi_heads/zip.py | import os
from mmcv import FileClient, BaseStorageBackend
from zipfile import ZipFile
import torch
import io
class ZipBackend(BaseStorageBackend):
"""
Only single image directory is supported
"""
def __init__(self, zip_file_name=None):
if zip_file_name is not None:
self.zip_f... | 2,057 | 38.576923 | 103 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.