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 |
|---|---|---|---|---|---|---|
DetNAS | DetNAS-master/maskrcnn_benchmark/layers/dcn/deform_pool_module.py | from torch import nn
from .deform_pool_func 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,
... | 6,307 | 40.774834 | 79 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/layers/dcn/deform_conv_module.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from .deform_conv_func import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
... | 5,802 | 31.601124 | 78 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/engine/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import time
import os
import torch
from tqdm import tqdm
import numpy as np
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.data.datasets.evaluation import evaluate
from ..utils.comm import is_main_process, get_wo... | 15,299 | 32.774834 | 130 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/engine/bbox_aug.py | import torch
import torchvision.transforms as TT
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.data import transforms as T
from maskrcnn_benchmark.structures.image_list import to_image_list
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.modeling.roi_heads.box... | 4,440 | 36.319328 | 98 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/engine/trainer.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import os
import time
import torch
import torch.distributed as dist
from tqdm import tqdm
import numpy as np
from maskrcnn_benchmark.data import make_data_loader
from maskrcnn_benchmark.utils.comm import get_world_si... | 8,317 | 36.809091 | 145 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/c2_model_loading.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import pickle
from collections import OrderedDict
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.registry import Registry
def _rename_basic_resnet_weights(layer... | 8,677 | 38.990783 | 129 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/complexity.py | import sys
import torch
import torch.nn as nn
from torch import Tensor
from torch.nn import Module
from maskrcnn_benchmark.utils.module_flops_comp import MODULE_FLOPS_COMP
class Complexity(object):
__all_modules__ = (nn.Conv2d,)
"""docstring for Complexity"""
def __init__(self, mode='flops', module_flop... | 2,018 | 30.546875 | 72 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/metric_logger.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import defaultdict
from collections import deque
import torch
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the global series average.
"""
def __... | 1,862 | 26.80597 | 82 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
from maskrcnn_benchmark.utils.imports import import_file
from mask... | 4,836 | 33.55 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/comm.py | """
This file contains primitives for multi-gpu communication.
This is useful when doing distributed training.
"""
import pickle
import time
import torch
import torch.distributed as dist
def get_world_size():
if not dist.is_available():
return 1
if not dist.is_initialized():
return 1
ret... | 3,372 | 27.584746 | 84 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.... | 3,045 | 48.129032 | 135 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/collect_env.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import PIL
from torch.utils.collect_env import get_pretty_env_info
def get_pil_version():
return "\n Pillow ({})".format(PIL.__version__)
def collect_env_info():
env_str = get_pretty_env_info()
env_str += get_pil_version()
... | 338 | 21.6 | 71 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
from maskrcnn_benchmark.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that w... | 3,464 | 41.777778 | 91 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/module_flops_comp.py | import sys
import torch
import torch.nn as nn
from torch import Tensor
from torch.nn import Module
from maskrcnn_benchmark.utils.registry import Registry
sys.setrecursionlimit(10000)
MODULE_FLOPS_COMP = Registry()
@MODULE_FLOPS_COMP.register("Conv2d")
def build_conv2d_flops(module: Module, oup: Tensor):
kh, ... | 745 | 23.866667 | 65 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/utils/imports.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
if torch._six.PY3:
import importlib
import importlib.util
import sys
# from https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?utm_medium=organic&utm_source=google_rich_qa&utm_campai... | 843 | 34.166667 | 168 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import copy
import logging
import torch.utils.data
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.imports import import_file
from maskrcnn_benchmark.utils.miscellaneous import save_labels
from... | 7,156 | 38.10929 | 143 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/datasets/voc.py | import os
import torch
import torch.utils.data
from PIL import Image
import sys
if sys.version_info[0] == 2:
import xml.etree.cElementTree as ET
else:
import xml.etree.ElementTree as ET
from maskrcnn_benchmark.structures.bounding_box import BoxList
class PascalVOCDataset(torch.utils.data.Dataset):
CL... | 4,168 | 29.654412 | 118 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/datasets/concat_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
class ConcatDataset(_ConcatDataset):
"""
Same as torch.utils.data.dataset.ConcatDataset, but exposes an extra
method for querying the sizes of the ima... | 766 | 30.958333 | 72 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/datasets/abstract.py | import torch
class AbstractDataset(torch.utils.data.Dataset):
"""
Serves as a common interface to reduce boilerplate and help dataset
customization
A generic Dataset for the maskrcnn_benchmark must have the following
non-trivial fields / methods implemented:
CLASSES - list/tuple:
... | 2,309 | 32.478261 | 80 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/datasets/coco.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torchvision
import os
from PIL import Image
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
from maskrcnn_benchmark.structures.keypoint... | 4,405 | 34.532258 | 85 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
... | 14,055 | 34.405542 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/samplers/grouped_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
class GroupedBatchSampler(BatchSampler):
"""
Wraps another sampler to yield a mini-batch of indices.
It enfo... | 4,845 | 40.775862 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/samplers/iteration_based_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... | 1,164 | 35.40625 | 71 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/samplers/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Code is copy-pasted exactly as in torch.utils.data.distributed.
# FIXME remove this once c10d fixes the bug it has
import math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class DistributedSampler(S... | 2,569 | 37.358209 | 86 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/data/transforms/transforms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import random
import torch
import torchvision
from torchvision.transforms import functional as F
class Compose(object):
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, image, target):
for ... | 3,477 | 27.508197 | 83 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
ground-truth element may be assigned t... | 5,129 | 44.39823 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/make_layers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.modeling.poolers import P... | 3,760 | 28.849206 | 82 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
"""
assert isinstance(tensors, (list, tuple))
if ... | 400 | 22.588235 | 97 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.layers import ROIAlign
from .utils import cat
class LevelMapper(object):
"""Determine which FPN level each RoI in a set of RoIs should map to based
... | 4,561 | 33.044776 | 90 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
uint8 = torch.bool
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, positive_fract... | 2,725 | 37.942857 | 90 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used for training the regressors.
"""
def __init__(self, weights, bbox_xform_clip=math.log(1... | 3,367 | 34.083333 | 86 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/detnasnet.py | import torch.nn as nn
from maskrcnn_benchmark.modeling.backbone.shuffle_blocks import ConvBNReLU, ShuffleNetV2BlockSearched, blocks_key
class ShuffleNetV2DetNAS(nn.Module):
def __init__(self, cfg):
super(ShuffleNetV2DetNAS, self).__init__()
model_size = cfg.MODEL.BACKBONE.CONV_BODY.lstrip('DETNAS-... | 3,775 | 45.617284 | 138 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 15,159 | 30.257732 | 85 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/fbnet_builder.py | """
FBNet model builder
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from maskrcnn_benchmark.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
... | 24,964 | 29.078313 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/fbnet.py | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from maskrcnn_benchmark.modeling import registry
from mas... | 7,845 | 30.011858 | 83 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/backbone.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . im... | 4,896 | 36.098485 | 109 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/fpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.pytorch_distributed_syncbn.syncbn import DistributedSyncBN
class FPN(nn.Module):
"""
Module that adds FPN on top of a list of feature maps.
The ... | 4,251 | 39.495238 | 86 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/backbone/shuffle_blocks.py | import torch
import torch.nn as nn
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.pytorch_distributed_syncbn.syncbn import DistributedSyncBN
batch_norm = DistributedSyncBN
blocks_key = [
'shufflenet_3x3',
'shufflenet_5x5',
'shufflenet_7x7',
'xception_3x3',
]
Blocks = {
'shufflen... | 10,228 | 47.709524 | 209 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
import torch
from torch import nn
from maskrcnn_benchmark.structures.image_list import to_image_list
from ..backbone import build_backbone
from ..rpn.rpn import build_rpn
from ..roi_heads.roi_he... | 2,661 | 34.026316 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist
from maskrcnn_benchmark.structures.boxlist_ops... | 7,780 | 36.229665 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/anchor_generator.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
class BufferList(nn.Module):
"""
Similar to nn.ParameterList, but for buffers
"""
def __init__(self... | 9,947 | 33.303448 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains specific functions for computing losses on the RPN
file
"""
import torch
from torch.nn import functional as F
from .utils import concat_box_prediction_layers
from ..balanced_positive_negative_sampler import BalancedPositiv... | 5,775 | 35.556962 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Utility functions minipulating the prediction layers
"""
from ..utils import cat
import torch
def permute_and_flatten(layer, N, A, C, H, W):
layer = layer.view(N, -1, C, H, W)
layer = layer.permute(0, 3, 4, 1, 2)
layer = layer.re... | 1,679 | 35.521739 | 80 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.rpn.retinanet.retinanet import build_ret... | 7,616 | 35.620192 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/retinanet/inference.py | import torch
from ..inference import RPNPostProcessor
from ..utils import permute_and_flatten
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.utils import cat
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,865 | 34.391753 | 79 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/retinanet/loss.py | """
This file contains specific functions for computing losses on the RetinaNet
file
"""
import torch
from torch.nn import functional as F
from ..utils import concat_box_prediction_layers
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.layers import SigmoidFocalLoss
from maskrcnn_benchma... | 3,484 | 31.268519 | 83 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/rpn/retinanet/retinanet.py | import math
import torch
import torch.nn.functional as F
from torch import nn
from .inference import make_retinanet_postprocessor
from .loss import make_retinanet_loss_evaluator
from ..anchor_generator import make_anchor_generator_retinanet
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_ben... | 5,699 | 34.849057 | 92 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .box_head.box_head import build_roi_box_head
from .mask_head.mask_head import build_roi_mask_head
from .keypoint_head.keypoint_head import build_roi_keypoint_head
class CombinedROIHeads(torch.nn.ModuleDict):
"""
Combine... | 3,269 | 41.467532 | 96 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.layers.misc import interpolate
from maskrcnn_benchmark.structures.bounding_box import BoxList
# TODO check if want to return a single BoxList or a composite
# object
cl... | 6,698 | 30.9 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
fr... | 2,502 | 33.287671 | 82 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmar... | 5,367 | 36.538462 | 80 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.layers import ConvTranspose2d
from maskrcnn_benchmark.modeling import registry
@registry.ROI_MASK_PREDICTOR.register("... | 2,229 | 37.448276 | 83 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from .roi_mask_feature_extractors import make_roi_mask_feature_extractor
from .roi_mask_predictors import make_roi_mask_predictor
from .inference imp... | 3,126 | 36.22619 | 86 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,695 | 37.705202 | 88 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.backbone import resnet
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_be... | 5,634 | 35.121795 | 82 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from .roi_box_feature_extractors import make_roi_box_feature_extractor
from .roi_box_predictors import make_roi_box_predictor
from .inference import make_roi_box_post_processor
from .loss import make_roi_box_loss_... | 2,765 | 37.416667 | 96 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.struc... | 7,059 | 35.391753 | 90 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark.modeling import registry
from torch import nn
@registry.ROI_BOX_PREDICTOR.register("FastRCNNPredictor")
class FastRCNNPredictor(nn.Module):
def __init__(self, config, in_channels):
super(FastRCNNPredictor, self... | 2,295 | 35.444444 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/inference.py | import torch
from torch import nn
class KeypointPostProcessor(nn.Module):
def __init__(self, keypointer=None):
super(KeypointPostProcessor, self).__init__()
self.keypointer = keypointer
def forward(self, x, boxes):
mask_prob = x
scores = None
if self.keypointer:
... | 4,468 | 34.468254 | 102 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/roi_keypoint_feature_extractors.py | from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_benchmark.layers import Conv2d
@registry.ROI_KEYPOINT_FEATURE_EXTRACTORS.register("KeypointRCNNFeatureExtractor")
class KeypointRCNNFeatureE... | 1,892 | 36.117647 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/loss.py | import torch
from torch.nn import functional as F
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmark.modeli... | 7,104 | 37.61413 | 90 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/keypoint_head.py | import torch
from .roi_keypoint_feature_extractors import make_roi_keypoint_feature_extractor
from .roi_keypoint_predictors import make_roi_keypoint_predictor
from .inference import make_roi_keypoint_post_processor
from .loss import make_roi_keypoint_loss_evaluator
class ROIKeypointHead(torch.nn.Module):
def __i... | 2,057 | 38.576923 | 86 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/roi_keypoint_predictors.py | from torch import nn
from maskrcnn_benchmark import layers
from maskrcnn_benchmark.modeling import registry
@registry.ROI_KEYPOINT_PREDICTOR.register("KeypointRCNNPredictor")
class KeypointRCNNPredictor(nn.Module):
def __init__(self, cfg, in_channels):
super(KeypointRCNNPredictor, self).__init__()
... | 1,273 | 31.666667 | 81 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/structures/image_list.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from __future__ import division
import torch
class ImageList(object):
"""
Structure that holds a list of images (of possibly
varying sizes) as a single tensor.
This works by padding the images to the same size,
and storing in... | 2,485 | 33.054795 | 87 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/structures/segmentation_mask.py | import cv2
import copy
import torch
import numpy as np
from maskrcnn_benchmark.layers.misc import interpolate
from maskrcnn_benchmark.utils import cv2_util
import pycocotools.mask as mask_utils
# transpose
FLIP_LEFT_RIGHT = 0
FLIP_TOP_BOTTOM = 1
""" ABSTRACT
Segmentations come in either:
1) Binary masks
2) Polygons
... | 18,793 | 31.515571 | 94 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/structures/bounding_box.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
# transpose
FLIP_LEFT_RIGHT = 0
FLIP_TOP_BOTTOM = 1
class BoxList(object):
"""
This class represents a set of bounding boxes.
The bounding boxes are represented as a Nx4 Tensor.
In order to uniquely determine the bou... | 9,645 | 35.127341 | 92 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/structures/boxlist_ops.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .bounding_box import BoxList
from maskrcnn_benchmark.layers import nms as _box_nms
def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="scores"):
"""
Performs non-maximum suppression on a boxlist, with s... | 3,716 | 27.592308 | 97 | py |
DetNAS | DetNAS-master/maskrcnn_benchmark/structures/keypoint.py | import torch
# transpose
FLIP_LEFT_RIGHT = 0
FLIP_TOP_BOTTOM = 1
class Keypoints(object):
def __init__(self, keypoints, size, mode=None):
# FIXME remove check once we have better integration with device
# in my version this would consistently return a CPU tensor
device = keypoints.device ... | 6,555 | 33.687831 | 97 | py |
DetNAS | DetNAS-master/tests/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import os
from tempfile import TemporaryDirectory
import unittest
import torch
from torch import nn
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.checkpo... | 4,645 | 38.042017 | 88 | py |
DetNAS | DetNAS-master/tests/test_detectors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import glob
import os
import copy
import torch
from maskrcnn_benchmark.modeling.detector import build_detection_model
from maskrcnn_benchmark.structures.image_list import to_image_list
import utils
CONFIG_FILES = [
# bbox
... | 4,223 | 28.333333 | 71 | py |
DetNAS | DetNAS-master/tests/test_nms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import numpy as np
import torch
from maskrcnn_benchmark.layers import nms as box_nms
class TestNMS(unittest.TestCase):
def test_nms_cpu(self):
""" Match unit test UtilsNMSTest.TestNMS in
caffe2/operators/... | 7,612 | 33.292793 | 76 | py |
DetNAS | DetNAS-master/tests/test_backbones.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import copy
import torch
# import modules to to register backbones
from maskrcnn_benchmark.modeling.backbone import build_backbone # NoQA
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.config import cfg as... | 1,914 | 33.196429 | 75 | py |
DetNAS | DetNAS-master/tests/test_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import copy
import torch
# import modules to to register feature extractors
from maskrcnn_benchmark.modeling.backbone import build_backbone # NoQA
from maskrcnn_benchmark.modeling.roi_heads.roi_heads import build_roi_heads # NoQA
f... | 3,070 | 31.670213 | 82 | py |
DetNAS | DetNAS-master/tests/test_fbnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import numpy as np
import torch
import maskrcnn_benchmark.modeling.backbone.fbnet_builder as fbnet_builder
TEST_CUDA = torch.cuda.is_available()
def _test_primitive(self, device, op_name, op_func, N, C_in, C_out, expand, strid... | 2,845 | 32.482353 | 84 | py |
DetNAS | DetNAS-master/tests/test_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import copy
import torch
# import modules to to register predictors
from maskrcnn_benchmark.modeling.backbone import build_backbone # NoQA
from maskrcnn_benchmark.modeling.roi_heads.roi_heads import build_roi_heads # NoQA
from mask... | 3,214 | 31.474747 | 82 | py |
DetNAS | DetNAS-master/tests/test_data_samplers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import random
import unittest
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
from torch.utils.data.sampler import SequentialSampler
from torch.utils.data.sampler import RandomSampler... | 5,532 | 34.928571 | 88 | py |
DetNAS | DetNAS-master/tests/test_rpn_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import copy
import torch
# import modules to to register rpn heads
from maskrcnn_benchmark.modeling.backbone import build_backbone # NoQA
from maskrcnn_benchmark.modeling.rpn.rpn import build_rpn # NoQA
from maskrcnn_benchmark.mode... | 1,992 | 30.634921 | 71 | py |
DetNAS | DetNAS-master/tests/test_segmentation_mask.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import torch
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
class TestSegmentationMask(unittest.TestCase):
def __init__(self, method_name='runTest'):
super(TestSegmentationMask, self).__in... | 2,414 | 33.5 | 76 | py |
DetNAS | DetNAS-master/tests/test_box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import numpy as np
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
class TestBoxCoder(unittest.TestCase):
def test_box_decoder(self):
""" Match unit test UtilsBoxesTest.TestBboxTransformRandom... | 3,112 | 27.3 | 80 | py |
DetNAS | DetNAS-master/distributed_arch_search/test_server.py | #!/usr/bin/env python3
from multiprocessing import Process
from multiprocessing import Queue
import argparse
import logging
import pickle
import shutil
import os
import sys
import time
import hashlib
import glob
import re
import gc
import uuid
import numpy as np
from tqdm import tqdm
import tempfile
import functools
... | 13,017 | 31.222772 | 91 | py |
DetNAS | DetNAS-master/distributed_arch_search/search.py | import os
import sys
import time
import glob
import numpy as np
import pickle
import torch
import logging
import argparse
import functools
from maskrcnn_benchmark.modeling.detector.generalized_rcnn import GeneralizedRCNN
from maskrcnn_benchmark.utils.complexity import Complexity
from maskrcnn_benchmark.config import ... | 9,671 | 30.711475 | 103 | py |
DetNAS | DetNAS-master/demo/webcam.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import argparse
import cv2
from maskrcnn_benchmark.config import cfg
from predictor import COCODemo
import time
def main():
parser = argparse.ArgumentParser(description="PyTorch Object Detection Webcam Demo")
parser.add_argument(
... | 2,329 | 27.765432 | 88 | py |
DetNAS | DetNAS-master/demo/predictor.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import cv2
import torch
from torchvision import transforms as T
from torchvision.transforms import functional as F
from maskrcnn_benchmark.modeling.detector import build_detection_model
from maskrcnn_benchmark.utils.checkpoint import DetectronCheck... | 16,522 | 34.006356 | 86 | py |
RobustLoc | RobustLoc-main/eval.py |
import os
import torch
import os.path as osp
import numpy as np
import matplotlib
import sys
DISPLAY = 'DISPLAY' in os.environ
if not DISPLAY:
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from tqdm import tqdm
from tools.options import Options
from network.robustloc import RobustLoc
from torchvision impo... | 6,258 | 31.942105 | 170 | py |
RobustLoc | RobustLoc-main/train.py | import os
import torch
import sys
import time
import os.path as osp
import numpy as np
from tqdm import tqdm
from tools.options import Options
from network.robustloc import RobustLoc
from torchvision import transforms
from tools.utils import AtLocPlusCriterion
from data.dataloaders import RobotCar
from torch.utils... | 7,631 | 30.66805 | 180 | py |
RobustLoc | RobustLoc-main/tools/utils.py |
import os
import torch
from torch import nn
import transforms3d.quaternions as txq
import numpy as np
import sys
from torchvision.datasets.folder import default_loader
from collections import OrderedDict
from tools.options import Options
import random
import torchvision.transforms.functional as TVF
import os.path a... | 10,302 | 26.921409 | 141 | py |
RobustLoc | RobustLoc-main/network/resnet.py | import torch
from torch import Tensor
import torch.nn as nn
from torch.hub import load_state_dict_from_url
from typing import Type, Any, Callable, Union, List, Optional
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide... | 15,447 | 38.610256 | 111 | py |
RobustLoc | RobustLoc-main/network/robustloc.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init
from network.gatt import GATT
from network.vvit import VVITLayer
from tools.utils import set_seed
set_seed(7)
from tools.options import Options
opt = Options().parse()
class RobustLoc(nn.Module):
def __init__(self, featu... | 4,106 | 20.170103 | 113 | py |
RobustLoc | RobustLoc-main/network/gatt.py |
import torch.nn as nn
import torch.nn.functional as F
import torch
from torchdiffeq import odeint
from tools.options import Options
opt = Options().parse()
class GraphAttentionLayer(nn.Module):
def __init__(self,
in_features,
hidden_features,
concat=False,
n_heads=4):
... | 5,285 | 20.753086 | 98 | py |
RobustLoc | RobustLoc-main/network/vvit.py | import torch
import torch.nn as nn
from tools.options import Options
from tools.utils import set_seed
import torch.nn.functional as F
from torchdiffeq import odeint
set_seed(7)
opt = Options().parse()
class VVITLayer(nn.Module):
def __init__(self,
in_features,
hidden_features,
n_heads,
... | 3,008 | 23.266129 | 99 | py |
RobustLoc | RobustLoc-main/data/dataloaders.py | import os
import random
import torch
import numpy as np
import os.path as osp
from tools.utils import process_poses, load_image
from torch.utils import data
from tools.options import Options
from torchvision import transforms
import torchvision.transforms.functional as TVF
from tools.utils import set_seed
set_seed(7)
o... | 9,109 | 30.413793 | 133 | py |
MTGODE | MTGODE-main/layer.py | from __future__ import division
import torch
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
import torchdiffeq
import numbers
class nconv(nn.Module):
def __init__(self):
super(nconv,self).__init__()
def forward(self,x, A):
# x.shape = (batch, dim, nodes, seq_l... | 14,293 | 31.634703 | 126 | py |
MTGODE | MTGODE-main/run_multi_step.py | import argparse
import time
import numpy as np
from util import *
import torch.optim as optim
from trainer import Trainer
from model import MTGODE
def str_to_bool(value):
if isinstance(value, bool):
return value
if value.lower() in {'false', 'f', '0', 'no', 'n'}:
return False
elif value.lo... | 13,377 | 43.593333 | 178 | py |
MTGODE | MTGODE-main/model.py | from layer import dilated_inception, mixprop, CGP, graph_constructor
import torchdiffeq
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
class ODEFunc(nn.Module):
def __init__(self, stnet):
super(ODEFunc, self).__init__()
self.stnet = stnet
self.... | 7,952 | 40.638743 | 143 | py |
MTGODE | MTGODE-main/util.py | import pickle
import numpy as np
import os
import scipy.sparse as sp
import torch
from scipy.sparse import linalg
from torch.autograd import Variable
def normal_std(x):
return x.std() * np.sqrt((len(x) - 1.) / (len(x)))
class DataLoaderS(object):
# train and valid is the ratio of training set and validation... | 9,996 | 31.777049 | 113 | py |
MTGODE | MTGODE-main/trainer.py | import torch
import torch.optim as optim
import util
class Trainer():
def __init__(self, model, lrate, wdecay, clip, step_size, seq_out_len, scaler, device, cl=True):
self.scaler = scaler
self.model = model
self.model.to(device)
self.optimizer = optim.Adam(self.model.parameters(), ... | 2,626 | 39.415385 | 102 | py |
MTGODE | MTGODE-main/run_single_step.py | import argparse
import math
import time
import torch.nn as nn
import torch.optim as optim
from util import *
# from trainer import Optim
from model import MTGODE
def str_to_bool(value):
if isinstance(value, bool):
return value
if value.lower() in {'false', 'f', '0', 'no', 'n'}:
return False
... | 14,050 | 46.309764 | 146 | py |
BLDR | BLDR-main/loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import random
import math
# Loss functions
def loss_cross_entropy(epoch, y, t,class_list, ind, noise_or_not,loss_all,loss_div_all):
## Record loss and loss_div for further analysis
loss = ... | 6,206 | 35.946429 | 122 | py |
BLDR | BLDR-main/utils.py | import numpy as np
import random
import torch
import torch.nn.functional as F
class EMA():
def __init__(self, model, decay=0.9):
self.model = model
self.decay = decay
self.shadow = {}
self.backup = {}
def register(self):
for name, param in self.model.named_parameters()... | 2,119 | 27.266667 | 90 | py |
BLDR | BLDR-main/learning.py | # -*- coding:utf-8 -*-
import torch
import torch.nn.functional as F
from torch.autograd import Variable
from data.datasets import input_dataset
from models.resnet_for_selfKD import *
from models.resnet import *
from utils import *
import argparse
import time
import os
parser = argparse.ArgumentParser()
parser.add_ar... | 4,663 | 35.724409 | 220 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.