repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/miscellaneous.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
| 228 | 18.083333 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/env.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
... | 1,249 | 31.894737 | 90 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/utils/imports.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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_campaign=google_rich_qa
def import_file(module_name, fi... | 598 | 38.933333 | 164 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .build import make_data_loader
| 108 | 35.333333 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/collate_batch.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
"""
... | 673 | 31.095238 | 72 | 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/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .coco import COCODataset
from .concat_dataset import ConcatDataset,MixDataset
from .icdar import IcdarDataset
from .synthtext import SynthtextDataset
from .scut import ScutDataset
from .total_text import TotaltextDataset
__all__ = ["COCODatase... | 421 | 45.888889 | 122 | 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/datasets/list_dataset.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
from maskrcnn_benchmark.structures.bounding_box import BoxList
class ListDataset(object):
def __init__(self, image_lists, transforms=None):
self.imag... | 943 | 24.513514 | 71 | 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/samplers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .distributed import DistributedSampler
from .grouped_batch_sampler import GroupedBatchSampler
from .iteration_based_batch_sampler import IterationBasedBatchSampler
__all__ = ["DistributedSampler", "GroupedBatchSampler", "IterationBasedBatchSa... | 328 | 46 | 85 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/transforms/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .transforms import Compose
from .transforms import Resize
from .transforms import RandomHorizontalFlip
from .transforms import ToTensor
from .transforms import Normalize
from .build import build_transforms
| 285 | 27.6 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/data/transforms/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from . import transforms as T
def build_transforms(cfg, is_train=True):
to_bgr255 = cfg.INPUT.TO_BGR255
normalize_transform = T.Normalize(
mean=cfg.INPUT.PIXEL_MEAN, std=cfg.INPUT.PIXEL_STD, to_bgr255=to_bgr255
)
if is_tra... | 1,839 | 31.857143 | 79 | 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/__init__.py | 0 | 0 | 0 | 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/backbone/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .backbone import build_backbone
| 109 | 35.666667 | 71 | py |
MaskTextSpotter | MaskTextSpotter-master/maskrcnn_benchmark/modeling/detector/detectors.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... | 324 | 28.545455 | 74 | 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/detector/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .detectors import build_detection_model
| 117 | 38.333333 | 71 | 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/rpn/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# from .rpn import build_rpn
| 101 | 33 | 71 | 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/__init__.py | 0 | 0 | 0 | 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/__init__.py | 0 | 0 | 0 | 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/modeling/roi_heads/box_head/__init__.py | 0 | 0 | 0 | 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/maskrcnn_benchmark/structures/__init__.py | 0 | 0 | 0 | py | |
MaskTextSpotter | MaskTextSpotter-master/evaluation/icdar2015/e2e/rrc_evaluation_funcs.py | #!/usr/bin/env python2
#encoding: UTF-8
import json
import sys;sys.path.append('./')
import zipfile
import re
import sys
import os
import codecs
import importlib
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
def print_help():
sys.stdout.write('Usage: python %s.py -g=<gtFile... | 15,410 | 40.764228 | 359 | py |
MaskTextSpotter | MaskTextSpotter-master/evaluation/icdar2015/e2e/script.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# encoding=utf8
from collections import namedtuple
import rrc_evaluation_funcs
import importlib
from prepare_results import prepare_results_for_evaluation
def evaluation_imports():
"""
evaluation_imports: Dictionary ( key = module name , value = alias ) with pyth... | 19,886 | 42.803965 | 322 | py |
MaskTextSpotter | MaskTextSpotter-master/evaluation/icdar2015/e2e/weighted_editdistance.py | def weighted_edit_distance(word1, word2, scores):
m = len(word1)
n = len(word2)
dp = [[0 for __ in range(m + 1)] for __ in range(n + 1)]
for j in range(m + 1):
dp[0][j] = j
for i in range(n + 1):
dp[i][0] = i
for i in range(1, n + 1): ## word2
for j in range(1, m + 1): #... | 1,813 | 31.981818 | 107 | py |
MaskTextSpotter | MaskTextSpotter-master/evaluation/icdar2015/e2e/prepare_results.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
sys.path.append('./')
import shapely
from shapely.geometry import Polygon,MultiPoint
import numpy as np
import editdistance
from weighted_editdistance import weighted_edit_distance
from tqdm import tqdm
try:
import pickle
except ImportError:
im... | 10,653 | 39.664122 | 243 | 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_glue.py | import os
import logging
import sys
import csv
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import matthews_corrcoef, f1_score
logger = logging.getLogger()
class InputExample(object):
"""A single training/test example for simple sequence classification."""
def __init__(self, guid, text_a... | 21,128 | 33.18932 | 86 | 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/tokenization.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,859 | 36.868852 | 114 | 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/configuration.py | """ BERT model configuration """
from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import sys
import os
import copy
from io import open
logger = logging.getLogger(__name__)
#CONFIG_NAME = "config_bert_base.json"
CONFIG_NAME = "config.json"
class BertConfig... | 6,448 | 42.574324 | 128 | 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 |
ti-kd-qat | ti-kd-qat-main/transformer/__init__.py | from .tokenization import BertTokenizer, BasicTokenizer, WordpieceTokenizer
from .modeling import BertForSequenceClassification,BertModel, CONFIG_NAME, WEIGHTS_NAME
from .configuration import BertConfig
from .optimization import BertAdam
from .utils_quant import QuantizeLinear
from .modeling_quant import BertSelfAttent... | 459 | 50.111111 | 88 | py |
Quantum-Repeater-using-Quantum-Circuits | Quantum-Repeater-using-Quantum-Circuits-main/purification-5qubit-EDC.py | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 20:28:55 2019
Entanglement Purification - Repetition Code
5-qubit Error Detection Code
@author: User
"""
import math
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
pair1 = QuantumRegister(2, "pair1")
pair2 = ... | 2,387 | 17.80315 | 69 | py |
Quantum-Repeater-using-Quantum-Circuits | Quantum-Repeater-using-Quantum-Circuits-main/channel_length_sim.py | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 18 22:41:25 2019
@author: User
"""
#channel length
n = 1
import math
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
from qiskit.tools.qi import qi
ebit = QuantumRegister(2, "ebits")
channel = QuantumRegister(n, "chan... | 1,781 | 19.72093 | 97 | py |
Quantum-Repeater-using-Quantum-Circuits | Quantum-Repeater-using-Quantum-Circuits-main/deutsch_single-stage_3qubit.py | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 15 21:30:11 2019
Deutsch - Single Stage - 3 qubit
@author: User
"""
import math
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
pair1 = QuantumRegister(2, "pair1")
pair2 = QuantumRegister(2, "pair2")
pair3 = QuantumR... | 1,863 | 16.420561 | 69 | py |
gevent | gevent-master/_setuputils.py | # -*- coding: utf-8 -*-
"""
gevent build utilities.
"""
from __future__ import print_function, absolute_import, division
import re
import os
import os.path
import sys
import sysconfig
from distutils import sysconfig as dist_sysconfig
from subprocess import check_call
from glob import glob
from setuptools import Exte... | 18,816 | 34.30394 | 135 | py |
gevent | gevent-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""gevent build & installation script"""
from __future__ import print_function
import sys
import os
import os.path
# setuptools is *required* on Windows
# (https://bugs.python.org/issue23246) and for PyPy. No reason not to
# use it everywhere. v24.2.0 is needed for python... | 17,597 | 36.048421 | 97 | py |
gevent | gevent-master/_setuplibev.py | # -*- coding: utf-8 -*-
"""
setup helpers for libev.
Importing this module should have no side-effects; in particular,
it shouldn't attempt to cythonize anything.
"""
from __future__ import print_function, absolute_import, division
import os.path
from _setuputils import Extension
from _setuputils import system
fro... | 4,757 | 37.682927 | 89 | py |
gevent | gevent-master/_setupares.py | # -*- coding: utf-8 -*-
"""
setup helpers for c-ares.
"""
from __future__ import print_function, absolute_import, division
import os
import os.path
import shutil
import sys
from _setuputils import Extension
import distutils.sysconfig # to get CFLAGS to pass into c-ares configure script pylint:disable=import-error
... | 4,041 | 30.092308 | 108 | py |
gevent | gevent-master/benchmarks/bench_spawn.py | """
Benchmarking spawn() performance.
"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from pyperf import perf_counter
from pyperf import Runner
try:
xrange
except NameError:
xrange = range
N = 10000
counter = 0
def incr(**_kwargs):
globa... | 5,929 | 24.670996 | 84 | py |
gevent | gevent-master/benchmarks/bench_tracer.py | # -*- coding: utf-8 -*-
"""
Benchmarks for gevent.queue
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import contextlib
import perf
import greenlet
import gevent
from gevent import _tracer as monitor
N = 1000
@contextlib.contextmanager
def tracer(... | 2,310 | 18.099174 | 65 | py |
gevent | gevent-master/benchmarks/bench_threadpool.py | # -*- coding: utf-8 -*-
"""
Benchmarks for thread pool.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import perf
from gevent.threadpool import ThreadPool
try:
xrange = xrange
except NameError:
xrange = range
def noop():
"Does nothing"
... | 2,544 | 19.36 | 49 | py |
gevent | gevent-master/benchmarks/bench_queue.py | # -*- coding: utf-8 -*-
"""
Benchmarks for gevent.queue
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import perf
import gevent
from gevent import queue
N = 1000
def _b_no_block(q):
for i in range(N):
q.put(i)
for i in range(N):
... | 2,577 | 24.27451 | 63 | py |
gevent | gevent-master/benchmarks/bench_dns_resolver.py | from __future__ import absolute_import, print_function, division
# Best run with dnsmasq configured as a caching nameserver
# with no timeouts and configured to point there via
# /etc/resolv.conf and GEVENT_RESOLVER_NAMESERVERS
# Remember to use --inherit-environ to make that work!
# dnsmasq -d --cache-size=100000 --... | 3,281 | 29.110092 | 87 | py |
gevent | gevent-master/benchmarks/bench_socket.py | #! /usr/bin/env python
"""
Basic socket benchmarks.
"""
from __future__ import print_function, division, absolute_import
import os
import sys
import perf
import gevent
from gevent import socket as gsocket
import socket
import threading
def recvall(sock, _):
while sock.recv(4096):
pass
N = 10
MB = 102... | 3,784 | 23.262821 | 64 | py |
gevent | gevent-master/benchmarks/bench_sleep0.py | """
Benchmarking sleep(0) performance.
"""
from __future__ import print_function
import perf
try:
xrange
except NameError:
xrange = range
N = 100
def test(loops, sleep, arg):
t0 = perf.perf_counter()
for __ in range(loops):
for _ in xrange(N):
sleep(arg)
return perf.perf_c... | 1,034 | 20.122449 | 61 | py |
gevent | gevent-master/benchmarks/bench_sendall.py | #! /usr/bin/env python
from __future__ import print_function, division, absolute_import
import perf
from gevent import socket
from gevent.server import StreamServer
def recvall(sock, _):
while sock.recv(4096):
pass
N = 10
runs = []
def benchmark(conn, data):
spent_total = 0
for _ in range(N... | 1,123 | 19.436364 | 77 | py |
gevent | gevent-master/benchmarks/bench_local.py | # -*- coding: utf-8 -*-
"""
Benchmarks for thread locals.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import perf
from gevent.local import local as glocal
from threading import local as nlocal
class GLocalSub(glocal):
pass
class NativeSub(nlo... | 1,921 | 20.595506 | 53 | py |
gevent | gevent-master/benchmarks/bench_hub.py | # -*- coding: utf-8 -*-
"""
Benchmarks for hub primitive operations.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import perf
from perf import perf_counter
import gevent
from greenlet import greenlet
from greenlet import getcurrent
N = 1000
def b... | 2,544 | 20.386555 | 66 | py |
gevent | gevent-master/benchmarks/bench_get_memory.py | """
Benchmarking for getting the memoryview of an object.
https://github.com/gevent/gevent/issues/1318
"""
from __future__ import print_function
# pylint:disable=unidiomatic-typecheck
try:
xrange
except NameError:
xrange = range
try:
buffer
except NameError:
buffer = memoryview
import perf
from ge... | 2,732 | 25.794118 | 75 | py |
gevent | gevent-master/benchmarks/bench_subprocess.py | # -*- coding: utf-8 -*-
"""
Benchmarks for thread locals.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import perf
from gevent import subprocess as gsubprocess
import subprocess as nsubprocess
N = 10
def _bench_spawn(module, loops, close_fds=True)... | 1,580 | 26.258621 | 67 | py |
gevent | gevent-master/benchmarks/bench_pool.py | # -*- coding: utf-8 -*-
"""
Benchmarks for greenlet pool.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import gevent.pool
import bench_threadpool
bench_threadpool.ThreadPool = gevent.pool.Pool
if __name__ == '__main__':
bench_threadpool.main()
| 320 | 17.882353 | 46 | py |
gevent | gevent-master/examples/wsgiserver_ssl.py | #!/usr/bin/python
"""Secure WSGI server example based on gevent.pywsgi"""
from __future__ import print_function
from gevent import pywsgi
def hello_world(env, start_response):
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
return [b"<b>hello world</b>"]
... | 768 | 33.954545 | 105 | py |
gevent | gevent-master/examples/unixsocket_server.py | # gevent-test-requires-resource: unixsocket_client
import os
from gevent.pywsgi import WSGIServer
from gevent import socket
def application(environ, start_response):
assert environ
start_response('200 OK', [])
return []
if __name__ == '__main__':
listener = socket.socket(socket.AF_UNIX, socket.SOCK_... | 553 | 25.380952 | 64 | py |
gevent | gevent-master/examples/dns_mass_resolve.py | #!/usr/bin/python
# gevent-test-requires-resource: network
"""Resolve hostnames concurrently, exit after 2 seconds.
Under the hood, this might use an asynchronous resolver based on
c-ares (the default) or thread-pool-based resolver.
You can choose between resolvers using GEVENT_RESOLVER environment
variable. To enabl... | 1,052 | 24.682927 | 66 | py |
gevent | gevent-master/examples/webpy.py | #!/usr/bin/python
# gevent-test-requires-resource: webpy
"""A web.py application powered by gevent"""
from __future__ import print_function
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
import time
import web # pylint:disable=import-error
urls = ("/", "index",
'/long', 'lo... | 1,182 | 32.8 | 99 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.