python_code stringlengths 0 679k | repo_name stringlengths 9 41 | file_path stringlengths 6 149 |
|---|---|---|
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
#--------------------------------... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/models/transformer.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import torch.nn as nn
class Fair... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/models/fairseq_incremental_decoder.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import torch
import torch.nn as nn... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/modules/beamable_mm.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
#--------------------------------... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/modules/multihead_attention.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import torch.nn as nn
from fairse... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/modules/learned_positional_embedding.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
from .beamable_mm import BeamableM... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/modules/__init__.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import math
from typing import Opt... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/modules/sinusoidal_positional_embedding.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
#--------------------------------... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/data/__init__.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
#--------------------------------... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/data/data_utils.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
#--------------------------------... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/data/language_pair_dataset.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import os
import struct
import nu... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/data/indexed_dataset.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
from collections import Counter
im... | DeepLearningExamples-master | PyTorch/Translation/Transformer/fairseq/data/dictionary.py |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
"""
Use this script in order to ... | DeepLearningExamples-master | PyTorch/Translation/Transformer/scripts/build_sym_alignment.py |
DeepLearningExamples-master | PyTorch/Translation/Transformer/scripts/__init__.py | |
#!/usr/bin/env python3
import argparse
import collections
import torch
import os
import re
def average_checkpoints(inputs):
"""Loads checkpoints from inputs and returns a model with averaged weights.
Args:
inputs: An iterable of string paths of checkpoints to load from.
Returns:
A dict of s... | DeepLearningExamples-master | PyTorch/Translation/Transformer/scripts/average_checkpoints.py |
import json
import argparse
from collections import defaultdict, OrderedDict
import matplotlib.pyplot as plt
import numpy as np
def smooth_moving_average(x, n):
fil = np.ones(n)/n
smoothed = np.convolve(x, fil, mode='valid')
smoothed = np.concatenate((x[:n-1], smoothed), axis=0)
return smoothed
d... | DeepLearningExamples-master | PyTorch/Translation/Transformer/scripts/draw_summary.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/setup.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import cv2
import torch
from torchvision import transforms as T
from maskrcnn_benchmark.modeling.detector import build_detection_model
from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
from maskrcnn_benchmark.structures.image_l... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/demo/predictor.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(
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/demo/webcam.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tools/test_net.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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_be... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tools/train_net.py |
#!/usr/bin/python
#
# Convert instances from png files to a dictionary
# This files is created according to https://github.com/facebookresearch/Detectron/issues/111
from __future__ import print_function, absolute_import, division
import os, sys
sys.path.append( os.path.normpath( os.path.join( os.path.dirname( __file_... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tools/cityscapes/instances2dict_with_polygons.py |
#!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tools/cityscapes/convert_cityscapes_to_coco.py |
import os
from IPython.lib import passwd
#c = c # pylint:disable=undefined-variable
c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = int(os.getenv('PORT', 8888))
c.NotebookApp.open_browser = False
# sets a password if PASSWORD is set in the environment
if 'PASSWORD' in os.environ:
password = os.e... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/docker/docker-jupyter/jupyter_notebook_config.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
from maskrcnn_benchmark.utils.metric_logger import MetricLogger
class TestMetricLogger(unittest.TestCase):
def test_update(self):
meter = MetricLogger()
for i in range(10):
meter.update(metric=floa... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tests/test_metric_logger.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tests/checkpoint.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/tests/test_data_samplers.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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://githu... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/misc.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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_ben... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/roi_align.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# from ._utils import _C
from maskrcnn_benchmark import _C
from torch.cuda.amp import custom_fwd
# Only valid with fp32 inputs - give AMP the hint
nms = custom_fwd(_C.nms)
# nms.__do... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/nms.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import ConvTranspose2d
from .misc import interpolate
from .misc import nhwc_to_nchw_transform... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/__init__.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
class _ROIPool(Function):
@staticmethod
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/roi_pool.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__()... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/batch_norm.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/_utils.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/layers/smooth_l1_loss.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import torch
import pycocotools.mask as mask_utils
# transpose
FLIP_LEFT_RIGHT = 0
FLIP_TOP_BOTTOM = 1
class Mask(object):
"""
This class is unfinished and not meant for use... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/structures/segmentation_mask.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 import _C
def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="score"):
"""
Performs non-maximum... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/structures/boxlist_ops.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/structures/__init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 represen... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/structures/bounding_box.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 w... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/structures/image_list.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
"""Centralized catalog of paths."""
import os
class DatasetCatalog(object):
DATA_DIR = "/data/coco/coco-2014"
DATASETS = {
"coco_2014_train": {
"img_dir":... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/config/paths_catalog_dlfw_ci.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
"""Centralized catalog of paths."""
import os
class DatasetCatalog(object):
DATA_DIR = "/data2/coco/coco-2017"
DATASETS = {
"coco_2017_train": {
"img_dir"... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/config/paths_catalog_ci.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .defaults import _C as cfg
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/config/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Centralized catalog of paths."""
import os
class DatasetCatalog(object):
DATA_DIR = "/datasets"
DATASETS = {
"coco_2017_train": {
"img_dir": "data/train2017",
"ann_file": "data/annotations/instances_tra... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/config/paths_catalog.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import os
from yacs.config import CfgNode as CN
# -----------------------------------------------------------------------------
# Convention about Training / Test specific parameters... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/config/defaults.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 __... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/metric_logger.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
from maskrcnn_benchmark.utils.imports import import_file
def setup_environment():
"""Perform environment setup work. The default setup is a no-op, but this
function allows the user to specify a Python source file that performs
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/env.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/checkpoint.py |
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
"""
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():
retu... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/comm.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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.re... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/c2_model_loading.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
def _register_generic(module_dict, module_name, module):
assert module_name not in module_dict
module_dict[module_name] = module
class Registry(dict):
'''
A helper class for managing registering modules, it extends a dictionary
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/registry.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 ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/model_zoo.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()
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/collect_env.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/__init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import sys
def setup_logger(name, save_dir, distributed_rank):
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
# don't log results for the non-master process
if distributed_rank > 0:
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/logger.py |
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
"""
Module for cv2 utility functions and maintaining version compatibility
between 3.x and 4.x
"""
import cv2
def findContours(*args, **kwargs):
"""
Wraps cv2.findContours to maintain compatiblity between versions
3 and 4
Returns:
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/cv2_util.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import torch
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_sour... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/imports.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that we will create will have prefixes appended
to each of it... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/model_serialization.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import errno
import os
def mkdir(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/miscellaneous.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import torch
from apex.optimizers import FusedSGD
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
params = []
for key, value in model.named_parame... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/solver/build.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/solver/lr_scheduler.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .build import make_optimizer
from .build import make_lr_scheduler
from .lr_scheduler import WarmupMultiStepLR
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/solver/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 w... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/poolers.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
import torch
from maskrcnn_benchmark import _C
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicte... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/matcher.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark.utils.registry import Registry
BACKBONES = Registry()
ROI_BOX_FEATURE_EXTRACTORS = Registry()
RPN_HEADS = Registry()
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/registry.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
import math
from maskrcnn_benchmark import _C
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/box_coder.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/__init__.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 ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/utils.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/make_layers.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
import torch
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init_... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 .loss... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/rpn/rpn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# from .rpn import build_rpn
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/rpn/__init__.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 ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler
from ..utils import cat
from ma... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/rpn/loss.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 n... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/rpn/anchor_generator.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 im... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/rpn/inference.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2018, NVIDIA CORPORATION. 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_b... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .detectors import build_detection_model
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/detector/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .generalized_rcnn import GeneralizedRCNN
_DETECTION_META_ARCHITECTURES = {"GeneralizedRCNN": GeneralizedRCNN}
def build_detection_model(cfg):
meta_arch = _DETECTION_META_ARCHITECTURES[cfg.MODEL.META_ARCHITECTURE]
return meta_arch(c... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/detector/detectors.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/__init__.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
class CombinedROIHeads(torch.nn.ModuleDict):
"""
Combines a set of individual heads (for box prediction or masks) into a ... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/roi_heads.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_... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/__init__.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
class FastRCNNPredictor(nn.Module):
def __init__(self, config, pretrained=None):
super(FastRCNNPredictor, self).__init__()
stage_index = 4
stage2_relative_factor = 2 ** (stage_index - 1)
r... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 mas... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/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 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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.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.poolers import Pooler
from maskrcnn_benchmark.modeling.make_layers import... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_feature_extractors.py |
DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/__init__.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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from maskrcnn_benchmark.structures.bounding_box import BoxList
# TODO check if want to return a single BoxList or a composite
# object
class MaskPostProcessor(n... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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
class MaskRCNNC4Predictor... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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 cur... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/backbone/fpn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/backbone/backbone.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .backbone import build_backbone
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/backbone/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2022, NVIDIA CORPORATION. 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",
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/modeling/backbone/resnet.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved..
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
import bisect
import copy
import logging
import torch.utils.data
from maskrcnn_benchmark.data.datasets.coco import HybridDataLoader
from maskrcnn_benchmark.utils.comm import get_world... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/data/build.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .build import make_data_loader
| DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/data/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark.structures.image_list import to_image_list
class BatchCollator(object):
"""
From a list of samples from the dataset,
returns the batched images and targets.
This should be passed to the DataLoader
"""
... | DeepLearningExamples-master | PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/data/collate_batch.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.