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 |
|---|---|---|---|---|---|---|
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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,886 | 35.85514 | 88 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/fcos/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,868 | 36.12973 | 94 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/fcos/loss.py | """
This file contains specific functions for computing losses of FCOS
file
"""
import torch
from torch.nn import functional as F
from torch import nn
import os
from ..utils import concat_box_prediction_layers
from maskrcnn_benchmark.layers import IOULoss
from maskrcnn_benchmark.layers import SigmoidFocalLoss
from mas... | 11,362 | 38.454861 | 96 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/fcos/fcos.py | import math
import torch
import torch.nn.functional as F
from torch import nn
from .inference import make_fcos_postprocessor
from .loss import make_fcos_loss_evaluator
from maskrcnn_benchmark.layers import Scale
from maskrcnn_benchmark.layers import DFConv2d
class FCOSHead(torch.nn.Module):
def __init__(self, c... | 7,506 | 34.244131 | 89 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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... | 4,519 | 34.873016 | 188 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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
class RetinaNet... | 5,441 | 33.884615 | 89 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/atss/inference.py | import torch
from ..utils import permute_and_flatten
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_ml_nms
from maskrcnn_benchmark.structures.boxlist_ops import remove_small_bo... | 5,263 | 37.144928 | 97 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/atss/loss.py | import torch
from torch import nn
import os
from ..utils import concat_box_prediction_layers
from maskrcnn_benchmark.layers import SigmoidFocalLoss
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmark.structures.boxlist_ops imp... | 16,469 | 51.452229 | 117 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/atss/atss.py | import math
import torch
import torch.nn.functional as F
from torch import nn
from .inference import make_atss_postprocessor
from .loss import make_atss_loss_evaluator
from maskrcnn_benchmark.layers import Scale
from maskrcnn_benchmark.layers import DFConv2d
from ..anchor_generator import make_anchor_generator_atss
... | 9,260 | 38.918103 | 93 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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,404 | 34.559211 | 81 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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,103 | 37.608696 | 90 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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,778 | 31.489619 | 94 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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
from maskrcnn_benchmark.layers import ml_nms as _box_ml_nms
def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="scores"):
"... | 4,655 | 28.468354 | 97 | py |
SA-AutoAug | SA-AutoAug-master/maskrcnn-benchmark/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/setup.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import glob
import os
import torch
from setuptools import find_packages
from setuptools import setup
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import CppExtension
from torch.utils.cpp_ext... | 2,074 | 25.265823 | 100 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/tools/test_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from fcos_core.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch
from fco... | 3,491 | 34.632653 | 119 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/tools/remove_solver_states.py | # Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from fcos_core.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch
def main():
parser = argparse.ArgumentParser(description="Remove the solver ... | 924 | 27.90625 | 102 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/tools/train_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
r"""
Basic training script for PyTorch
"""
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from fcos_core.utils.env import setup_environment # noqa F401 isort:skip
impo... | 5,668 | 30.320442 | 119 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/solver/lr_scheduler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from bisect import bisect_right
import torch
# FIXME ideally this would be achieved with a CombinedLRScheduler,
# separating MultiStepLR with WarmupLR
# but the current LRScheduler design doesn't allow it
class WarmupMultiStepLR(torch.optim.lr_s... | 1,817 | 33.301887 | 80 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/solver/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import logging
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
logger = logging.getLogger("fcos_core.trainer")
params = []
for key, value in model.named_parameters():
if not value.requi... | 1,301 | 33.263158 | 79 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/batch_norm.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
class FrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters
are fixed
"""
def __init__(self, n):
super(FrozenBatchNorm2d, self).__init__()... | 799 | 31 | 71 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/iou_loss.py | # GIoU and Linear IoU are added by following
# https://github.com/yqyao/FCOS_PLUS/blob/master/maskrcnn_benchmark/layers/iou_loss.py.
import torch
from torch import nn
class IOULoss(nn.Module):
def __init__(self, loss_type="iou"):
super(IOULoss, self).__init__()
self.loss_type = loss_type
def ... | 1,961 | 36.730769 | 95 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/roi_pool.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from fcos_core import _C
class _ROIPool(Function):
@staticmethod
def f... | 1,846 | 27.859375 | 74 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/roi_align.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from fcos_core import _C
class _ROIAlign(Function):
@staticmethod
def ... | 2,101 | 29.463768 | 85 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/smooth_l1_loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
# TODO maybe push this to nn?
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True):
"""
very similar to the smooth_l1_loss from pytorch, but with
the extra beta parameter
"""
n = torch.abs(input - tar... | 481 | 27.352941 | 71 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/sigmoid_focal_loss.py | import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from fcos_core import _C
# TODO: Use JIT to replace CUDA implementation in the future.
class _SigmoidFocalLoss(Function):
@staticmethod
def forward(ctx, logits, targets, gamma, alpha):... | 2,333 | 29.311688 | 118 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import glob
import os.path
import torch
try:
from torch.utils.cpp_extension import load as load_ext
from torch.utils.cpp_extension import CUDA_HOME
except ImportError:
raise ImportError("The cpp layer extensions requires PyTorch 0.4 o... | 1,165 | 28.15 | 80 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/scale.py | import torch
from torch import nn
class Scale(nn.Module):
def __init__(self, init_value=1.0):
super(Scale, self).__init__()
self.scale = nn.Parameter(torch.FloatTensor([init_value]))
def forward(self, input):
return input * self.scale
| 270 | 21.583333 | 66 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
helper class that supports empty tensors on some nn functions.
Ideally, add support directly in PyTorch to empty tensors in
those functions.
This can be removed once https://github.com/pytorch/pytorch/issues/12013
is implemented
"""
import m... | 6,017 | 31.52973 | 88 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import DFConv2d
from .misc import ConvTranspose2d
from .misc import BatchNorm2d
from .misc import interpolate
from .nms import nms, ml_nms
from .roi_align i... | 1,442 | 25.722222 | 77 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/dcn/deform_conv_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from fcos_core import _C
class DeformConvFunction(Function):
@staticmethod
def forward(
ctx,
input,
offset,
weight,
stri... | 8,377 | 30.977099 | 83 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/layers/dcn/deform_pool_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from fcos_core import _C
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(
ctx,
data,
rois,
offset,
spatial_scale,
out_size,
out... | 2,607 | 26.166667 | 99 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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,
... | 6,076 | 32.20765 | 78 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/scale_aware_aug.py | import copy
import torch
import torchvision
from fcos_core.config import cfg
from fcos_core.augmentations.image_level_augs.img_level_augs import Img_augs
from fcos_core.augmentations.box_level_augs.box_level_augs import Box_augs
from fcos_core.augmentations.box_level_augs.color_augs import color_aug_func
from fcos_core... | 2,720 | 45.913793 | 185 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/image_level_augs/zoom_out.py | import math
import torch
import random
import numpy as np
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.segmentation_mask import SegmentationMask
from fcos_core.augmentations.image_level_augs.scale_jitter import scale_jitter
class Zoom_out(object):
def __init__(self, ratio=1.0, i... | 3,600 | 46.381579 | 183 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/image_level_augs/scale_jitter.py | import torch
def scale_jitter(tensor, target, jitter_factor):
if isinstance(jitter_factor, tuple):
new_h, new_w = jitter_factor
elif isinstance(jitter_factor, float):
_, h, w = tensor.shape
new_h, new_w = int(h * jitter_factor), int(w * jitter_factor)
else:
return tensor, t... | 530 | 32.1875 | 117 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/image_level_augs/zoom_in.py | import torch
import numpy as np
from fcos_core.augmentations.image_level_augs.scale_jitter import scale_jitter
class Zoom_in(object):
def __init__(self, ratio=1.0, iou_threshold=0.5):
self.ratio = ratio
self.iou_threshold = iou_threshold
def __call__(self, tensor, target):
if self.rat... | 1,445 | 38.081081 | 110 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/box_level_augs/gaussian_maps.py | import math
import torch
def _gaussian_map(img, boxes, scale_splits=None, scale_ratios=None):
g_maps = torch.zeros(*img.shape[1:]).to(img.device)
height, width = img.shape[1], img.shape[2]
x_range = torch.arange(0, height, 1).to(img.device)
y_range = torch.arange(0, width, 1).to(img.device)
xx, y... | 1,968 | 40.020833 | 111 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/box_level_augs/geometric_augs.py | import copy
import random
import torch
import torchvision.transforms as transforms
from fcos_core.config import cfg
import numpy as np
from fcos_core.structures.segmentation_mask import SegmentationMask
from fcos_core.augmentations.box_level_augs.gaussian_maps import _gaussian_map
_MAX_LEVEL = 10.0
pixel_mean = cfg.IN... | 5,528 | 48.810811 | 210 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/box_level_augs/box_level_augs.py | import torch
import random
import numpy as np
from fcos_core.config import cfg
from fcos_core.augmentations.box_level_augs.color_augs import color_aug_func
from fcos_core.augmentations.box_level_augs.geometric_augs import geometric_aug_func
pixel_mean = cfg.INPUT.PIXEL_MEAN
def _box_sample_prob(bbox, scale_ratios_sp... | 2,822 | 39.913043 | 244 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/augmentations/box_level_augs/color_augs.py | import random
import torch
import torch.nn.functional as F
from fcos_core.augmentations.box_level_augs.gaussian_maps import _merge_gaussian
_MAX_LEVEL = 10.0
def blend(image1, image2, factor):
"""Blend image1 and image2 using 'factor'.
Factor can be above 0.0. A value of 0.0 means only image1 is used.
A... | 7,934 | 38.08867 | 203 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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
from fcos_core.config import cfg
from fcos_core.data.datasets.evaluation import evaluate
from ..utils.comm import is_main_process, get_world_size
from ..utils.comm import all... | 4,163 | 32.580645 | 96 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/engine/bbox_aug.py | import torch
import torchvision.transforms as TT
from fcos_core.config import cfg
from fcos_core.data import transforms as T
from fcos_core.structures.image_list import to_image_list
from fcos_core.structures.bounding_box import BoxList
from fcos_core.modeling.rpn.fcos.inference import make_fcos_postprocessor
def im... | 4,511 | 36.289256 | 97 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/engine/trainer.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import time
import torch
import torch.distributed as dist
from fcos_core.utils.comm import get_world_size, is_pytorch_1_1_0_or_later
from fcos_core.utils.metric_logger import MetricLogger
def reduce_loss_dict(loss... | 4,033 | 32.065574 | 84 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/engine/bbox_aug_vote.py | import torch
import torchvision.transforms as TT
from fcos_core.config import cfg
from fcos_core.data import transforms as T
from fcos_core.structures.image_list import to_image_list
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.layers imp... | 11,977 | 37.514469 | 120 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.utils.model_serialization import load_state_dict
from fcos_core.utils.registry import Registry
def _rename_basic_resnet_weights(layer_keys):
layer_... | 8,368 | 39.043062 | 129 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from fcos_core.utils.model_serialization import load_state_dict
from fcos_core.utils.c2_model_loading import load_c2_format
from fcos_core.utils.imports import import_file
from fcos_core.utils.model_zoo impor... | 4,759 | 33 | 84 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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,480 | 27.532787 | 84 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.model_zoo import urlparse
from torch.utils.model_zoo import HASH_REGEX
except:
from torch.hub import _download_url_to_file
from ... | 3,083 | 46.446154 | 126 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
from fcos_core.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that we will cr... | 3,455 | 41.666667 | 91 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import copy
import logging
import torch.utils.data
from fcos_core.utils.comm import get_world_size
from fcos_core.utils.imports import import_file
from . import datasets as D
from . import samplers
from .collate_batch import BatchC... | 6,894 | 37.735955 | 143 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.structures.bounding_box import BoxList
class PascalVOCDataset(torch.utils.data.Dataset):
CLASSES = (... | 4,112 | 29.466667 | 118 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/data/datasets/coco.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torchvision
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.segmentation_mask import SegmentationMask
from fcos_core.structures.keypoint import PersonKeypoints
min_keypoints_per_image = 10
de... | 3,610 | 34.401961 | 80 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/data/datasets/evaluation/coco/coco_eval.py | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from fcos_core.modeling.roi_heads.mask_head.inference import Masker
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import boxlist_iou
def do_coco_evaluation(
... | 14,780 | 33.943262 | 88 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 ... | 2,820 | 27.785714 | 83 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.config import cfg
from fcos_core.layers import Conv2d
from fcos_core.modeling.poolers import Pooler
def get_group_gn(di... | 3,549 | 27.861789 | 78 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.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
on the ... | 4,542 | 32.902985 | 90 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/modeling/balanced_positive_negative_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, positive_fraction):
"""
... | 2,718 | 38.405797 | 90 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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",
... | 14,148 | 30.303097 | 85 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
interpola... | 24,946 | 29.056627 | 88 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.modeling import registry
from fcos_core.mo... | 7,818 | 29.905138 | 83 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/modeling/backbone/backbone.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
@... | 3,546 | 33.105769 | 81 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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
class FPN(nn.Module):
"""
Module that adds FPN on top of a list of feature maps.
The feature maps are currently supposed to be in increasing depth
order, and must b... | 3,906 | 37.683168 | 94 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/modeling/backbone/mobilenet.py | # taken from https://github.com/tonylins/pytorch-mobilenet-v2/
# Published by Ji Lin, tonylins
# licensed under the Apache License, Version 2.0, January 2004
from torch import nn
from torch.nn import BatchNorm2d
#from fcos_core.layers import FrozenBatchNorm2d as BatchNorm2d
from fcos_core.layers import Conv2d
def c... | 4,606 | 33.125926 | 97 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.structures.image_list import to_image_list
from ..backbone import build_backbone
from ..rpn.rpn import build_rpn
from ..roi_heads.roi_heads impor... | 2,222 | 32.681818 | 87 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/modeling/rpn/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.structures.boxlist_ops import boxlist_nms
from fcos_core.s... | 7,421 | 35.561576 | 87 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.structures.bounding_box import BoxList
class BufferList(nn.Module):
"""
Similar to nn.ParameterList, but for buffers
"""
def __init__(self, buffers... | 11,071 | 33.81761 | 88 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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,732 | 35.28481 | 87 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/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 fcos_core.modeling import registry
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.modeling.rpn.retinanet.retinanet import build_retinanet
from fcos_core.model... | 7,832 | 35.602804 | 88 | py |
SA-AutoAug | SA-AutoAug-master/FCOS/fcos_core/modeling/rpn/fcos/inference.py | import torch
from ..inference import RPNPostProcessor
from ..utils import permute_and_flatten
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.modeling.utils import cat
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.structu... | 6,814 | 35.837838 | 94 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.