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 |
|---|---|---|---|---|---|---|
Instaboost | Instaboost-master/mmdetection/mmdet/models/anchor_heads/retina_head.py | import numpy as np
import torch.nn as nn
from mmcv.cnn import normal_init
from .anchor_head import AnchorHead
from ..registry import HEADS
from ..utils import bias_init_with_prob
@HEADS.register_module
class RetinaHead(AnchorHead):
def __init__(self,
num_classes,
in_channels,
... | 2,459 | 33.647887 | 75 | py |
Instaboost | Instaboost-master/mmdetection/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, weighted_smoothl1,
multi_apply)
from .anchor_head import AnchorHead
from ..registry import HEADS
@HEADS.register_modul... | 7,573 | 38.447917 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/models/bbox_heads/bbox_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmdet.core import (delta2bbox, multiclass_nms, bbox_target,
weighted_cross_entropy, weighted_smoothl1, accuracy)
from ..registry import HEADS
@HEADS.register_module
class BBoxHead(nn.Module):
"""Simplest RoI head, wit... | 7,749 | 36.08134 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/models/bbox_heads/convfc_bbox_head.py | import torch.nn as nn
from .bbox_head import BBoxHead
from ..registry import HEADS
from ..utils import ConvModule
@HEADS.register_module
class ConvFCBBoxHead(BBoxHead):
"""More general bbox head, with shared conv and fc layers and two optional
separated branches.
/-> cls conv... | 7,019 | 36.945946 | 79 | py |
Instaboost | Instaboost-master/mmdetection/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 |
Instaboost | Instaboost-master/mmdetection/mmdet/models/utils/norm.py | import torch.nn as nn
norm_cfg = {
# format: layer_type: (abbreviation, module)
'BN': ('bn', nn.BatchNorm2d),
'SyncBN': ('bn', None),
'GN': ('gn', nn.GroupNorm),
# and potentially 'SN'
}
def build_norm_layer(cfg, num_features, postfix=''):
""" Build normalization layer
Args:
cfg... | 1,687 | 28.103448 | 70 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/models/utils/conv_module.py | import warnings
import torch.nn as nn
from mmcv.cnn import kaiming_init, constant_init
from .norm import build_norm_layer
class ConvModule(nn.Module):
def __init__(self,
in_channels,
out_channels,
kernel_size,
stride=1,
paddin... | 2,871 | 30.56044 | 79 | py |
Instaboost | Instaboost-master/mmdetection/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 mmdet.ops import DeformConv, ModulatedDeformConv
from ..registry import BACKBONES
from ..utils import build_norm_layer
def conv3x3(in_planes, out_pl... | 14,740 | 31.397802 | 79 | py |
Instaboost | Instaboost-master/mmdetection/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, xavier_init, constant_init, kaiming_init,
normal_init)
from mmcv.runner import load_checkpoint
from ..registry import BACKBONES
@BACKBONES.register_module
class SSDVGG(VGG):
extra_se... | 4,510 | 33.435115 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/models/backbones/resnext.py | import math
import torch.nn as nn
from mmdet.ops import DeformConv, ModulatedDeformConv
from .resnet import Bottleneck as _Bottleneck
from .resnet import ResNet
from ..registry import BACKBONES
from ..utils import build_norm_layer
class Bottleneck(_Bottleneck):
def __init__(self, *args, groups=1, base_width=4,... | 7,229 | 33.927536 | 79 | py |
Instaboost | Instaboost-master/mmdetection/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 ..registry import HEADS
from ..utils import ConvModule
from mmdet.core import mask_cross_entropy, mask_target
@HEADS.register_module
class FCNMaskHead(nn.Module):
def __init__(self,
num_c... | 6,303 | 37.439024 | 78 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/custom.py | import os.path as osp
import mmcv
import numpy as np
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (ImageTransform, BboxTransform, MaskTransform,
Numpy2Tensor)
from .utils import to_tensor, random_scale
from .extra_aug import ExtraA... | 14,549 | 37.390501 | 91 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/concat_dataset.py | import numpy as np
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
class ConcatDataset(_ConcatDataset):
"""A wrapper of concatenated dataset.
Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but
concat the group flag for image aspect ratio.
Args:
datasets (list[:ob... | 698 | 29.391304 | 68 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/utils.py | import copy
from collections import Sequence
import mmcv
from mmcv.runner import obj_from_dict
import torch
import matplotlib.pyplot as plt
import numpy as np
from .concat_dataset import ConcatDataset
from .repeat_dataset import RepeatDataset
from .. import datasets
def to_tensor(data):
"""Convert objects of va... | 3,683 | 30.487179 | 72 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/transforms.py | import mmcv
import numpy as np
import torch
__all__ = ['ImageTransform', 'BboxTransform', 'MaskTransform', 'Numpy2Tensor']
class ImageTransform(object):
"""Preprocess an image.
1. rescale the image to expected size
2. normalize the image
3. flip the image (if needed)
4. pad the image (if needed)... | 3,731 | 29.590164 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/loader/sampler.py | from __future__ import division
import math
import torch
import numpy as np
from torch.distributed import get_world_size, get_rank
from torch.utils.data.sampler import Sampler
class GroupSampler(Sampler):
def __init__(self, dataset, samples_per_gpu=1):
assert hasattr(dataset, 'flag')
self.datas... | 4,682 | 34.210526 | 78 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/datasets/loader/build_loader.py | from functools import partial
from mmcv.runner import get_dist_info
from mmcv.parallel import collate
from torch.utils.data import DataLoader
from .sampler import GroupSampler, DistributedGroupSampler
# https://github.com/pytorch/pytorch/issues/973
import resource
rlimit = resource.getrlimit(resource.RLIMIT_NOFILE)
... | 1,356 | 29.155556 | 76 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/dcn/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='deform_conv',
ext_modules=[
CUDAExtension('deform_conv_cuda', [
'src/deform_conv_cuda.cpp',
'src/deform_conv_cuda_kernel.cu',
]),
CUDAExtension('deform_p... | 469 | 28.375 | 72 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/dcn/functions/deform_pool.py | import torch
from torch.autograd import Function
from .. import deform_pool_cuda
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(ctx,
data,
rois,
offset,
spatial_scale,
out_size,
out_channels,... | 2,370 | 32.871429 | 78 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/dcn/functions/deform_conv.py | import torch
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from .. import deform_conv_cuda
class DeformConvFunction(Function):
@staticmethod
def forward(ctx,
input,
offset,
weight,
stride=1,
paddin... | 7,291 | 39.065934 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/dcn/modules/deform_pool.py | from torch import nn
from ..functions.deform_pool import deform_roi_pooling
class DeformRoIPooling(nn.Module):
def __init__(self,
spatial_scale,
out_size,
out_channels,
no_trans,
group_size=1,
part_size=None,
... | 7,058 | 39.803468 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/dcn/modules/deform_conv.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from ..functions.deform_conv import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(self,
in_channels,
out_channels,
kernel_size,
... | 5,207 | 31.962025 | 78 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/sigmoid_focal_loss/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='SigmoidFocalLoss',
ext_modules=[
CUDAExtension('sigmoid_focal_loss_cuda', [
'src/sigmoid_focal_loss.cpp',
'src/sigmoid_focal_loss_cuda.cu',
]),
],
cmdcla... | 354 | 26.307692 | 67 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py | import torch.nn.functional as F
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, reduction='mean'):
ctx.sav... | 1,388 | 31.302326 | 77 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py | from torch import nn
from ..functions.sigmoid_focal_loss import sigmoid_focal_loss
class SigmoidFocalLoss(nn.Module):
def __init__(self, gamma, alpha):
super(SigmoidFocalLoss, self).__init__()
self.gamma = gamma
self.alpha = alpha
def forward(self, logits, targets):
assert l... | 643 | 25.833333 | 74 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_align/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='roi_align_cuda',
ext_modules=[
CUDAExtension('roi_align_cuda', [
'src/roi_align_cuda.cpp',
'src/roi_align_kernel.cu',
]),
],
cmdclass={'build_ext': Build... | 332 | 24.615385 | 67 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_align/gradcheck.py | import numpy as np
import torch
from torch.autograd import gradcheck
import os.path as osp
import sys
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_align import RoIAlign # noqa: E402
feat_size = 15
spatial_scale = 1.0 / 8
img_size = feat_size / spatial_scale
num_imgs = 2
num_rois = 20
batch_in... | 866 | 27.9 | 76 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_align/functions/roi_align.py | from torch.autograd import Function
from .. import roi_align_cuda
class RoIAlignFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0):
if isinstance(out_size, int):
out_h = out_size
out_w = out_size
elif isinstance(o... | 2,113 | 33.096774 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_align/modules/roi_align.py | from torch.nn.modules.module import Module
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, out_size, spatial_scale, sample_num=0):
super(RoIAlign, self).__init__()
self.out_size = out_size
self.spatial_scale = float(spatial_scale)
sel... | 535 | 30.529412 | 74 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_pool/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='roi_pool',
ext_modules=[
CUDAExtension('roi_pool_cuda', [
'src/roi_pool_cuda.cpp',
'src/roi_pool_kernel.cu',
])
],
cmdclass={'build_ext': BuildExtension}... | 322 | 23.846154 | 67 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_pool/gradcheck.py | import torch
from torch.autograd import gradcheck
import os.path as osp
import sys
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_pool import RoIPool # noqa: E402
feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda()
rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55],
... | 500 | 30.3125 | 66 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_pool/functions/roi_pool.py | import torch
from torch.autograd import Function
from .. import roi_pool_cuda
class RoIPoolFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale):
if isinstance(out_size, int):
out_h = out_size
out_w = out_size
elif isinstance(out_... | 1,815 | 31.428571 | 74 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/roi_pool/modules/roi_pool.py | from torch.nn.modules.module import Module
from ..functions.roi_pool import roi_pool
class RoIPool(Module):
def __init__(self, out_size, spatial_scale):
super(RoIPool, self).__init__()
self.out_size = out_size
self.spatial_scale = float(spatial_scale)
def forward(self, features, roi... | 399 | 25.666667 | 74 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/nms/setup.py | import os.path as osp
from setuptools import setup, Extension
import numpy as np
from Cython.Build import cythonize
from Cython.Distutils import build_ext
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
ext_args = dict(
include_dirs=[np.get_include()],
language='c++',
extra_compile_arg... | 2,678 | 30.517647 | 79 | py |
Instaboost | Instaboost-master/mmdetection/mmdet/ops/nms/nms_wrapper.py | import numpy as np
import torch
from . import nms_cuda, nms_cpu
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... | 2,580 | 31.670886 | 79 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/cascade_mask_rcnn_r101_fpn_4x.py | # model settings
model = dict(
type='CascadeRCNN',
num_stages=3,
pretrained='modelzoo://resnet101',
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
... | 6,620 | 28.039474 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/mask_rcnn_r101_fpn_4x.py | # model settings
model = dict(
type='MaskRCNN',
pretrained='modelzoo://resnet101',
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
in_channels=[256, ... | 4,763 | 27.189349 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/mask_rcnn_x101_64x4d_fpn_4x.py | # model settings
model = dict(
type='MaskRCNN',
pretrained='open-mmlab://resnext101_64x4d',
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=d... | 4,813 | 27.152047 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/mask_rcnn_x101_32x4d_fpn_4x.py | # model settings
model = dict(
type='MaskRCNN',
pretrained='open-mmlab://resnext101_32x4d',
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=d... | 4,813 | 27.152047 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/cascade_mask_rcnn_x101_32x4d_fpn_4x.py | # model settings
model = dict(
type='CascadeRCNN',
num_stages=3,
pretrained='open-mmlab://resnext101_32x4d',
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='... | 6,670 | 28.004348 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/cascade_mask_rcnn_x101_64x4d_fpn_4x.py | # model settings
model = dict(
type='CascadeRCNN',
num_stages=3,
pretrained='open-mmlab://resnext101_64x4d',
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='... | 6,670 | 28.004348 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/mask_rcnn_r50_fpn_4x.py | # model settings
model = dict(
type='MaskRCNN',
pretrained='modelzoo://resnet50',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
in_channels=[256, 51... | 4,760 | 27.171598 | 77 | py |
Instaboost | Instaboost-master/mmdetection/InstaBoost_configs/cascade_mask_rcnn_r50_fpn_4x.py | # model settings
model = dict(
type='CascadeRCNN',
num_stages=3,
pretrained='modelzoo://resnet50',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
... | 6,616 | 28.02193 | 77 | py |
Instaboost | Instaboost-master/detectron/tools/infer_simple.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import distutils.util
import os
import sys
import pprint
import subprocess
from collections import defaultdict
from six.moves import xrange
# Use a non-interactive backend
import matplotlib
mat... | 5,424 | 29.649718 | 104 | py |
Instaboost | Instaboost-master/detectron/tools/test_net.py | """Perform inference on one or more datasets."""
import argparse
import cv2
import os
import pprint
import sys
import time
import torch
import _init_paths # pylint: disable=unused-import
from core.config import cfg, merge_cfg_from_file, merge_cfg_from_list, assert_and_infer_cfg
from core.test_engine import run_infe... | 3,654 | 31.345133 | 91 | py |
Instaboost | Instaboost-master/detectron/tools/train_net_step.py | """ Training script for steps_with_decay policy"""
import argparse
import os
import sys
import pickle
import resource
import traceback
import logging
from collections import defaultdict
import numpy as np
import yaml
import torch
from torch.autograd import Variable
import torch.nn as nn
import cv2
cv2.setNumThreads(0... | 17,469 | 37.395604 | 107 | py |
Instaboost | Instaboost-master/detectron/tools/download_imagenet_weights.py | """Script to downlaod ImageNet pretrained weights from Google Drive
Extra packages required to run the script:
colorama, argparse_color_formatter
"""
import argparse
import os
import requests
from argparse_color_formatter import ColorHelpFormatter
from colorama import init, Fore
import _init_paths # pylint: dis... | 3,186 | 33.641304 | 89 | py |
Instaboost | Instaboost-master/detectron/tools/train_net.py | """ Training Script """
import argparse
import distutils.util
import os
import sys
import pickle
import resource
import traceback
import logging
from collections import defaultdict
import numpy as np
import yaml
import torch
from torch.autograd import Variable
import torch.nn as nn
import cv2
cv2.setNumThreads(0) # ... | 13,836 | 35.222513 | 103 | py |
Instaboost | Instaboost-master/detectron/lib/nn/init.py | """Parameter initialization functions
"""
import math
import operator
from functools import reduce
import torch.nn.init as init
def XavierFill(tensor):
"""Caffe2 XavierFill Implementation"""
size = reduce(operator.mul, tensor.shape, 1)
fan_in = size / tensor.shape[0]
scale = math.sqrt(3 / fan_in)
... | 594 | 22.8 | 48 | py |
Instaboost | Instaboost-master/detectron/lib/nn/modules/affine.py | import torch
import torch.nn as nn
class AffineChannel2d(nn.Module):
""" A simple channel-wise affine transformation operation """
def __init__(self, num_features):
super().__init__()
self.num_features = num_features
self.weight = nn.Parameter(torch.Tensor(num_features))
self.b... | 584 | 31.5 | 67 | py |
Instaboost | Instaboost-master/detectron/lib/nn/modules/normalization.py | """Normalization Layers"""
import torch
import torch.nn as nn
import nn.functional as myF
class GroupNorm(nn.Module):
def __init__(self, num_groups, num_channels, eps=1e-5, affine=True):
super().__init__()
self.num_groups = num_groups
self.num_channels = num_channels
self.eps = e... | 1,061 | 27.702703 | 72 | py |
Instaboost | Instaboost-master/detectron/lib/nn/modules/upsample.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class BilinearInterpolation2d(nn.Module):
"""Bilinear interpolation in space of scale.
Takes input of NxKxHxW and outputs NxKx(sH)x(sW), where s:= up_scale
Adapted from the CVPR'15 ... | 1,811 | 32.555556 | 84 | py |
Instaboost | Instaboost-master/detectron/lib/nn/parallel/replicate.py | import torch.cuda.comm as comm
def replicate(network, devices):
from ._functions import Broadcast
devices = tuple(devices)
num_replicas = len(devices)
params = list(network.parameters())
param_indices = {param: idx for idx, param in enumerate(params)}
param_copies = Broadcast.apply(devices, ... | 2,700 | 38.720588 | 74 | py |
Instaboost | Instaboost-master/detectron/lib/nn/parallel/data_parallel.py | import torch
from torch.nn import Module
from torch.autograd import Variable
from .scatter_gather import scatter_kwargs, gather
from .replicate import replicate
from .parallel_apply import parallel_apply
class DataParallel(Module):
r"""Implements data parallelism at the module level.
This container paralleli... | 7,095 | 39.318182 | 119 | py |
Instaboost | Instaboost-master/detectron/lib/nn/parallel/_functions.py | import torch
import torch.cuda.comm as comm
from torch.autograd import Function
class Broadcast(Function):
@staticmethod
def forward(ctx, target_gpus, *inputs):
if not all(input.is_cuda for input in inputs):
raise TypeError('Broadcast function not implemented for CPU tensors')
ctx... | 3,648 | 34.427184 | 98 | py |
Instaboost | Instaboost-master/detectron/lib/nn/parallel/scatter_gather.py | import collections
import re
import numpy as np
import torch
from torch.autograd import Variable
from ._functions import Scatter, Gather
from torch._six import string_classes, int_classes
from torch.utils.data.dataloader import numpy_type_map
def scatter(inputs, target_gpus, dim=0):
r"""
Slices variables into... | 3,972 | 39.131313 | 93 | py |
Instaboost | Instaboost-master/detectron/lib/nn/parallel/parallel_apply.py | import threading
import torch
from torch.autograd import Variable
def get_a_var(obj):
if isinstance(obj, Variable):
return obj
if isinstance(obj, list) or isinstance(obj, tuple):
results = map(get_a_var, obj)
for result in results:
if isinstance(result, Variable):
... | 2,096 | 28.957143 | 91 | py |
Instaboost | Instaboost-master/detectron/lib/core/test.py | # Written by Roy Tseng
#
# Based on:
# --------------------------------------------------------
# Copyright (c) 2017-present, Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
... | 34,788 | 36.407527 | 98 | py |
Instaboost | Instaboost-master/detectron/lib/core/config.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six
import os
import os.path as osp
import copy
from ast import literal_eval
import numpy as np
from packaging import version
import torch
import torch.nn as nn
f... | 41,679 | 34.746141 | 101 | py |
Instaboost | Instaboost-master/detectron/lib/core/test_engine.py | # Copyright (c) 2017-present, Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... | 14,653 | 35.819095 | 95 | py |
Instaboost | Instaboost-master/detectron/lib/utils/detectron_weight_helper.py | """Helper functions for loading pretrained weights from Detectron pickle files
"""
import pickle
import re
import torch
def load_detectron_weight(net, detectron_weight_file):
name_mapping, orphan_in_detectron = net.detectron_weight_mapping
with open(detectron_weight_file, 'rb') as fp:
src_blobs = pi... | 1,418 | 26.823529 | 78 | py |
Instaboost | Instaboost-master/detectron/lib/utils/misc.py | import os
import socket
from collections import defaultdict, Iterable
from copy import deepcopy
from datetime import datetime
from itertools import chain
import torch
from core.config import cfg
def get_run_name():
""" A unique name for each run """
return datetime.now().strftime(
'%b%d-%H-%M-%S') +... | 5,738 | 39.702128 | 111 | py |
Instaboost | Instaboost-master/detectron/lib/utils/subprocess.py | # Copyright (c) 2017-present, Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... | 5,636 | 37.609589 | 85 | py |
Instaboost | Instaboost-master/detectron/lib/utils/net.py | import logging
import os
import numpy as np
import torch
import torch.nn.functional as F
from torch.autograd import Variable
from core.config import cfg
import nn as mynn
logger = logging.getLogger(__name__)
def smooth_l1_loss(bbox_pred, bbox_targets, bbox_inside_weights, bbox_outside_weights, beta=1.0):
"""
... | 6,306 | 33.464481 | 97 | py |
Instaboost | Instaboost-master/detectron/lib/utils/resnet_weights_helper.py | """
Helper functions for converting resnet pretrained weights from other formats
"""
import os
import pickle
import torch
import nn as mynn
import utils.detectron_weight_helper as dwh
from core.config import cfg
def load_pretrained_imagenet_weights(model):
"""Load pretrained weights
Args:
num_layers... | 3,158 | 35.732558 | 90 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
#this_file = os.path.dirname(__file__)
sources = ['src/roi_crop.c']
headers = ['src/roi_crop.h']
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['sr... | 881 | 22.837838 | 75 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/functions/gridgen.py | # functions/add.py
import torch
from torch.autograd import Function
import numpy as np
class AffineGridGenFunction(Function):
def __init__(self, height, width,lr=1):
super(AffineGridGenFunction, self).__init__()
self.lr = lr
self.height, self.width = height, width
self.grid = np.ze... | 2,233 | 46.531915 | 171 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/functions/crop_resize.py | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
from cffi import FFI
ffi = FFI()
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1
self.input2 = input2
self.device_c = ffi.new("int *")
output = to... | 1,545 | 39.684211 | 126 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/functions/roi_crop.py | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
import pdb
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1.clone()
self.input2 = input2.clone()
output = input2.new(input2.size()[0], input1.size()[1], in... | 1,002 | 44.590909 | 122 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/modules/gridgen.py | from torch.nn.modules.module import Module
import torch
from torch.autograd import Variable
import numpy as np
from ..functions.gridgen import AffineGridGenFunction
import pyximport
pyximport.install(setup_args={"include_dirs":np.get_include()},
reload_support=True)
class _AffineGridGen(Module):
... | 16,557 | 38.802885 | 170 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/modules/roi_crop.py | from torch.nn.modules.module import Module
from ..functions.roi_crop import RoICropFunction
class _RoICrop(Module):
def __init__(self, layout = 'BHWD'):
super(_RoICrop, self).__init__()
def forward(self, input1, input2):
return RoICropFunction()(input1, input2)
| 287 | 31 | 48 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/_ext/crop_resize/__init__.py |
from torch.utils.ffi import _wrap_function
from ._crop_resize import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
locals[symbol] = _wrap_function(fn, _ffi)
__all__.append(symbol)
_import_symbols(locals())
| 310 | 22.923077 | 50 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_crop/_ext/roi_crop/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_crop import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] =... | 382 | 22.9375 | 53 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_align/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
# sources = ['src/roi_align.c']
# headers = ['src/roi_align.h']
sources = []
headers = []
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/roi_al... | 872 | 22.594595 | 75 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_align/functions/roi_align.py | import torch
from torch.autograd import Function
from .._ext import roi_align
# TODO use save_for_backward instead
class RoIAlignFunction(Function):
def __init__(self, aligned_height, aligned_width, spatial_scale):
self.aligned_width = int(aligned_width)
self.aligned_height = int(aligned_height)
... | 1,760 | 35.6875 | 102 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_align/modules/roi_align.py | from torch.nn.modules.module import Module
from torch.nn.functional import avg_pool2d, max_pool2d
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, aligned_height, aligned_width, spatial_scale):
super(RoIAlign, self).__init__()
self.aligned_width = int(... | 1,672 | 37.906977 | 74 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_align/_ext/roi_align/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_align import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] ... | 383 | 23 | 53 | py |
Instaboost | Instaboost-master/detectron/lib/model/utils/net_utils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import torchvision.models as models
from core.config import cfg
from model.roi_crop.functions.roi_crop import RoICropFunction
import cv2
import pdb
import random
def save_net(fname, net):
impor... | 5,497 | 30.597701 | 107 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_pooling/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
sources = ['src/roi_pooling.c']
headers = ['src/roi_pooling.h']
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/roi_pooling_cuda.c']
header... | 848 | 22.583333 | 75 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_pooling/functions/roi_pool.py | import torch
from torch.autograd import Function
from .._ext import roi_pooling
import pdb
class RoIPoolFunction(Function):
def __init__(ctx, pooled_height, pooled_width, spatial_scale):
ctx.pooled_width = pooled_width
ctx.pooled_height = pooled_height
ctx.spatial_scale = spatial_scale
... | 1,773 | 44.487179 | 108 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_pooling/modules/roi_pool.py | from torch.nn.modules.module import Module
from ..functions.roi_pool import RoIPoolFunction
class _RoIPooling(Module):
def __init__(self, pooled_height, pooled_width, spatial_scale):
super(_RoIPooling, self).__init__()
self.pooled_width = int(pooled_width)
self.pooled_height = int(pooled_... | 524 | 34 | 105 | py |
Instaboost | Instaboost-master/detectron/lib/model/roi_pooling/_ext/roi_pooling/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_pooling import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol... | 385 | 23.125 | 53 | py |
Instaboost | Instaboost-master/detectron/lib/model/nms/nms_wrapper.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
import torch
from core.config import cfg
from model.nms.nms_gpu import n... | 628 | 32.105263 | 66 | py |
Instaboost | Instaboost-master/detectron/lib/model/nms/nms_gpu.py | from __future__ import absolute_import
import torch
import numpy as np
from ._ext import nms
import pdb
def nms_gpu(dets, thresh):
keep = dets.new(dets.size(0), 1).zero_().int()
num_out = dets.new(1).zero_().int()
nms.nms_cuda(keep, dets, num_out, thresh)
keep = keep[:num_out[0]]
return keep
| 299 | 22.076923 | 47 | py |
Instaboost | Instaboost-master/detectron/lib/model/nms/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
#this_file = os.path.dirname(__file__)
sources = []
headers = []
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/nms_cuda.c']
headers += ['... | 850 | 21.394737 | 75 | py |
Instaboost | Instaboost-master/detectron/lib/model/nms/_ext/nms/__init__.py |
from torch.utils.ffi import _wrap_function
from ._nms import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] = fn
... | 377 | 22.625 | 53 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/ResNet.py | import os
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
from core.config import cfg
import nn as mynn
import utils.net as net_utils
from utils.resnet_weights_helper import convert_state_dict
# -------------------------------------------------------------------... | 14,337 | 35.115869 | 105 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/keypoint_rcnn_heads.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.autograd import Variable
from core.config import cfg
import nn as mynn
# ---------------------------------------------------------------------------- #
# Keypoint R-CNN outputs and losses
# ... | 7,410 | 40.172222 | 92 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/FPN.py | import collections
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from core.config import cfg
import utils.net as net_utils
import modeling.ResNet as ResNet
from modeling.generate_anchors import generate_anchors
from modeling.generate_proposals import G... | 20,507 | 40.180723 | 106 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/collect_and_distribute_fpn_rpn_proposals.py | import numpy as np
from torch import nn
from core.config import cfg
from datasets import json_dataset
import roi_data.fast_rcnn
import utils.blob as blob_utils
import utils.fpn as fpn_utils
class CollectAndDistributeFpnRpnProposalsOp(nn.Module):
"""Merge RPN proposals generated at multiple FPN levels and then
... | 5,054 | 41.125 | 90 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/model_builder.py | from functools import wraps
import importlib
import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from core.config import cfg
from model.roi_pooling.functions.roi_pool import RoIPoolFunction
from model.roi_crop.functions.roi_crop import RoICropFunction
... | 16,827 | 44.481081 | 112 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/rpn_heads.py | from torch import nn
from torch.nn import init
import torch.nn.functional as F
from core.config import cfg
from modeling.generate_anchors import generate_anchors
from modeling.generate_proposals import GenerateProposalsOp
from modeling.generate_proposal_labels import GenerateProposalLabelsOp
import modeling.FPN as FPN... | 6,517 | 39.484472 | 91 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/generate_proposal_labels.py | from torch import nn
from core.config import cfg
from datasets import json_dataset
import roi_data.fast_rcnn
class GenerateProposalLabelsOp(nn.Module):
def __init__(self):
super().__init__()
def forward(self, rpn_rois, roidb, im_info):
"""Op for generating training labels for RPN proposals. ... | 1,519 | 37 | 78 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/fast_rcnn_heads.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.autograd import Variable
from core.config import cfg
import nn as mynn
import utils.net as net_utils
class fast_rcnn_outputs(nn.Module):
def __init__(self, dim_in):
super().__init__()
self.c... | 8,504 | 34 | 91 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/mask_rcnn_heads.py | from functools import partial
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.autograd import Variable
from core.config import cfg
from modeling import ResNet
import nn as mynn
import utils.net as net_utils
# -----------------------------... | 14,700 | 37.085492 | 105 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/generate_proposals.py | import logging
import numpy as np
from torch import nn
from core.config import cfg
import utils.boxes as box_utils
logger = logging.getLogger(__name__)
class GenerateProposalsOp(nn.Module):
def __init__(self, anchors, spatial_scale):
super().__init__()
self._anchors = anchors
self._num_... | 8,633 | 46.180328 | 89 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/roi_xfrom/roi_align/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
# sources = ['src/roi_align.c']
# headers = ['src/roi_align.h']
sources = []
headers = []
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/roi_al... | 872 | 22.594595 | 75 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py | import torch
from torch.autograd import Function
from .._ext import roi_align
# TODO use save_for_backward instead
class RoIAlignFunction(Function):
def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio):
self.aligned_width = int(aligned_width)
self.aligned_height = int(a... | 1,868 | 37.142857 | 102 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/roi_xfrom/roi_align/modules/roi_align.py | from torch.nn.modules.module import Module
from torch.nn.functional import avg_pool2d, max_pool2d
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio):
super(RoIAlign, self).__init__()
self.alig... | 1,933 | 41.043478 | 88 | py |
Instaboost | Instaboost-master/detectron/lib/modeling/roi_xfrom/roi_align/_ext/roi_align/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_align import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] ... | 383 | 23 | 53 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.