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/detectron2/projects/DensePose/densepose/structures/cse.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass from typing import Union import torch @dataclass class DensePoseEmbeddingPredictorOutput: """ Predictor output that contains embedding and coarse segmentation data: * embedding: float tensor of size ...
1,704
31.169811
94
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/densepose/structures/transform_data.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import BinaryIO, Dict, Union import torch def normalized_coords_transform(x0, y0, w, h): """ Coordinates transform that maps top left corner to (-1, -1) and bottom right corner to (1, 1). Used for torch.grid_sample to initialize the grid ...
2,794
37.819444
128
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/densepose/structures/mesh.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import pickle from functools import lru_cache from typing import Dict, Optional, Tuple import torch from detectron2.utils.file_io import PathManager from densepose.data.meshes.catalog import MeshCatalog, MeshInfo def _maybe_copy_to_device( ...
6,330
36.023392
98
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/densepose/structures/chart_result.py
# Copyright (c) Facebook, Inc. and its affiliates. from dataclasses import dataclass from typing import Any, Optional, Tuple import torch @dataclass class DensePoseChartResult: """ DensePose results for chart-based methods represented by labels and inner coordinates (U, V) of individual charts. Each char...
6,914
36.581522
99
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/densepose/structures/chart.py
# Copyright (c) Facebook, Inc. and its affiliates. from dataclasses import dataclass from typing import Union import torch @dataclass class DensePoseChartPredictorOutput: """ Predictor output that contains segmentation and inner coordinates predictions for predefined body parts: * coarse segmentatio...
2,320
31.690141
100
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/densepose/structures/list.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from densepose.structures.data_relative import DensePoseDataRelative class DensePoseList(object): _TORCH_DEVICE_CPU = torch.device("cpu") def __init__(self, densepose_datas, boxes_xyxy_abs, image_size_hw, device=_TORCH_DEVICE_CPU): ass...
2,912
40.028169
99
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_model_e2e.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from detectron2.structures import BitMasks, Boxes, Instances from .common import get_model # TODO(plabatut): Modularize detectron2 tests and re-use def make_model_inputs(image, instances=None): if instances is None: return ...
1,137
24.863636
87
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_image_resize_transform.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from densepose.data.transform import ImageResizeTransform class TestImageResizeTransform(unittest.TestCase): def test_image_resize_1(self): images_batch = torch.ones((3, 100, 100, 3), dtype=torch.uint8) * 100 transfo...
637
36.529412
91
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/common.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import torch from detectron2.config import get_cfg from detectron2.engine import default_setup from detectron2.modeling import build_model from densepose import add_densepose_config _BASE_CONFIG_DIR = "configs" _EVOLUTION_CONFIG_SUB_DIR = "evolution" _HRN...
3,475
26.808
98
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_cse_annotations_accumulator.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import unittest import torch from detectron2.structures import Boxes, BoxMode, Instances from densepose.modeling.losses.embed_utils import CseAnnotationsAccumulator from densepose.structures import DensePoseDataRelative, DensePoseList class Tes...
8,664
34.954357
100
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_tensor_storage.py
# Copyright (c) Facebook, Inc. and its affiliates. import io import tempfile import unittest from contextlib import ExitStack import torch import torch.distributed as dist import torch.multiprocessing as mp from detectron2.utils import comm from densepose.evaluation.tensor_storage import ( SingleProcessFileTenso...
10,863
41.272374
97
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_chart_based_annotations_accumulator.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from detectron2.structures import Boxes, BoxMode, Instances from densepose.modeling.losses.utils import ChartBasedAnnotationsAccumulator from densepose.structures import DensePoseDataRelative, DensePoseList image_shape = (100, 100) inst...
3,535
44.922078
98
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DensePose/tests/test_video_keyframe_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import os import random import tempfile import unittest import torch import torchvision.io as io from densepose.data.transform import ImageResizeTransform from densepose.data.video import RandomKFramesSelector, VideoKeyframeDataset try: import ...
3,464
36.258065
95
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TridentNet/tridentnet/trident_backbone.py
# Copyright (c) Facebook, Inc. and its affiliates. import fvcore.nn.weight_init as weight_init import torch import torch.nn.functional as F from detectron2.layers import Conv2d, FrozenBatchNorm2d, get_norm from detectron2.modeling import BACKBONE_REGISTRY, ResNet, ResNetBlockBase from detectron2.modeling.backbone.resn...
7,846
34.506787
97
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TridentNet/tridentnet/trident_rpn.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from detectron2.modeling import PROPOSAL_GENERATOR_REGISTRY from detectron2.modeling.proposal_generator.rpn import RPN from detectron2.structures import ImageList @PROPOSAL_GENERATOR_REGISTRY.register() class TridentRPN(RPN): """ Trident RPN sub...
1,150
33.878788
90
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TridentNet/tridentnet/trident_conv.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch import nn from torch.nn import functional as F from torch.nn.modules.utils import _pair from detectron2.layers.wrappers import _NewEmptyTensorOp class TridentConv(nn.Module): def __init__( self, in_channels, out_ch...
3,868
34.824074
100
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/train_net.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. """ DeepLab Training Script. This script is a simplified version of the training script in detectron2/tools. """ import os import torch import detectron2.data.transforms as T import detectron2.utils.comm as comm from detectron2.checkpoint imp...
4,636
32.121429
98
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/deeplab/lr_scheduler.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List import torch from detectron2.solver.lr_scheduler import _get_warmup_factor_at_iter # NOTE: PyTorch's LR scheduler interface uses names that assume the LR changes # only on epoch boundaries. We typically use iteration based schedule...
2,398
37.079365
148
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/deeplab/build_solver.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from detectron2.config import CfgNode from detectron2.solver import build_lr_scheduler as build_d2_lr_scheduler from .lr_scheduler import WarmupPolyLR def build_lr_scheduler( cfg: CfgNode, optimizer: torch.optim.Optimizer ) -> torch.optim.lr_schedu...
883
29.482759
73
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/deeplab/resnet.py
# Copyright (c) Facebook, Inc. and its affiliates. import fvcore.nn.weight_init as weight_init import torch.nn.functional as F from detectron2.layers import CNNBlockBase, Conv2d, get_norm from detectron2.modeling import BACKBONE_REGISTRY from detectron2.modeling.backbone.resnet import ( BasicStem, BottleneckBl...
5,797
35.465409
92
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/deeplab/loss.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.nn as nn class DeepLabCE(nn.Module): """ Hard pixel mining with cross entropy loss, for semantic segmentation. This is used in TensorFlow DeepLab frameworks. Paper: DeeperLab: Single-Shot Image Parser Reference: https://g...
1,776
42.341463
147
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/DeepLab/deeplab/semantic_seg.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import Callable, Dict, List, Optional, Tuple, Union import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.layers import ASPP, Conv2d, De...
14,826
41.484241
98
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TensorMask/setup.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. import glob import os from setuptools import find_packages, setup import torch from torch.utils.cpp_extension import CUDA_HOME, CppExtension, CUDAExtension def get_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) exte...
2,040
28.157143
100
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TensorMask/tensormask/arch.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import math from typing import List import torch import torch.nn.functional as F from fvcore.nn import sigmoid_focal_loss_star_jit, smooth_l1_loss from torch import nn from detectron2.layers import ShapeSpec, batched_nms, cat, paste_masks_in_image from det...
42,127
45.091904
100
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TensorMask/tensormask/layers/swap_align2nat.py
# Copyright (c) Facebook, Inc. and its affiliates. from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from tensormask import _C class _SwapAlign2Nat(Function): @staticmethod def forward(ctx, X, lambda_val, pad_val): ctx.lambda_val = lambda...
2,083
32.612903
89
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/TensorMask/tests/test_swap_align2nat.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from torch.autograd import gradcheck from tensormask.layers.swap_align2nat import SwapAlign2Nat class SwapAlign2NatTest(unittest.TestCase): @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")...
1,048
30.787879
84
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/Panoptic-DeepLab/train_net.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. """ Panoptic-DeepLab Training Script. This script is a simplified version of the training script in detectron2/tools. """ import os import torch import detectron2.data.transforms as T import detectron2.utils.comm as comm from detectron2.checkp...
6,312
34.869318
97
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/post_processing.py
# Copyright (c) Facebook, Inc. and its affiliates. # Reference: https://github.com/bowenc0221/panoptic-deeplab/blob/master/segmentation/model/post_processing/instance_post_processing.py # noqa from collections import Counter import torch import torch.nn.functional as F def find_instance_center(center_heatmap, thres...
9,600
39.855319
142
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/dataset_mapper.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import numpy as np from typing import Callable, List, Union import torch from panopticapi.utils import rgb2id from detectron2.config import configurable from detectron2.data import MetadataCatalog from detectron2.data import detection_utils ...
4,456
37.094017
99
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/target_generator.py
# Copyright (c) Facebook, Inc. and its affiliates. # Reference: https://github.com/bowenc0221/panoptic-deeplab/blob/aa934324b55a34ce95fea143aea1cb7a6dbe04bd/segmentation/data/transforms/target_transforms.py#L11 # noqa import numpy as np import torch class PanopticDeepLabTargetGenerator(object): """ Generates...
7,653
48.064103
167
py
SA-AutoAug
SA-AutoAug-master/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/panoptic_seg.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Callable, Dict, List, Union import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.data import MetadataCatalog ...
23,513
40.036649
100
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. #!/usr/bin/env python 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,084
28.785714
100
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip import argparse import os import torch...
4,178
35.657895
119
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/tools/search.py
import os import sys import time import glob import numpy as np import pickle import torch import logging import argparse import functools import random from maskrcnn_benchmark.modeling.detector.generalized_rcnn import GeneralizedRCNN from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.utils.logger impor...
11,946
35.535168
214
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:s...
6,719
31.463768
119
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/solver/build.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from .lr_scheduler import WarmupMultiStepLR def make_optimizer(cfg, model): params = [] for key, value in model.named_parameters(): if not value.requires_grad: continue lr = cfg.SOLVER.BASE_LR ...
976
29.53125
79
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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__()...
1,094
33.21875
71
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/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 maskrcnn_benchmark import _C from apex import amp class _ROIPool(Function...
1,900
27.80303
74
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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 maskrcnn_benchmark import _C from apex import amp class _ROIAlign(Functio...
2,154
29.785714
85
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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, return_loss_vec=False): """ very similar to the smooth_l1_loss from pytorch, but with the extra beta parameter """ n ...
615
25.782609
89
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/layers/sigmoid_focal_loss.py
import torch from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from maskrcnn_benchmark import _C # TODO: Use JIT to replace CUDA implementation in the future. class _SigmoidFocalLoss(Function): @staticmethod def forward(ctx, logits, targets, gamma...
2,388
29.628205
118
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/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,499
31.663317
88
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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,431
26.018868
105
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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 maskrcnn_benchmark import _C class DeformConvFunction(Function): @staticmethod def forward( ctx, input, offset, weight, ...
8,309
30.596958
83
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/layers/dcn/deform_pool_func.py
import torch from torch.autograd import Function from torch.autograd.function import once_differentiable from maskrcnn_benchmark import _C class DeformRoIPoolingFunction(Function): @staticmethod def forward( ctx, data, rois, offset, spatial_scale, out_size, ...
2,595
26.041667
99
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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, ...
6,102
31.811828
78
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/scale_aware_aug.py
import copy import torch import torchvision from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.augmentations.image_level_augs.img_level_augs import Img_augs from maskrcnn_benchmark.augmentations.box_level_augs.box_level_augs import Box_augs from maskrcnn_benchmark.augmentations.box_level_augs.color_augs ...
2,851
46.533333
185
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/image_level_augs/zoom_out.py
import math import torch import random import numpy as np from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask from maskrcnn_benchmark.augmentations.image_level_augs.scale_jitter import scale_jitter class Zoom_out(object): def ...
3,626
46.723684
183
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/image_level_augs/zoom_in.py
import torch import numpy as np from maskrcnn_benchmark.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...
1,454
38.324324
110
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/box_level_augs/geometric_augs.py
import copy import random import torch import torchvision.transforms as transforms from maskrcnn_benchmark.config import cfg import numpy as np from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask from maskrcnn_benchmark.augmentations.box_level_augs.gaussian_maps import _gaussian_map _MAX_LEVEL...
5,612
49.116071
210
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/box_level_augs/box_level_augs.py
import torch import random import numpy as np from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.augmentations.box_level_augs.color_augs import color_aug_func from maskrcnn_benchmark.augmentations.box_level_augs.geometric_augs import geometric_aug_func pixel_mean = cfg.INPUT.PIXEL_MEAN def _box_sample...
2,849
40.304348
244
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/augmentations/box_level_augs/color_augs.py
import random import torch import torch.nn.functional as F from maskrcnn_benchmark.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 us...
7,942
38.321782
203
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.data.datasets.evaluation import evaluate from ..utils.comm import is_main_process, get_world_size from ..uti...
4,297
33.111111
96
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 from maskrcnn_benchmark.data import make_data_loader from maskrcnn_benchmark.utils.comm import get_world_size, synchronize fr...
7,762
37.430693
146
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/engine/bbox_aug_vote.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.structures.boxlist_ops...
12,092
37.759615
120
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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,386
39.129187
129
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/cityscapes.py
import os import glob import json from PIL import Image import numpy as np import torch import torchvision from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask from .abstract import AbstractDataset from cityscapesscripts.helpers...
7,644
31.257384
85
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/coco.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch import torchvision from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask from maskrcnn_benchmark.structures.keypoint import PersonKeypoints min_ke...
3,783
35.038095
85
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/evaluation/coco/abs_to_coco.py
# COCO style evaluation for custom datasets derived from AbstractDataset # Warning! area is computed using binary maps, therefore results may differ # because of the precomputed COCO areas # by botcs@github import numpy as np import torch import pycocotools.mask as mask_util from maskrcnn_benchmark.data.datasets.abst...
6,795
33.150754
81
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/evaluation/cityscapes/eval_instances.py
#!/usr/bin/python # # The evaluation script for instance-level semantic labeling. # We use this script to evaluate your approach on the test set. # You can use the script to evaluate on the validation set. # # Please check the description of the "getPrediction" method below # and set the required environment variables ...
37,178
39.90099
126
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/evaluation/cityscapes/cityscapes_eval.py
import logging import tempfile import os import torch from collections import OrderedDict from tqdm import tqdm from copy import deepcopy import torch import numpy as np from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker from maskrcnn_benchmark.structures.bounding_box import BoxList from mas...
3,502
32.682692
81
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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,557
27.926829
78
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/maskrcnn_benchmark/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,716
38.376812
90
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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", ...
14,182
30.378319
85
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 @regist...
2,759
33.5
81
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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 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,939
38.4
86
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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,473
33.361111
101
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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,758
36.483092
87
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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...
10,890
33.795527
88
py
SA-AutoAug
SA-AutoAug-master/maskrcnn-benchmark/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...
6,055
36.153374
87
py