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 |
|---|---|---|---|---|---|---|
stylegan3 | stylegan3-main/train.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 15,910 | 54.055363 | 210 | py |
stylegan3 | stylegan3-main/calc_metrics.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 8,114 | 41.936508 | 154 | py |
stylegan3 | stylegan3-main/training/loss.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 7,999 | 55.737589 | 199 | py |
stylegan3 | stylegan3-main/training/augment.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 26,617 | 59.910755 | 366 | py |
stylegan3 | stylegan3-main/training/dataset.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 8,642 | 35.16318 | 158 | py |
stylegan3 | stylegan3-main/training/training_loop.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 21,879 | 50.121495 | 168 | py |
stylegan3 | stylegan3-main/training/networks_stylegan2.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 40,302 | 49.695597 | 164 | py |
stylegan3 | stylegan3-main/training/networks_stylegan3.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 26,208 | 49.792636 | 141 | py |
stylegan3 | stylegan3-main/torch_utils/custom_ops.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 6,646 | 41.06962 | 146 | py |
stylegan3 | stylegan3-main/torch_utils/training_stats.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 10,720 | 38.855019 | 118 | py |
stylegan3 | stylegan3-main/torch_utils/persistence.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 9,752 | 37.702381 | 144 | py |
stylegan3 | stylegan3-main/torch_utils/misc.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 11,106 | 40.599251 | 133 | py |
stylegan3 | stylegan3-main/torch_utils/ops/bias_act.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 9,845 | 45.885714 | 185 | py |
stylegan3 | stylegan3-main/torch_utils/ops/grid_sample_gradfix.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 3,575 | 40.103448 | 132 | py |
stylegan3 | stylegan3-main/torch_utils/ops/conv2d_gradfix.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 9,745 | 46.77451 | 197 | py |
stylegan3 | stylegan3-main/torch_utils/ops/upfirdn2d.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 16,424 | 41.115385 | 120 | py |
stylegan3 | stylegan3-main/torch_utils/ops/filtered_lrelu.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 12,916 | 45.970909 | 164 | py |
stylegan3 | stylegan3-main/torch_utils/ops/conv2d_resample.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 6,765 | 45.986111 | 130 | py |
stylegan3 | stylegan3-main/torch_utils/ops/fma.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 2,047 | 32.57377 | 105 | py |
stylegan3 | stylegan3-main/viz/renderer.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 15,309 | 39.502646 | 164 | py |
stylegan3 | stylegan3-main/metrics/metric_utils.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 11,936 | 41.632143 | 167 | py |
stylegan3 | stylegan3-main/metrics/equivariance.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 10,868 | 39.55597 | 165 | py |
stylegan3 | stylegan3-main/metrics/perceptual_path_length.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 5,256 | 40.722222 | 131 | py |
stylegan3 | stylegan3-main/metrics/metric_main.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 5,675 | 35.857143 | 147 | py |
stylegan3 | stylegan3-main/metrics/precision_recall.py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 3,644 | 56.857143 | 159 | py |
MaskTextSpotter | MaskTextSpotter-master/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,055 | 28.371429 | 73 | py |
MaskTextSpotter | MaskTextSpotter-master/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... | 3,340 | 33.802083 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/tools/demo.py | import os
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_list import to_image_list
from maskrcnn_benchmark.config import... | 9,596 | 39.154812 | 123 | py |
MaskTextSpotter | MaskTextSpotter-master/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... | 5,444 | 30.293103 | 89 | py |
MaskTextSpotter | MaskTextSpotter-master/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,810 | 33.169811 | 80 | py |
MaskTextSpotter | MaskTextSpotter-master/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
... | 1,083 | 29.111111 | 79 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/config/paths_catalog.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Centralized catalog of paths."""
import os
def add_gt_path(data_dir, attrs):
if len(attrs)>1:
return os.path.join(data_dir,attrs[1])
else:
return None
class DatasetCatalog(object):
DATA_DIR = "datasets"
DATASE... | 8,907 | 36.745763 | 121 | py |
MaskTextSpotter | MaskTextSpotter-master/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__()... | 799 | 31 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/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
class _ROIPool(Function):
@staticmethod
... | 1,855 | 28 | 74 | py |
MaskTextSpotter | MaskTextSpotter-master/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
class _ROIAlign(Function):
@staticmethod... | 2,110 | 29.594203 | 85 | py |
MaskTextSpotter | MaskTextSpotter-master/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):
"""
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 |
MaskTextSpotter | MaskTextSpotter-master/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 |
MaskTextSpotter | MaskTextSpotter-master/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... | 3,241 | 30.475728 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/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 ConvTranspose2d
from .misc import interpolate
from .nms import nms
from .roi_align import ROIAlign
from .roi_align import roi_align
from .roi_pool im... | 557 | 33.875 | 148 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/engine/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import tempfile
import time
import os
from collections import OrderedDict
import torch
from tqdm import tqdm
from ..structures.bounding_box import BoxList
from ..utils.comm import is_main_process
from ..utils.comm ... | 14,699 | 33.265734 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/engine/text_inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import tempfile
import time
import os
from collections import OrderedDict
import torch
from tqdm import tqdm
from ..structures.bounding_box import BoxList
from ..utils.comm import is_main_process
from ..utils.comm ... | 15,120 | 36.992462 | 203 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/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 maskrcnn_benchmark.utils.comm import get_world_size, is_main_process
from maskrcnn_benchmark.utils.metric_logger import MetricLogger
def reduce_loss_di... | 4,044 | 32.991597 | 79 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/c2_model_loading.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import pickle
from collections import OrderedDict
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
def _rename_basic_resnet_weights(layer_keys):
layer_keys = [k.replace("_", ".") for k in ... | 5,667 | 38.636364 | 129 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/metric_logger.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import defaultdict
from collections import deque
import torch
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the global series average.
"""
def __... | 1,714 | 25.796875 | 82 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
from maskrcnn_benchmark.utils.imports import import_file
from mask... | 4,813 | 33.385714 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/comm.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains primitives for multi-gpu communication.
This is useful when doing distributed training.
"""
import os
import pickle
import tempfile
import time
import torch
import torch.distributed as dist
def get_world_size():
if no... | 4,514 | 29.714286 | 80 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.... | 3,045 | 48.129032 | 135 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/collect_env.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import PIL
from torch.utils.collect_env import get_pretty_env_info
def get_pil_version():
return "\n Pillow ({})".format(PIL.__version__)
def collect_env_info():
env_str = get_pretty_env_info()
env_str += get_pil_version()
... | 338 | 21.6 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
from maskrcnn_benchmark.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that w... | 3,464 | 41.777778 | 91 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import logging
import torch.utils.data
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.imports import import_file
from . import datasets as D
from . import samplers
from .collate_batch import ... | 6,569 | 37.647059 | 143 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/datasets/concat_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import numpy as np
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 th... | 1,508 | 25.946429 | 72 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/datasets/synthtext.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Simple dataset class that wraps a list of path names
"""
from PIL import Image,ImageDraw
import os
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask, Seg... | 8,241 | 44.038251 | 143 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/datasets/scut.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Simple dataset class that wraps a list of path names
"""
from PIL import Image, ImageDraw
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import os
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_b... | 8,112 | 44.324022 | 143 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/datasets/icdar.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Simple dataset class that wraps a list of path names
"""
from PIL import Image, ImageDraw
import os
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask, Se... | 8,290 | 44.80663 | 143 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/datasets/total_text.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Simple dataset class that wraps a list of path names
"""
from PIL import Image, ImageDraw
import os
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask, Se... | 7,448 | 44.145455 | 143 | py |
MaskTextSpotter | MaskTextSpotter-master/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
class COCODataset(torchvision.datasets.coco.CocoDetection):
def __ini... | 2,363 | 34.818182 | 89 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/samplers/grouped_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
class GroupedBatchSampler(BatchSampler):
"""
Wraps another sampler to yield a mini-batch of indices.
It enfo... | 4,844 | 41.130435 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/samplers/iteration_based_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... | 1,164 | 35.40625 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/samplers/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Code is copy-pasted exactly as in torch.utils.data.distributed,
# with a modification in the import to use the deprecated backend
# FIXME remove this once c10d fixes the bug it has
import math
import torch
# import torch.distributed.deprecated as... | 2,678 | 37.826087 | 86 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/transforms/transforms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import random
import numpy as np
import torch
import torchvision
from torchvision.transforms import functional as F
from shapely.geometry import box, Polygon
from shapely import affinity
from PIL import Image
import cv2
class Compose(object):
d... | 9,303 | 33.716418 | 200 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
ground-truth element may be assigned t... | 4,845 | 44.28972 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
"""
assert isinstance(tensors, (list, tuple))
if ... | 404 | 22.823529 | 97 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
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... | 4,171 | 32.645161 | 90 | py |
MaskTextSpotter | MaskTextSpotter-master/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,668 | 37.681159 | 90 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used for training the regressors.
"""
def __init__(self, weights, bbox_xform_clip=math.log(1... | 3,367 | 34.083333 | 86 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/backbone/resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 9,902 | 29.946875 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/backbone/backbone.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
from torch import nn
from . import fpn as fpn_module
from . import resnet
def build_resnet_backbone(cfg):
body = resnet.ResNet(cfg)
model = nn.Sequential(OrderedDict([("body", body)]))
return mode... | 1,310 | 28.133333 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/backbone/fpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
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,234 | 42.133333 | 86 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
import torch
from torch import nn
from maskrcnn_benchmark.structures.image_list import to_image_list
from ..backbone import build_backbone
from ..rpn.rpn import build_rpn
from ..roi_heads.roi_he... | 2,175 | 31.969697 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/rpn/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist
from maskrcnn_benchmark.structures.boxlist_ops... | 7,479 | 35.847291 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/rpn/anchor_generator.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
class BufferList(nn.Module):
"""
Similar to nn.ParameterList, but for buffers
"""
def __init__(self... | 8,907 | 32.742424 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/rpn/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains specific functions for computing losses on the RPN
file
"""
import torch
from torch.nn import functional as F
from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler
from ..utils import cat
from ma... | 6,100 | 39.138158 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/rpn/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from .loss import make_rpn_loss_evaluator
from .anchor_generator import make_anchor_generator
from .inference import make_... | 5,430 | 37.792857 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .box_head.box_head import build_roi_box_head
from .mask_head.mask_head import build_roi_mask_head
class CombinedROIHeads(torch.nn.ModuleDict):
"""
Combines a set of individual heads (for box prediction or masks) into a ... | 2,093 | 37.072727 | 93 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
from PIL import Image
from torch import nn
import cv2
from torch.nn import functional as F
from maskrcnn_benchmark.structures.bounding_box import BoxList
# TODO check if want to return a single BoxList or a composi... | 8,338 | 33.17623 | 205 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_benchmark.layers import Conv2d
clas... | 2,740 | 36.040541 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmar... | 7,330 | 37.584211 | 117 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_seq_predictors.py | # Written by Minghui Liao
import torch
from torch import nn
from torch.nn import functional as F
import math
import random
import numpy as np
from maskrcnn_benchmark.utils.chars import char2num, num2char
gpu_device = torch.device("cuda")
cpu_device = torch.device("cpu")
def reduce_mul(l):
out = 1.0
for x in l... | 14,496 | 51.33574 | 172 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.layers import ConvTranspose2d
from .roi_seq_predictors import make_roi_seq_predictor
class MaskRCNNC4Predictor(nn.Modul... | 5,358 | 43.658333 | 176 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from .roi_mask_feature_extractors import make_roi_mask_feature_extractor
from .roi_mask_predictors import make_roi_mask_predictor
from .inference imp... | 11,105 | 49.027027 | 329 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,029 | 38.411765 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_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 maskrcnn_benchmark.modeling.backbone import resnet
from maskrcnn_benchmark.modeling.poolers import Pooler
class ResNet50Conv5ROIFeatureExtractor(nn.Module):
def __init__(self, co... | 2,997 | 32.685393 | 80 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from .roi_box_feature_extractors import make_roi_box_feature_extractor
from .roi_box_predictors import make_roi_box_predictor
from .inference import make_roi_box_post_processor
from .loss import make_roi_box_loss_... | 2,663 | 36.521127 | 96 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.struc... | 6,664 | 36.869318 | 90 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.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... | 2,066 | 31.809524 | 72 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/structures/image_list.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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 a field the original sizes of ea... | 2,385 | 33.57971 | 87 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/structures/segmentation_mask.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import pycocotools.mask as mask_utils
import numpy as np
import cv2
from PIL import Image
from maskrcnn_benchmark.utils.chars import num2char, char2num
from shapely.geometry import Polygon
from shapely import affinity
# transpose
FLIP... | 24,511 | 39.785358 | 163 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/structures/bounding_box.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from shapely.geometry import box
from shapely import affinity
import numpy as np
# transpose
FLIP_LEFT_RIGHT = 0
FLIP_TOP_BOTTOM = 1
class BoxList(object):
"""
This class represents a set of bounding boxes.
The bounding b... | 11,086 | 36.456081 | 96 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/structures/boxlist_ops.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .bounding_box import BoxList
from maskrcnn_benchmark.layers import nms as _box_nms
def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="score"):
"""
Performs non-maximum suppression on a boxlist, with sc... | 3,635 | 27.186047 | 97 | py |
MaskTextSpotter | MaskTextSpotter-master/tests/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import os
from tempfile import TemporaryDirectory
import unittest
import torch
from torch import nn
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.checkpo... | 4,645 | 38.042017 | 88 | py |
MaskTextSpotter | MaskTextSpotter-master/tests/test_data_samplers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import random
import unittest
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
from torch.utils.data.sampler import SequentialSampler
from torch.utils.data.sampler import RandomSampler... | 5,532 | 34.928571 | 88 | py |
ti-kd-qat | ti-kd-qat-main/main.py |
# This code is implemented base on "TernaryBERT: Distillation-aware Ultra-low Bit BERT" (Zhang et al, EMNLP2020)
# https://arxiv.org/abs/2009.12812
from __future__ import absolute_import, division, print_function
import argparse
import logging
import os
import random
import sys
import pickle
import copy
import colle... | 44,506 | 43.11001 | 218 | py |
ti-kd-qat | ti-kd-qat-main/utils.py | #*
# @file Different utility functions
# Copyright (c) Zhewei Yao, Amir Gholami
# All rights reserved.
# This file is part of PyHessian library.
#
# PyHessian is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, ei... | 2,610 | 25.642857 | 70 | py |
ti-kd-qat | ti-kd-qat-main/transformer/utils_quant.py | import torch
import torch.nn as nn
import sys
import logging
from transformers import SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST
log_format = '%(asctime)s %(message)s'
logging.basicConfig(stream=sys.stdout, level=logging.INFO,
format=log_format, datefmt='%m/%d %I:%M:%S %p')
logger = logging.getLogg... | 8,642 | 37.932432 | 123 | py |
ti-kd-qat | ti-kd-qat-main/transformer/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# 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/LICEN... | 13,044 | 42.33887 | 139 | py |
ti-kd-qat | ti-kd-qat-main/transformer/modeling_quant.py | # coding=utf-8
# 2020.04.20 - Add&replace quantization modules
# Huawei Technologies Co., Ltd <zhangwei379@huawei.com>
# Copyright (c) 2020, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA C... | 21,718 | 43.966874 | 172 | py |
ti-kd-qat | ti-kd-qat-main/transformer/modeling.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# 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 cop... | 16,313 | 40.093199 | 145 | py |
ti-kd-qat | ti-kd-qat-main/transformer/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
from __future__ import (absolute_import, division, print_function, unicode_literals)
import json
import logging
import os
import shutil
im... | 9,106 | 32.72963 | 112 | py |
gevent | gevent-master/src/gevent/testing/patched_tests_setup.py | # pylint:disable=missing-docstring,invalid-name,too-many-lines
from __future__ import print_function, absolute_import, division
import collections
import contextlib
import functools
import sys
import os
# At least on 3.6+, importing platform
# imports subprocess, which imports selectors. That
# can expose issues with ... | 57,621 | 41.873512 | 123 | py |
gevent | gevent-master/src/gevent/libuv/_corecffi_build.py | # pylint: disable=no-member
# This module is only used to create and compile the gevent.libuv._corecffi module;
# nothing should be directly imported from it except `ffi`, which should only be
# used for `ffi.compile()`; programs should import gevent._corecfffi.
# However, because we are using "out-of-line" mode, it i... | 12,349 | 34.693642 | 110 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.