repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
s2anet
s2anet-master/mmdet/core/bbox/samplers/base_sampler.py
from abc import ABCMeta, abstractmethod import torch from .sampling_result import SamplingResult class BaseSampler(metaclass=ABCMeta): def __init__(self, num, pos_fraction, neg_pos_ub=-1, add_gt_as_proposals=True, **kwargs): ...
2,942
33.22093
78
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/random_sampler.py
import numpy as np import torch from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module class RandomSampler(BaseSampler): def __init__(self, num, pos_fraction, neg_pos_ub=-1, add_gt_as_proposals=T...
1,924
34
77
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/ohem_sampler.py
import torch from ..transforms import bbox2roi from .base_sampler import BaseSampler class OHEMSampler(BaseSampler): """ Online Hard Example Mining Sampler described in [1]_. References: .. [1] https://arxiv.org/pdf/1604.03540.pdf """ def __init__(self, num, ...
2,912
35.4125
77
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py
import numpy as np import torch from .random_sampler import RandomSampler class IoUBalancedNegSampler(RandomSampler): """IoU Balanced Sampling arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) Sampling proposals according to their IoU. `floor_fraction` of needed RoIs are sampled from proposal...
5,869
42.80597
79
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/random_sampler_rotated.py
import torch from .random_sampler import RandomSampler from .sampling_result import SamplingResult from ..builder import BBOX_SAMPLERS @BBOX_SAMPLERS.register_module class RandomSamplerRotated(RandomSampler): def sample(self, assign_result, bboxes, gt_bboxes, ...
1,997
35.327273
84
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/__init__.py
from .base_sampler import BaseSampler from .combined_sampler import CombinedSampler from .instance_balanced_pos_sampler import InstanceBalancedPosSampler from .iou_balanced_neg_sampler import IoUBalancedNegSampler from .ohem_sampler import OHEMSampler from .pseudo_sampler import PseudoSampler from .random_sampler impor...
643
39.25
77
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/sampling_result.py
import torch class SamplingResult(object): def __init__(self, pos_inds, neg_inds, bboxes, gt_bboxes, assign_result, gt_flags): self.pos_inds = pos_inds self.neg_inds = neg_inds self.pos_bboxes = bboxes[pos_inds] self.neg_bboxes = bboxes[neg_inds] self.pos_...
790
30.64
76
py
s2anet
s2anet-master/mmdet/core/bbox/samplers/pseudo_sampler.py
import torch from .base_sampler import BaseSampler from .sampling_result import SamplingResult class PseudoSampler(BaseSampler): def __init__(self, **kwargs): pass def _sample_pos(self, **kwargs): raise NotImplementedError def _sample_neg(self, **kwargs): raise NotImplementedEr...
829
29.740741
79
py
s2anet
s2anet-master/mmdet/core/utils/dist_utils.py
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 bucket_size_mb > 0: ...
1,967
32.355932
73
py
s2anet
s2anet-master/mmdet/core/utils/misc.py
from functools import partial import mmcv import numpy as np from six.moves import map, zip def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): num_imgs = tensor.size(0) mean = np.array(mean, dtype=np.float32) std = np.array(std, dtype=np.float32) imgs = [] for img_id in range(nu...
1,108
28.184211
75
py
s2anet
s2anet-master/mmdet/core/utils/__init__.py
from .dist_utils import DistOptimizerHook, allreduce_grads from .misc import multi_apply, tensor2imgs, unmap __all__ = [ 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', 'multi_apply' ]
210
25.375
67
py
s2anet
s2anet-master/mmdet/core/anchor/anchor_target.py
import torch from ..bbox import PseudoSampler, assign_and_sample, build_assigner, build_bbox_coder from ..utils import multi_apply def anchor_target(anchor_list, valid_flag_list, gt_bboxes_list, img_metas, target_means, target_...
7,680
37.989848
90
py
s2anet
s2anet-master/mmdet/core/anchor/guided_anchor_target.py
import torch from ..bbox import PseudoSampler, build_assigner, build_sampler from ..utils import multi_apply, unmap def calc_region(bbox, ratio, featmap_size=None): """Calculate a proportional bbox region. The bbox center are fixed and the new h' and w' is h * ratio and w * ratio. Args: bbox (T...
11,809
40.006944
79
py
s2anet
s2anet-master/mmdet/core/anchor/point_generator.py
import torch 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: return yy, xx def grid_points(self, featmap_size, stride=16, dev...
1,287
35.8
71
py
s2anet
s2anet-master/mmdet/core/anchor/anchor_generator.py
import torch class AnchorGenerator(object): """ Examples: >>> from mmdet.core import AnchorGenerator >>> self = AnchorGenerator(9, [1.], [1.]) >>> all_anchors = self.grid_anchors((2, 2), device='cpu') >>> print(all_anchors) tensor([[ 0., 0., 8., 8.], ...
3,603
35.40404
78
py
s2anet
s2anet-master/mmdet/core/anchor/__init__.py
from .anchor_generator import AnchorGenerator from .anchor_generator_rotated import AnchorGeneratorRotated from .anchor_target import anchor_inside_flags, anchor_target, unmap, images_to_levels from .guided_anchor_target import ga_loc_target, ga_shape_target from .point_generator import PointGenerator from .point_targe...
552
41.538462
86
py
s2anet
s2anet-master/mmdet/core/anchor/point_target.py
import torch from ..bbox import PseudoSampler, assign_and_sample, build_assigner from ..utils import multi_apply def point_target(proposals_list, valid_flag_list, gt_bboxes_list, img_metas, cfg, gt_bboxes_ignore_list=None, ...
6,441
37.807229
79
py
s2anet
s2anet-master/mmdet/core/anchor/anchor_generator_rotated.py
import torch class AnchorGeneratorRotated(object): def __init__(self, base_size, scales, ratios, angles=[0,],scale_major=True, ctr=None): self.base_size = base_size self.scales = torch.Tensor(scales) self.ratios = torch.Tensor(ratios) self.angles = torch.Tensor(angles) self...
3,472
38.022472
91
py
s2anet
s2anet-master/mmdet/models/registry.py
from mmdet.utils import Registry 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')
258
24.9
42
py
s2anet
s2anet-master/mmdet/models/__init__.py
from .anchor_heads import * # noqa: F401,F403 from .backbones import * # noqa: F401,F403 from .bbox_heads import * # noqa: F401,F403 from .builder import (build_backbone, build_detector, build_head, build_loss, build_neck, build_roi_extractor, build_shared_head) from .detectors import * # noqa...
982
39.958333
78
py
s2anet
s2anet-master/mmdet/models/builder.py
from torch import nn from mmdet.utils import build_from_cfg from .registry import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, ROI_EXTRACTORS, SHARED_HEADS) def build(cfg, registry, default_args=None): if isinstance(cfg, list): modules = [ build_from_cfg(cfg_, registry,...
959
20.818182
78
py
s2anet
s2anet-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 .. import builder from ..registry import DETECTORS from .base import BaseDetector from .test_mixins import BBoxTestMixin, MaskTestMixin, RPNTestMixin @DETECTORS.register_module class TwoStageDetector(B...
12,245
38.25
79
py
s2anet
s2anet-master/mmdet/models/detectors/base.py
import logging from abc import ABCMeta, abstractmethod import mmcv import numpy as np import pycocotools.mask as maskUtils import torch.nn as nn from mmdet.core import auto_fp16, get_classes, tensor2imgs class BaseDetector(nn.Module): """Base class for detectors""" __metaclass__ = ABCMeta def __init__...
5,120
32.690789
77
py
s2anet
s2anet-master/mmdet/models/detectors/single_stage.py
import torch.nn as nn from mmdet.core import bbox2result from .. import builder from ..registry import DETECTORS from .base import BaseDetector @DETECTORS.register_module class SingleStageDetector(BaseDetector): """Base class for single-stage detectors. Single-stage detectors directly and densely predict bo...
2,822
31.448276
78
py
s2anet
s2anet-master/mmdet/models/detectors/reppoints_detector.py
import torch from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms from ..registry import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module class RepPointsDetector(SingleStageDetector): """RepPoints: Point Set Representation for Object Detection. This det...
3,089
36.682927
79
py
s2anet
s2anet-master/mmdet/models/detectors/fast_rcnn.py
from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class FastRCNN(TwoStageDetector): def __init__(self, backbone, bbox_roi_extractor, bbox_head, train_cfg, test_cfg, ...
1,768
33.686275
77
py
s2anet
s2anet-master/mmdet/models/detectors/s2anet.py
from .single_stage import SingleStageDetector from ..registry import DETECTORS @DETECTORS.register_module class S2ANetDetector(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, ...
503
28.647059
82
py
s2anet
s2anet-master/mmdet/models/detectors/cascade_rcnn.py
from __future__ import division 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 .. import builder from ..registry import DETECTORS from...
23,674
41.276786
79
py
s2anet
s2anet-master/mmdet/models/detectors/mask_rcnn.py
from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class MaskRCNN(TwoStageDetector): def __init__(self, backbone, rpn_head, bbox_roi_extractor, bbox_head, mask_roi_extractor, ...
926
27.96875
50
py
s2anet
s2anet-master/mmdet/models/detectors/faster_rcnn_hbb_obb.py
import torch from mmdet.core import (bbox2result_rotated, rotated_box_to_roi, build_assigner, build_sampler, bbox_to_rotated_box, bbox_mapping, multiclass_nms_rotated, merge_aug_bboxes_rotated, rotated_box_to_bbox, bbox2roi) from .two_stage import TwoStageDetector from ....
13,152
40.755556
116
py
s2anet
s2anet-master/mmdet/models/detectors/faster_rcnn.py
from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class FasterRCNN(TwoStageDetector): def __init__(self, backbone, rpn_head, bbox_roi_extractor, bbox_head, train_cfg, ...
781
26.928571
50
py
s2anet
s2anet-master/mmdet/models/detectors/grid_rcnn.py
import torch from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler from .. import builder from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class GridRCNN(TwoStageDetector): """Grid R-CNN. This detector is the implementation of: - G...
9,225
39.113043
79
py
s2anet
s2anet-master/mmdet/models/detectors/double_head_rcnn.py
import torch from mmdet.core import bbox2roi, build_assigner, build_sampler from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class DoubleHeadRCNN(TwoStageDetector): def __init__(self, reg_roi_scale_factor, **kwargs): super().__init__(**kwargs) s...
7,453
40.642458
77
py
s2anet
s2anet-master/mmdet/models/detectors/rpn.py
import mmcv from mmdet.core import bbox_mapping, tensor2imgs from .. import builder from ..registry import DETECTORS from .base import BaseDetector from .test_mixins import RPNTestMixin @DETECTORS.register_module class RPN(BaseDetector, RPNTestMixin): def __init__(self, backbone, ...
3,513
34.857143
78
py
s2anet
s2anet-master/mmdet/models/detectors/retinanet.py
from ..registry import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module class RetinaNet(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, ...
488
27.764706
77
py
s2anet
s2anet-master/mmdet/models/detectors/cascade_s2anet.py
import torch.nn as nn from mmdet.core import bbox2result from .base import BaseDetector from .. import builder from ..registry import DETECTORS @DETECTORS.register_module class CascadeS2ANetDetector(BaseDetector): """Base class for single-stage detectors. Single-stage detectors directly and densely predict ...
4,822
35.263158
120
py
s2anet
s2anet-master/mmdet/models/detectors/fcos.py
from ..registry import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module class FCOS(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, ...
473
26.882353
72
py
s2anet
s2anet-master/mmdet/models/detectors/fovea.py
from ..registry import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module class FOVEA(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, ...
476
27.058824
73
py
s2anet
s2anet-master/mmdet/models/detectors/htc.py
import torch import torch.nn.functional as F from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner, build_sampler, merge_aug_bboxes, merge_aug_masks, multiclass_nms) from .. import builder from ..registry import DETECTORS from .cascade_rcnn import C...
24,580
43.210432
79
py
s2anet
s2anet-master/mmdet/models/detectors/__init__.py
from .base import BaseDetector from .cascade_rcnn import CascadeRCNN from .cascade_s2anet import CascadeS2ANetDetector from .double_head_rcnn import DoubleHeadRCNN from .fast_rcnn import FastRCNN from .faster_rcnn import FasterRCNN from .faster_rcnn_hbb_obb import FasterRCNNHBBOBB from .fcos import FCOS from .fovea imp...
1,038
36.107143
77
py
s2anet
s2anet-master/mmdet/models/detectors/mask_scoring_rcnn.py
import torch from mmdet.core import bbox2roi, build_assigner, build_sampler from .. import builder from ..registry import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module class MaskScoringRCNN(TwoStageDetector): """Mask Scoring RCNN. https://arxiv.org/abs/1903.00241 """ ...
8,565
41.616915
79
py
s2anet
s2anet-master/mmdet/models/detectors/test_mixins.py
from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes, merge_aug_masks, merge_aug_proposals, multiclass_nms) class RPNTestMixin(object): def simple_test_rpn(self, x, img_meta, rpn_test_cfg): rpn_outs = self.rpn_head(x) proposal_inputs = rpn_outs + (img_meta, rpn...
7,197
42.624242
79
py
s2anet
s2anet-master/mmdet/models/plugins/non_local.py
import torch import torch.nn as nn from mmcv.cnn import constant_init, normal_init from ..utils import ConvModule class NonLocal2D(nn.Module): """Non-local module. See https://arxiv.org/abs/1711.07971 for details. Args: in_channels (int): Channels of the input feature map. reduction (in...
3,708
31.252174
79
py
s2anet
s2anet-master/mmdet/models/plugins/__init__.py
from .generalized_attention import GeneralizedAttention from .non_local import NonLocal2D __all__ = ['NonLocal2D', 'GeneralizedAttention']
140
27.2
55
py
s2anet
s2anet-master/mmdet/models/plugins/generalized_attention.py
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import kaiming_init class GeneralizedAttention(nn.Module): """GeneralizedAttention module. See 'An Empirical Study of Spatial Attention Mechanisms in Deep Networks' (https://arxiv.org/abs/1711...
15,139
38.324675
79
py
s2anet
s2anet-master/mmdet/models/necks/fpn.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import xavier_init from mmdet.core import auto_fp16 from ..registry import NECKS from ..utils import ConvModule @NECKS.register_module class FPN(nn.Module): def __init__(self, in_channels, out_channels, ...
5,289
36.253521
79
py
s2anet
s2anet-master/mmdet/models/necks/__init__.py
from .bfp import BFP from .fpn import FPN from .hrfpn import HRFPN __all__ = ['FPN', 'BFP', 'HRFPN']
102
16.166667
33
py
s2anet
s2anet-master/mmdet/models/necks/bfp.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import xavier_init from ..plugins import NonLocal2D from ..registry import NECKS from ..utils import ConvModule @NECKS.register_module class BFP(nn.Module): """BFP (Balanced Feature Pyrmamids) BFP takes multi-level features as inputs and ga...
3,598
33.941748
79
py
s2anet
s2anet-master/mmdet/models/necks/hrfpn.py
import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn.weight_init import caffe2_xavier_init from torch.utils.checkpoint import checkpoint from ..registry import NECKS from ..utils import ConvModule @NECKS.register_module class HRFPN(nn.Module): """HRFPN (High Resolution Feature Pyrmami...
3,363
32.306931
79
py
s2anet
s2anet-master/mmdet/models/roi_extractors/single_level.py
from __future__ import division import torch import torch.nn as nn from mmdet import ops from mmdet.core import force_fp32 from ..registry import ROI_EXTRACTORS @ROI_EXTRACTORS.register_module class SingleRoIExtractor(nn.Module): """Extract RoI features from a single level feature map. If there are mulitpl...
3,794
34.138889
79
py
s2anet
s2anet-master/mmdet/models/roi_extractors/__init__.py
from .single_level import SingleRoIExtractor from .single_level_rotated import SingleRoIExtractorRotated __all__ = ['SingleRoIExtractor', 'SingleRoIExtractorRotated']
168
32.8
61
py
s2anet
s2anet-master/mmdet/models/roi_extractors/single_level_rotated.py
from __future__ import division import torch from .single_level import SingleRoIExtractor from ..registry import ROI_EXTRACTORS @ROI_EXTRACTORS.register_module class SingleRoIExtractorRotated(SingleRoIExtractor): def map_roi_levels(self, rois, num_levels): """Map rois to corresponding feature levels by...
1,348
31.119048
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/reppoints_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (PointGenerator, multi_apply, multiclass_nms, point_target) from mmdet.ops import DeformConv from ..builder import build_loss from ..registry import HEA...
27,172
44.515913
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/fsaf_head.py
import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import multi_apply, multiclass_nms, distance2bbox from ..losses import sigmoid_focal_loss from ..registry import HEADS from ..utils import bias_init_with_prob, ConvModule def select_iou_loss(pred, target, weight, a...
23,125
42.226168
79
py
s2anet
s2anet-master/mmdet/models/anchor_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.core import delta2bbox from mmdet.ops import nms from ..registry import HEADS from .anchor_head import AnchorHead @HEADS.register_module class RPNHead(AnchorHead): def __init__(self, in_channels, **kwa...
4,050
37.580952
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/anchor_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (AnchorGenerator, anchor_target, delta2bbox, force_fp32, multi_apply, multiclass_nms) from ..builder import build_loss from ..registry import HEADS @H...
13,818
41.259939
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/retina_head.py
import numpy as np import torch.nn as nn from mmcv.cnn import normal_init from ..registry import HEADS from ..utils import ConvModule, bias_init_with_prob from .anchor_head import AnchorHead @HEADS.register_module class RetinaHead(AnchorHead): """ An anchor-based head used in [1]_. The head contains two...
3,602
33.644231
76
py
s2anet
s2anet-master/mmdet/models/anchor_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.core import delta2bbox from mmdet.ops import nms from ..registry import HEADS from .guided_anchor_head import GuidedAnchorHead @HEADS.register_module class GARPNHead(GuidedAnchorHead): """Guided-Anchor-...
4,981
37.921875
78
py
s2anet
s2anet-master/mmdet/models/anchor_heads/ga_retina_head.py
import torch.nn as nn from mmcv.cnn import normal_init from mmdet.ops import MaskedConv2d from ..registry import HEADS from ..utils import ConvModule, bias_init_with_prob from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead @HEADS.register_module class GARetinaHead(GuidedAnchorHead): """Guided-Ancho...
3,760
33.824074
78
py
s2anet
s2anet-master/mmdet/models/anchor_heads/ssd_head.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import xavier_init from mmdet.core import AnchorGenerator, anchor_target, multi_apply from ..losses import smooth_l1_loss from ..registry import HEADS from .anchor_head import AnchorHead # TODO: add loss evaluator for...
7,762
38.607143
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/fcos_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import distance2bbox, force_fp32, multi_apply, multiclass_nms from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule, Scale, bias_init_with_prob INF = 1e8 @HEADS.register_module class FCOSHead(n...
16,503
39.952854
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/__init__.py
from .anchor_head import AnchorHead from .fcos_head import FCOSHead from .fovea_head import FoveaHead from .fsaf_head import FSAFHead from .ga_retina_head import GARetinaHead from .ga_rpn_head import GARPNHead from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead from .reppoints_head import RepPointsHead fr...
612
33.055556
69
py
s2anet
s2anet-master/mmdet/models/anchor_heads/guided_anchor_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (AnchorGenerator, anchor_inside_flags, anchor_target, delta2bbox, force_fp32, ga_loc_target, ga_shape_target, multi_apply, multi...
25,226
39.820388
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads/fovea_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import multi_apply, multiclass_nms from mmdet.ops import DeformConv from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule, bias_init_with_prob INF = 1e8 class FeatureAlign(nn.Module): def ...
16,360
41.167526
79
py
s2anet
s2anet-master/mmdet/models/bbox_heads/bbox_head.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from mmdet.core import (auto_fp16, bbox_target, delta2bbox, force_fp32, multiclass_nms) from ..builder import build_loss from ..losses import accuracy from ..registry import HEADS @HEAD...
9,111
36.966667
79
py
s2anet
s2anet-master/mmdet/models/bbox_heads/__init__.py
from .bbox_head import BBoxHead from .convfc_bbox_head import ConvFCBBoxHead, SharedFCBBoxHead from .double_bbox_head import DoubleConvFCBBoxHead __all__ = [ 'BBoxHead', 'ConvFCBBoxHead', 'SharedFCBBoxHead', 'DoubleConvFCBBoxHead' ]
238
28.875
76
py
s2anet
s2anet-master/mmdet/models/bbox_heads/convfc_bbox_head.py
import torch.nn as nn from ..registry import HEADS from ..utils import ConvModule from .bbox_head import BBoxHead @HEADS.register_module class ConvFCBBoxHead(BBoxHead): r"""More general bbox head, with shared conv and fc layers and two optional separated branches. /-> cls con...
6,943
36.333333
79
py
s2anet
s2anet-master/mmdet/models/bbox_heads/double_bbox_head.py
import torch.nn as nn from mmcv.cnn.weight_init import normal_init, xavier_init from ..backbones.resnet import Bottleneck from ..registry import HEADS from ..utils import ConvModule from .bbox_head import BBoxHead class BasicResBlock(nn.Module): """Basic residual block. This block is a little different from...
5,274
29.847953
78
py
s2anet
s2anet-master/mmdet/models/shared_heads/res_layer.py
import logging import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from mmdet.core import auto_fp16 from ..backbones import ResNet, make_res_layer from ..registry import SHARED_HEADS @SHARED_HEADS.register_module class ResLayer(nn.Module): def __init__...
2,236
29.643836
74
py
s2anet
s2anet-master/mmdet/models/shared_heads/__init__.py
from .res_layer import ResLayer __all__ = ['ResLayer']
56
13.25
31
py
s2anet
s2anet-master/mmdet/models/utils/weight_init.py
import numpy as np import torch.nn as nn def xavier_init(module, gain=1, bias=0, distribution='normal'): assert distribution in ['uniform', 'normal'] if distribution == 'uniform': nn.init.xavier_uniform_(module.weight, gain=gain) else: nn.init.xavier_normal_(module.weight, gain=gain) i...
1,455
29.978723
71
py
s2anet
s2anet-master/mmdet/models/utils/norm.py
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) 'BN': ('bn', nn.BatchNorm2d), 'SyncBN': ('bn', nn.SyncBatchNorm), 'GN': ('gn', nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=''): """ Build normalization layer Args: ...
1,684
29.089286
74
py
s2anet
s2anet-master/mmdet/models/utils/scale.py
import torch import torch.nn as nn class Scale(nn.Module): """ A learnable scale parameter """ def __init__(self, scale=1.0): super(Scale, self).__init__() self.scale = nn.Parameter(torch.tensor(scale, dtype=torch.float)) def forward(self, x): return x * self.scale
314
18.6875
73
py
s2anet
s2anet-master/mmdet/models/utils/conv_ws.py
import torch.nn as nn import torch.nn.functional as F def conv_ws_2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1, eps=1e-5): c_in = weight.size(0) weight_flat = weight.view(c_in, -1...
1,335
27.425532
79
py
s2anet
s2anet-master/mmdet/models/utils/conv_module.py
import warnings import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from .conv_ws import ConvWS2d from .norm import build_norm_layer conv_cfg = { 'Conv': nn.Conv2d, 'ConvWS': ConvWS2d, # TODO: octave conv } def build_conv_layer(cfg, *args, **kwargs): """ Build convolution layer ...
5,745
33.824242
78
py
s2anet
s2anet-master/mmdet/models/utils/__init__.py
from .conv_module import ConvModule, build_conv_layer from .conv_ws import ConvWS2d, conv_ws_2d from .norm import build_norm_layer from .scale import Scale from .weight_init import (bias_init_with_prob, kaiming_init, normal_init, uniform_init, xavier_init) __all__ = [ 'conv_ws_2d', 'ConvW...
483
36.230769
73
py
s2anet
s2anet-master/mmdet/models/anchor_heads_rotated/cascade_s2anet_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (AnchorGeneratorRotated, anchor_target, build_bbox_coder, delta2bbox_rotated, force_fp32, images_to_levels, multi_apply, multicla...
19,133
37.811359
93
py
s2anet
s2anet-master/mmdet/models/anchor_heads_rotated/s2anet_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (AnchorGeneratorRotated, anchor_target, build_bbox_coder, delta2bbox_rotated, force_fp32, images_to_levels, multi_apply, multicla...
27,099
38.911635
88
py
s2anet
s2anet-master/mmdet/models/anchor_heads_rotated/anchor_head_rotated.py
from __future__ import division import torch import torch.nn as nn from mmdet.core import (AnchorGeneratorRotated, anchor_target, delta2bbox_rotated, force_fp32, multi_apply, multiclass_nms_rotated, images_to_levels, build_bbox_coder) from ..anchor_heads import AnchorHe...
7,452
40.636872
95
py
s2anet
s2anet-master/mmdet/models/anchor_heads_rotated/__init__.py
from .anchor_head_rotated import AnchorHeadRotated from .cascade_s2anet_head import CascadeS2ANetHead from .retina_head_rotated import RetinaHeadRotated from .s2anet_head import S2ANetHead __all__ = [ 'AnchorHeadRotated', 'RetinaHeadRotated', 'S2ANetHead', 'CascadeS2ANetHead' ]
284
30.666667
79
py
s2anet
s2anet-master/mmdet/models/anchor_heads_rotated/retina_head_rotated.py
import numpy as np import torch.nn as nn from mmcv.cnn import normal_init from ..registry import HEADS from ..utils import ConvModule, bias_init_with_prob from .anchor_head_rotated import AnchorHeadRotated @HEADS.register_module class RetinaHeadRotated(AnchorHeadRotated): def __init__(self, num...
3,012
34.034884
105
py
s2anet
s2anet-master/mmdet/models/bbox_heads_rotated/bbox_head_rotated.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from mmdet.core import (auto_fp16, bbox_target_rotated, delta2bbox_rotated, force_fp32, multiclass_nms_rotated, bbox_to_rotated_box, rotated_box_to_poly, poly_to_rotated_box) from ..build...
9,476
38
110
py
s2anet
s2anet-master/mmdet/models/bbox_heads_rotated/convfc_bbox_head_rotated.py
import torch.nn as nn from .bbox_head_rotated import BBoxHeadRotated from ..registry import HEADS from ..utils import ConvModule @HEADS.register_module class ConvFCBBoxHeadRotated(BBoxHeadRotated): r"""More general bbox head, with shared conv and fc layers and two optional separated branches. ...
7,037
36.83871
79
py
s2anet
s2anet-master/mmdet/models/bbox_heads_rotated/double_bbox_head_rotated.py
import torch.nn as nn from mmcv.cnn.weight_init import normal_init, xavier_init from .bbox_head_rotated import BBoxHeadRotated from ..backbones.resnet import Bottleneck from ..registry import HEADS from ..utils import ConvModule class BasicResBlock(nn.Module): """Basic residual block. This block is a little...
5,310
30.05848
78
py
s2anet
s2anet-master/mmdet/models/bbox_heads_rotated/__init__.py
from .bbox_head_rotated import BBoxHeadRotated from .convfc_bbox_head_rotated import ConvFCBBoxHeadRotated, SharedFCBBoxHeadRotated from .double_bbox_head_rotated import DoubleConvFCBBoxHeadRotated __all__ = [ 'BBoxHeadRotated', 'ConvFCBBoxHeadRotated', 'SharedFCBBoxHeadRotated', 'DoubleConvFCBBoxHeadRotated' ]
318
38.875
104
py
s2anet
s2anet-master/mmdet/models/losses/ghm_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES def _expand_binary_labels(labels, label_weights, label_channels): bin_labels = labels.new_full((labels.size(0), label_channels), 0) inds = torch.nonzero(labels >= 1).squeeze() if inds.numel() > 0: bin...
6,304
35.656977
79
py
s2anet
s2anet-master/mmdet/models/losses/mse_loss.py
import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES from .utils import weighted_loss mse_loss = weighted_loss(F.mse_loss) @LOSSES.register_module class MSELoss(nn.Module): def __init__(self, reduction='mean', loss_weight=1.0): super().__init__() self.reduction = ...
632
23.346154
66
py
s2anet
s2anet-master/mmdet/models/losses/balanced_l1_loss.py
import numpy as np import torch import torch.nn as nn from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def balanced_l1_loss(pred, target, beta=1.0, alpha=0.5, gamma=1.5, reduction='me...
1,884
25.928571
73
py
s2anet
s2anet-master/mmdet/models/losses/iou_loss.py
import torch import torch.nn as nn from mmdet.core import bbox_overlaps from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def iou_loss(pred, target, eps=1e-6): """IoU loss. Computing the IoU loss between a set of predicted bboxes and target bboxes. The loss is calculated as n...
6,650
30.671429
89
py
s2anet
s2anet-master/mmdet/models/losses/smooth_l1_loss.py
import torch import torch.nn as nn from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def smooth_l1_loss(pred, target, beta=1.0): assert beta > 0 assert pred.size() == target.size() and target.numel() > 0 diff = torch.abs(pred - target) loss = torch.where(diff < beta, 0.5 *...
1,288
27.021739
73
py
s2anet
s2anet-master/mmdet/models/losses/utils.py
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
3,003
29.343434
79
py
s2anet
s2anet-master/mmdet/models/losses/accuracy.py
import torch.nn as nn def accuracy(pred, target, topk=1): assert isinstance(topk, (int, tuple)) if isinstance(topk, int): topk = (topk, ) return_single = True else: return_single = False maxk = max(topk) _, pred_label = pred.topk(maxk, dim=1) pred_label = pred_label.t(...
801
24.0625
69
py
s2anet
s2anet-master/mmdet/models/losses/focal_loss.py
import torch.nn as nn import torch.nn.functional as F from mmdet.ops import sigmoid_focal_loss as _sigmoid_focal_loss from ..registry import LOSSES from .utils import weight_reduce_loss # This method is only for debugging def py_sigmoid_focal_loss(pred, target, wei...
2,783
32.95122
76
py
s2anet
s2anet-master/mmdet/models/losses/rotated_iou_loss.py
import torch import torch.nn as nn from mmdet.ops import box_iou_rotated_differentiable from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def iou_loss(pred, target, linear=False, eps=1e-6): """IoU loss. Computing the IoU loss between a set of predicted bboxes and target bboxes. ...
2,397
30.552632
82
py
s2anet
s2anet-master/mmdet/models/losses/cross_entropy_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES from .utils import weight_reduce_loss def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None): # element-wise losses loss = F.cross_entropy(pred, label, reduction='none') # apply weigh...
3,386
31.567308
79
py
s2anet
s2anet-master/mmdet/models/losses/__init__.py
from .accuracy import Accuracy, accuracy from .balanced_l1_loss import BalancedL1Loss, balanced_l1_loss from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, cross_entropy, mask_cross_entropy) from .focal_loss import FocalLoss, sigmoid_focal_loss from .ghm_loss import...
1,097
46.73913
76
py
s2anet
s2anet-master/mmdet/models/backbones/hrnet.py
import logging import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ..registry import BACKBONES from ..utils import build_conv_layer, build_norm_layer from .resnet import BasicBlock, Bottleneck class HRM...
19,868
36.773764
79
py
s2anet
s2anet-master/mmdet/models/backbones/resnet.py
import logging import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.plugins import GeneralizedAttention from mmdet.ops import ContextBlock, DeformConv, Modu...
18,098
32.331492
79
py
s2anet
s2anet-master/mmdet/models/backbones/ssd_vgg.py
import logging import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import VGG, constant_init, kaiming_init, normal_init, xavier_init from mmcv.runner import load_checkpoint from ..registry import BACKBONES @BACKBONES.register_module class SSDVGG(VGG): """VGG Backbone network for sin...
5,408
33.673077
79
py
s2anet
s2anet-master/mmdet/models/backbones/resnext.py
import math import torch.nn as nn from mmdet.ops import DeformConv, ModulatedDeformConv from ..registry import BACKBONES from ..utils import build_conv_layer, build_norm_layer from .resnet import Bottleneck as _Bottleneck from .resnet import ResNet class Bottleneck(_Bottleneck): def __init__(self, inplanes, pl...
8,336
33.882845
79
py