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 |
|---|---|---|---|---|---|---|
AlignShift | AlignShift-master/mmdet/models/roi_extractors/__init__.py | from .single_level import SingleRoIExtractor
__all__ = ['SingleRoIExtractor']
| 79 | 19 | 44 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,180 | 37.712963 | 83 | py |
AlignShift | AlignShift-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
@HE... | 14,032 | 41.268072 | 97 | py |
AlignShift | AlignShift-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,603 | 33.653846 | 77 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,509 | 39.366748 | 79 | py |
AlignShift | AlignShift-master/mmdet/models/anchor_heads/__init__.py | from .anchor_head import AnchorHead
from .fcos_head import FCOSHead
from .fovea_head import FoveaHead
from .free_anchor_retina_head import FreeAnchorRetinaHead
from .ga_retina_head import GARetinaHead
from .ga_rpn_head import GARPNHead
from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead
from .reppoints_he... | 650 | 35.166667 | 69 | py |
AlignShift | AlignShift-master/mmdet/models/anchor_heads/free_anchor_retina_head.py | import torch
import torch.nn.functional as F
from mmdet.core import bbox2delta, bbox_overlaps, delta2bbox
from ..registry import HEADS
from .retina_head import RetinaHead
@HEADS.register_module
class FreeAnchorRetinaHead(RetinaHead):
def __init__(self,
num_classes,
in_channels,... | 7,396 | 38.137566 | 79 | py |
AlignShift | AlignShift-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,250 | 39.596463 | 79 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,344 | 37.29918 | 79 | py |
AlignShift | AlignShift-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',] | 236 | 46.4 | 78 | py |
AlignShift | AlignShift-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... | 7,308 | 37.067708 | 82 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-master/mmdet/models/shared_heads/__init__.py | from .res_layer import ResLayer
__all__ = ['ResLayer']
| 56 | 13.25 | 31 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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... | 4,339 | 30.911765 | 79 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,784 | 32.554217 | 76 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,035 | 48.333333 | 76 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-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,099 | 32.272059 | 79 | py |
AlignShift | AlignShift-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,335 | 33.425806 | 79 | py |
AlignShift | AlignShift-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 |
AlignShift | AlignShift-master/mmdet/models/backbones/__init__.py | from .hrnet import HRNet
from .resnet import ResNet, make_res_layer
from .resnext import ResNeXt
from .ssd_vgg import SSDVGG
from deeplesion.models.truncated_densenet import DenseNetCustomTrunc
from nn.models.truncated_densenet3d_tsm import DenseNetCustomTrunc3dTSM
from nn.models.truncated_densenet3d_a3d import DenseN... | 610 | 49.916667 | 96 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/grid_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import kaiming_init, normal_init
from ..builder import build_loss
from ..registry import HEADS
from ..utils import ConvModule
@HEADS.register_module
class GridHead(nn.Module):
def __init__(self,
... | 15,429 | 41.624309 | 79 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/maskiou_head.py | import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import kaiming_init, normal_init
from torch.nn.modules.utils import _pair
from mmdet.core import force_fp32
from ..builder import build_loss
from ..registry import HEADS
@HEADS.register_module
class MaskIoUHead(nn.Module):
"""Mask IoU Head.
... | 7,453 | 38.026178 | 79 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/__init__.py | from .fcn_mask_head import FCNMaskHead
from .fused_semantic_head import FusedSemanticHead
from .grid_head import GridHead
from .htc_mask_head import HTCMaskHead
from .maskiou_head import MaskIoUHead
__all__ = [
'FCNMaskHead', 'HTCMaskHead', 'FusedSemanticHead', 'GridHead',
'MaskIoUHead'
]
| 299 | 26.272727 | 66 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/htc_mask_head.py | from ..registry import HEADS
from ..utils import ConvModule
from .fcn_mask_head import FCNMaskHead
@HEADS.register_module
class HTCMaskHead(FCNMaskHead):
def __init__(self, *args, **kwargs):
super(HTCMaskHead, self).__init__(*args, **kwargs)
self.conv_res = ConvModule(
self.conv_out_c... | 1,178 | 29.230769 | 78 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/fcn_mask_head.py | import mmcv
import numpy as np
import pycocotools.mask as mask_util
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from mmdet.core import auto_fp16, force_fp32, mask_target
from ..builder import build_loss
from ..registry import HEADS
from ..utils import ConvModule
@HEADS.register_module... | 7,271 | 37.887701 | 79 | py |
AlignShift | AlignShift-master/mmdet/models/mask_heads/fused_semantic_head.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import kaiming_init
from mmdet.core import auto_fp16, force_fp32
from ..registry import HEADS
from ..utils import ConvModule
@HEADS.register_module
class FusedSemanticHead(nn.Module):
r"""Multi-level fused semantic segmentation head.
in_1 -... | 3,554 | 32.224299 | 79 | py |
AlignShift | AlignShift-master/mmdet/datasets/custom.py | import os.path as osp
import mmcv
import numpy as np
from torch.utils.data import Dataset
from .pipelines import Compose
from .registry import DATASETS
@DATASETS.register_module
class CustomDataset(Dataset):
"""Custom dataset for detection.
Annotation format:
[
{
'filename': 'a.jpg'... | 5,047 | 32.653333 | 75 | py |
AlignShift | AlignShift-master/mmdet/datasets/voc.py | from .registry import DATASETS
from .xml_style import XMLDataset
@DATASETS.register_module
class VOCDataset(XMLDataset):
CLASSES = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car',
'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedpla... | 695 | 32.142857 | 78 | py |
AlignShift | AlignShift-master/mmdet/datasets/registry.py | from mmdet.utils import Registry
DATASETS = Registry('dataset')
PIPELINES = Registry('pipeline')
| 98 | 18.8 | 32 | py |
AlignShift | AlignShift-master/mmdet/datasets/cityscapes.py | from .coco import CocoDataset
from .registry import DATASETS
@DATASETS.register_module
class CityscapesDataset(CocoDataset):
CLASSES = ('person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle',
'bicycle')
| 234 | 22.5 | 79 | py |
AlignShift | AlignShift-master/mmdet/datasets/dataset_wrappers.py | import numpy as np
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
from .registry import DATASETS
@DATASETS.register_module
class ConcatDataset(_ConcatDataset):
"""A wrapper of concatenated dataset.
Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but
concat the group flag for... | 1,639 | 28.285714 | 78 | py |
AlignShift | AlignShift-master/mmdet/datasets/xml_style.py | import os.path as osp
import xml.etree.ElementTree as ET
import mmcv
import numpy as np
from .custom import CustomDataset
from .registry import DATASETS
@DATASETS.register_module
class XMLDataset(CustomDataset):
def __init__(self, min_size=None, **kwargs):
super(XMLDataset, self).__init__(**kwargs)
... | 3,070 | 34.298851 | 79 | py |
AlignShift | AlignShift-master/mmdet/datasets/__init__.py | from .builder import build_dataset
from .cityscapes import CityscapesDataset
from .coco import CocoDataset
from .custom import CustomDataset
from .dataset_wrappers import ConcatDataset, RepeatDataset
from .loader import DistributedGroupSampler, GroupSampler, build_dataloader
from .registry import DATASETS
from .voc imp... | 1,070 | 43.625 | 77 | py |
AlignShift | AlignShift-master/mmdet/datasets/builder.py | import copy
from mmdet.utils import build_from_cfg
from .dataset_wrappers import ConcatDataset, RepeatDataset
from .registry import DATASETS
def _concat_dataset(cfg, default_args=None):
ann_files = cfg['ann_file']
img_prefixes = cfg.get('img_prefix', None)
seg_prefixes = cfg.get('seg_prefixes', None)
... | 1,457 | 33.714286 | 78 | py |
AlignShift | AlignShift-master/mmdet/datasets/coco.py | import numpy as np
from pycocotools.coco import COCO
from .custom import CustomDataset
from .registry import DATASETS
@DATASETS.register_module
class CocoDataset(CustomDataset):
CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
'train', 'truck', 'boat', 'traffic_light', 'fir... | 4,304 | 37.783784 | 79 | py |
AlignShift | AlignShift-master/mmdet/datasets/wider_face.py | import os.path as osp
import xml.etree.ElementTree as ET
import mmcv
from .registry import DATASETS
from .xml_style import XMLDataset
@DATASETS.register_module
class WIDERFaceDataset(XMLDataset):
"""
Reader for the WIDER Face dataset in PASCAL VOC format.
Conversion scripts can be found in
https://g... | 1,301 | 29.27907 | 65 | py |
AlignShift | AlignShift-master/mmdet/datasets/loader/sampler.py | from __future__ import division
import math
import numpy as np
import torch
from mmcv.runner import get_dist_info
from torch.utils.data import DistributedSampler as _DistributedSampler
from torch.utils.data import Sampler
class DistributedSampler(_DistributedSampler):
def __init__(self, dataset, num_replicas=No... | 5,860 | 34.521212 | 78 | py |
AlignShift | AlignShift-master/mmdet/datasets/loader/build_loader.py | import platform
from functools import partial
from mmcv.parallel import collate
from mmcv.runner import get_dist_info
from torch.utils.data import DataLoader
from .sampler import DistributedGroupSampler, DistributedSampler, GroupSampler
if platform.system() != 'Windows':
# https://github.com/pytorch/pytorch/issu... | 1,552 | 30.693878 | 78 | py |
AlignShift | AlignShift-master/mmdet/datasets/loader/__init__.py | from .build_loader import build_dataloader
from .sampler import DistributedGroupSampler, GroupSampler
__all__ = ['GroupSampler', 'DistributedGroupSampler', 'build_dataloader']
| 177 | 34.6 | 73 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/test_aug.py | import mmcv
from ..registry import PIPELINES
from .compose import Compose
@PIPELINES.register_module
class MultiScaleFlipAug(object):
def __init__(self, transforms, img_scale, flip=False):
self.transforms = Compose(transforms)
self.img_scale = img_scale if isinstance(img_scale,
... | 1,312 | 32.666667 | 71 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/loading.py | import os.path as osp
import warnings
import mmcv
import numpy as np
import pycocotools.mask as maskUtils
from ..registry import PIPELINES
@PIPELINES.register_module
class LoadImageFromFile(object):
def __init__(self, to_float32=False):
self.to_float32 = to_float32
def __call__(self, results):
... | 5,376 | 33.467949 | 77 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/compose.py | import collections
from mmdet.utils import build_from_cfg
from ..registry import PIPELINES
@PIPELINES.register_module
class Compose(object):
def __init__(self, transforms):
assert isinstance(transforms, collections.abc.Sequence)
self.transforms = []
for transform in transforms:
... | 1,149 | 29.263158 | 71 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/formating.py | from collections.abc import Sequence
import mmcv
import numpy as np
import torch
from mmcv.parallel import DataContainer as DC
from ..registry import PIPELINES
def to_tensor(data):
"""Convert objects of various python types to :obj:`torch.Tensor`.
Supported types are: :class:`numpy.ndarray`, :class:`torch.... | 5,994 | 31.058824 | 79 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/__init__.py | from .compose import Compose
from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor,
Transpose, to_tensor)
from .loading import LoadAnnotations, LoadImageFromFile, LoadProposals
from .test_aug import MultiScaleFlipAug
from .transforms import (Albu, Expand, MinIoURandomCrop, No... | 948 | 51.722222 | 91 | py |
AlignShift | AlignShift-master/mmdet/datasets/pipelines/transforms.py | import inspect
import albumentations
import mmcv
import numpy as np
from albumentations import Compose
from imagecorruptions import corrupt
from numpy import random
from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps
from ..registry import PIPELINES
@PIPELINES.register_module
class Resize(object):
"""... | 31,043 | 35.181818 | 79 | py |
AlignShift | AlignShift-master/mmdet/utils/registry.py | import inspect
import mmcv
class Registry(object):
def __init__(self, name):
self._name = name
self._module_dict = dict()
def __repr__(self):
format_str = self.__class__.__name__ + '(name={}, items={})'.format(
self._name, list(self._module_dict.keys()))
return f... | 2,304 | 28.935065 | 78 | py |
AlignShift | AlignShift-master/mmdet/utils/flops_counter.py | # Modified from flops-counter.pytorch by Vladislav Sovrasov
# original repo: https://github.com/sovrasov/flops-counter.pytorch
# MIT License
# Copyright (c) 2018 Vladislav Sovrasov
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (th... | 14,351 | 32.069124 | 79 | py |
AlignShift | AlignShift-master/mmdet/utils/__init__.py | from .flops_counter import get_model_complexity_info
from .registry import Registry, build_from_cfg
__all__ = ['Registry', 'build_from_cfg', 'get_model_complexity_info']
| 171 | 33.4 | 69 | py |
AlignShift | AlignShift-master/mmdet/ops/context_block.py | import torch
from mmcv.cnn import constant_init, kaiming_init
from torch import nn
def last_zero_init(m):
if isinstance(m, nn.Sequential):
constant_init(m[-1], val=0)
else:
constant_init(m, val=0)
class ContextBlock(nn.Module):
def __init__(self,
inplanes,
... | 3,766 | 34.87619 | 76 | py |
AlignShift | AlignShift-master/mmdet/ops/__init__.py | from .context_block import ContextBlock
from .dcn import (DeformConv, DeformConvPack, DeformRoIPooling,
DeformRoIPoolingPack, ModulatedDeformConv,
ModulatedDeformConvPack, ModulatedDeformRoIPoolingPack,
deform_conv, deform_roi_pooling, modulated_deform_conv)
from .m... | 934 | 45.75 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/dcn/deform_pool.py | import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from . import deform_pool_cuda
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(ctx,
data,
... | 10,212 | 39.367589 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/dcn/deform_conv.py | import math
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from . import deform_conv_cuda
class DeformConvFunction(Function):
@staticmethod
def forward(ctx,
input,
... | 12,468 | 35.890533 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/dcn/__init__.py | from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv,
ModulatedDeformConvPack, deform_conv,
modulated_deform_conv)
from .deform_pool import (DeformRoIPooling, DeformRoIPoolingPack,
ModulatedDeformRoIPoolingPack, deform_ro... | 582 | 43.846154 | 76 | py |
AlignShift | AlignShift-master/mmdet/ops/masked_conv/masked_conv.py | import math
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from . import masked_conv2d_cuda
class MaskedConv2dFunction(Function):
@staticmethod
def forward(ctx, features, mask, weight, b... | 3,375 | 36.511111 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/masked_conv/__init__.py | from .masked_conv import MaskedConv2d, masked_conv2d
__all__ = ['masked_conv2d', 'MaskedConv2d']
| 98 | 23.75 | 52 | py |
AlignShift | AlignShift-master/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py | import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from . import sigmoid_focal_loss_cuda
class SigmoidFocalLossFunction(Function):
@staticmethod
def forward(ctx, input, target, gamma=2.0, alpha=0.25):
ctx.save_for_backward(input, target)... | 1,637 | 28.781818 | 77 | py |
AlignShift | AlignShift-master/mmdet/ops/sigmoid_focal_loss/__init__.py | from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss
__all__ = ['SigmoidFocalLoss', 'sigmoid_focal_loss']
| 123 | 30 | 68 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_align/roi_align.py | import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from . import roi_align_cuda
class RoIAlignFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0):
... | 3,068 | 33.875 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_align/gradcheck.py | import os.path as osp
import sys
import numpy as np
import torch
from torch.autograd import gradcheck
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_align import RoIAlign # noqa: E402, isort:skip
feat_size = 15
spatial_scale = 1.0 / 8
img_size = feat_size / spatial_scale
num_imgs = 2
num_rois =... | 879 | 27.387097 | 76 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_align/__init__.py | from .roi_align import RoIAlign, roi_align
__all__ = ['roi_align', 'RoIAlign']
| 80 | 19.25 | 42 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_pool/roi_pool.py | import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from . import roi_pool_cuda
class RoIPoolFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale):
... | 2,544 | 32.486842 | 78 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_pool/gradcheck.py | import os.path as osp
import sys
import torch
from torch.autograd import gradcheck
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_pool import RoIPool # noqa: E402, isort:skip
feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda()
rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55]... | 513 | 29.235294 | 66 | py |
AlignShift | AlignShift-master/mmdet/ops/roi_pool/__init__.py | from .roi_pool import RoIPool, roi_pool
__all__ = ['roi_pool', 'RoIPool']
| 75 | 18 | 39 | py |
AlignShift | AlignShift-master/mmdet/ops/nms/nms_wrapper.py | import numpy as np
import torch
from . import nms_cpu, nms_cuda
from .soft_nms_cpu import soft_nms_cpu
def nms(dets, iou_thr, device_id=None):
"""Dispatch to either CPU or GPU NMS implementations.
The input can be either a torch tensor or numpy array. GPU NMS will be used
if the input is a gpu tensor or... | 3,663 | 34.572816 | 79 | py |
AlignShift | AlignShift-master/mmdet/ops/nms/__init__.py | from .nms_wrapper import nms, soft_nms
__all__ = ['nms', 'soft_nms']
| 70 | 16.75 | 38 | py |
tensorsketch | tensorsketch-master/setup.py | import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="tensorsketch",
version="0.0.1",
author="Yang Guo, Yiming Sun, Charlene Luo",
author_email="yg93@cornell.edu, ys784@cornell.edu, cl894@cornell.edu",
description="Implementation of two-pass ... | 954 | 29.806452 | 91 | py |
tensorsketch | tensorsketch-master/examples/weather/simulation_weather.py | import netCDF4 as nc
import numpy as np
import matplotlib.pyplot as plt
import pickle
import tensorly
import matplotlib.ticker as ticker
import tensorsketch
from tensorsketch.tensor_approx import TensorApprox
import warnings
# In[8]:
def simrun_name(name, inv_factor, rm_typ):
'''
Create an file name for a ... | 6,738 | 43.629139 | 135 | py |
tensorsketch | tensorsketch-master/examples/weather/plot_util.py | import matplotlib.pyplot as plt
MARKER_LIST = ["s", "x", "o", "+", "*", "d", "^", "v"]
MARKER_COLOR_LIST = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'lawngreen', 'violet']
def find_rm_label(rm_typ):
if rm_typ == "g":
return "Gaussian"
elif rm_typ == "u":
return "Uniform"
elif rm_typ == "sp0":
... | 2,095 | 30.283582 | 111 | py |
tensorsketch | tensorsketch-master/examples/video/video_server.py | import numpy as np
import numpy as np
import matplotlib.pyplot as plt
import pickle
import tensorly as tl
import matplotlib.ticker as ticker
import tensorsketch
from tensorsketch.tensor_approx import TensorApprox, eval_rerr
import warnings
from tensorly.decomposition import tucker
from tensorsketch.util import RandomIn... | 5,487 | 37.377622 | 130 | py |
tensorsketch | tensorsketch-master/examples/video/plot_util.py | import matplotlib.pyplot as plt
MARKER_LIST = ["s", "x", "o", "+", "*", "d", "^", "v"]
MARKER_COLOR_LIST = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'lawngreen', 'violet']
def find_rm_label(rm_typ):
if rm_typ == "g":
return "Gaussian"
elif rm_typ == "u":
return "Uniform"
elif rm_typ == "sp0":
... | 2,095 | 30.283582 | 111 | py |
tensorsketch | tensorsketch-master/examples/simulation/main.py | import numpy as np
from scipy import fftpack
import tensorly as tl
import time
from tensorly.decomposition import tucker
import tensorsketch
from tensorsketch import util
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import pickle
import simulation
def sim_name(gen_type, r, nois... | 3,168 | 40.697368 | 118 | py |
tensorsketch | tensorsketch-master/examples/simulation/small_test.py | import numpy as np
from tensorsketch.tensor_approx import TensorApprox
from tensorsketch.util import square_tensor_gen
import tensorly as tl
n = 100
k = 20
rank = 5
dim = 3
s = 2 * k + 1
ranks = np.repeat(rank, dim)
ks = np.repeat(k, dim)
ss = np.repeat(s, dim)
tensor_shape = np.repeat(n, dim)
noise_level = 0.1
gen_ty... | 1,501 | 26.309091 | 80 | py |
tensorsketch | tensorsketch-master/examples/simulation/simulation.py | import numpy as np
from scipy import fftpack
import tensorly as tl
import tensorsketch
from tensorsketch import util
import time
from tensorly.decomposition import tucker
from tensorsketch.tensor_approx import TensorApprox
from tensorsketch.util import square_tensor_gen
class Simulation(object):
'''
In this s... | 3,351 | 37.090909 | 103 | py |
tensorsketch | tensorsketch-master/examples/simulation/simulation_server.py | # coding: utf-8
# In[1]:
import numpy as np
from scipy import fftpack
import tensorly as tl
import time
from tensorly.decomposition import tucker
import tensorsketch
from tensorsketch import util
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import pickle
import simulation
impo... | 12,836 | 44.846429 | 120 | py |
tensorsketch | tensorsketch-master/examples/simulation/plot_util.py | import matplotlib.pyplot as plt
MARKER_LIST = ["s", "x", "o", "+", "*", "d", "^", "v"]
MARKER_COLOR_LIST = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'lawngreen', 'violet']
def find_rm_label(rm_typ):
if rm_typ == "g":
return "Gaussian"
elif rm_typ == "u":
return "Uniform"
elif rm_typ == "sp0":
... | 2,095 | 30.283582 | 111 | py |
tensorsketch | tensorsketch-master/examples/combustion/combustion_test.py | import numpy as np
import pickle
import tensorsketch
from tensorsketch.tensor_approx import TensorApprox
import warnings
warnings.filterwarnings('ignore')
def simrun_name(name, inv_factor, rm_typ):
'''
Create an file name for a simulation run
'''
return "data/" + name + "_frk" + str(inv_factor) + "_... | 1,247 | 30.2 | 100 | py |
tensorsketch | tensorsketch-master/examples/combustion/plot_util.py | import matplotlib.pyplot as plt
MARKER_LIST = ["s", "x", "o", "+", "*", "d", "^", "v"]
MARKER_COLOR_LIST = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'lawngreen', 'violet']
def find_rm_label(rm_typ):
if rm_typ == "g":
return "Gaussian"
elif rm_typ == "u":
return "Uniform"
elif rm_typ == "sp0":
... | 2,095 | 30.283582 | 111 | py |
tensorsketch | tensorsketch-master/tensorsketch/random_projection.py | import numpy as np
import tensorly as tl
def random_matrix_generator(n, k, typ="g", target='col'):
"""
routine for usage: A \Omega or \Omega^\top x : n >> m
:param n: first dimension of random matrix to be generated
:param k: second dimension of random matrix to be generated
:param type:
:para... | 4,424 | 35.570248 | 103 | py |
tensorsketch | tensorsketch-master/tensorsketch/evaluate.py | import numpy as np
def eval_rerr(X, X_hat, X0=None):
"""
:param X: tensor, X0 or X0+noise
:param X_hat: output for apporoximation
:param X0: true signal, tensor
:return: the relative error = ||X- X_hat||_F/ ||X_0||_F
"""
if X0 is not None:
error = X0 - X_hat
return np.linalg.... | 583 | 37.933333 | 74 | py |
tensorsketch | tensorsketch-master/tensorsketch/recover_from_sketches.py | #######################
# *
# Yiming Sun *
# 11/2019 *
# *
#######################
"""
This file contains class
to return an approximation from
sketches. Two pass algorithm also need the original
tensor while one pass algorithm requires
"""
import numpy as... | 8,961 | 35.283401 | 129 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.