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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/data/datasets/tdtr.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Simple dataset class that wraps a list of path names """ import os import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import ( CharPolygons, ...
11,925
39.020134
120
py
MaskTextSpotterV3
MaskTextSpotterV3-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,498
26.254545
72
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/data/datasets/utils.py
#!/usr/bin/env python3 import os import shlex import shutil import subprocess def extract_archive(dataset_archive, tmp_data_path): if not os.path.isfile(dataset_archive): return False dataset_ext = os.path.splitext(dataset_archive)[1] if dataset_ext != ".gz" and dataset_ext != ".tar": re...
926
22.769231
85
py
MaskTextSpotterV3
MaskTextSpotterV3-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 """ import os import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import ( SegmentationCh...
9,096
38.042918
116
py
MaskTextSpotterV3
MaskTextSpotterV3-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 """ import os import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import ( CharPolygons, ...
13,327
39.510638
116
py
MaskTextSpotterV3
MaskTextSpotterV3-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 """ import os import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import ( SegmentationCh...
11,125
39.458182
120
py
MaskTextSpotterV3
MaskTextSpotterV3-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 """ import os import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import ( CharPolygons, ...
12,866
39.589905
120
py
MaskTextSpotterV3
MaskTextSpotterV3-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 .scut import ScutDataset from .synthtext import SynthtextDataset from .total_text import TotaltextDataset __all__ = [ "COC...
459
24.555556
71
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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 as dist from to...
2,777
38.126761
86
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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...
2,636
36.140845
125
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/data/transforms/transforms.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import random import cv2 import numpy as np from PIL import Image from shapely import affinity from shapely.geometry import Polygon from torchvision.transforms import functional as F class Compose(object): def __init__(self, transforms): ...
12,621
32.480106
83
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/registry.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from maskrcnn_benchmark.utils.registry import Registry BACKBONES = Registry() RPN_HEADS = Registry() ROI_BOX_FEATURE_EXTRACTORS = Registry() ROI_BOX_PREDICTOR = Registry() ROI_KEYPOINT_FEATURE_EXTRACTORS = Registry() ROI_KEYPOINT_PREDICTOR = Regi...
400
29.846154
71
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/make_layers.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Miscellaneous utility functions """ import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.layers import Conv2d from maskrcnn_benchmark.modeling.poolers import P...
3,557
27.926829
78
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch # TODO 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,678
37.271429
83
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/__init__.py
0
0
0
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/box_coder.py
#!/usr/bin/env python3 # 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, bbo...
3,462
33.979798
86
py
MaskTextSpotterV3
MaskTextSpotterV3-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", # "ResNe...
24,619
30.808786
90
py
MaskTextSpotterV3
MaskTextSpotterV3-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)]))...
4,395
32.30303
89
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/backbone/resnet34.py
import torch import torch.nn.functional as F from torch import nn import math from maskrcnn_benchmark.layers import FrozenBatchNorm2d from maskrcnn_benchmark.layers import Conv2d def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding""" return Conv2d(in_planes, out_planes, kernel_size=3, stri...
2,729
26.857143
67
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/backbone/fpn.py
# #!/usr/bin/env python3 # # 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 ...
7,331
40.659091
88
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/detector/detectors.py
#!/usr/bin/env python3 # 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]...
347
28
74
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py
#!/usr/bin/env python3 # 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 ...
3,837
35.903846
101
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/segmentation/inference.py
#!/usr/bin/env python3 import numpy as np import torch import cv2 import pyclipper from shapely.geometry import Polygon from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist, cat_boxlist_gt from maskrcnn_benchmark.structures.boxlist_ops import ...
15,089
38.815303
148
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/segmentation/loss.py
#!/usr/bin/env python3 """ This file contains specific functions for computing losses on the SEG file """ import torch class SEGLossComputation(object): """ This class computes the SEG loss. """ def __init__(self, cfg): self.eps = 1e-6 self.cfg = cfg def __call__(self, preds, ta...
2,122
31.661538
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/segmentation/segmentation.py
#!/usr/bin/env python3 import torch from torch import nn from .inference import make_seg_postprocessor from .loss import make_seg_loss_evaluator import time def conv3x3(in_planes, out_planes, stride=1, has_bias=False): "3x3 convolution with padding" return nn.Conv2d( in_planes, out_planes, kernel_siz...
6,573
34.923497
110
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/rpn/inference.py
#!/usr/bin/env python3 # 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...
7,490
35.720588
87
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/rpn/loss.py
#!/usr/bin/env python3 # 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 ..ut...
6,123
39.026144
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/rpn/rpn.py
#!/usr/bin/env python3 # 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 ...
5,453
37.680851
88
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py
#!/usr/bin/env python3 # 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 predi...
2,237
36.932203
86
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/__init__.py
0
0
0
py
MaskTextSpotterV3
MaskTextSpotterV3-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,971
34.184314
209
py
MaskTextSpotterV3
MaskTextSpotterV3-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,762
36.849315
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch # from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.utils import cat from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from to...
8,431
34.428571
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_seq_predictors.py
# Written by Minghui Liao import math import random import numpy as np import torch from maskrcnn_benchmark.utils.chars import char2num, num2char from torch import nn from torch.nn import functional as F gpu_device = torch.device("cuda") cpu_device = torch.device("cpu") def reduce_mul(l): out = 1.0 for x i...
16,629
42.534031
134
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from maskrcnn_benchmark.layers import Conv2d, ConvTranspose2d from torch import nn from torch.nn import functional as F from .roi_seq_predictors import make_roi_seq_predictor class MaskRCNNC4Predictor(nn.Module): def __init__(self, cfg): ...
11,124
40.356877
122
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/__init__.py
0
0
0
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from torch import nn from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.utils import cat from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmar...
27,041
44.679054
160
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py
#!/usr/bin/env python3 # 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.struc...
7,693
42.468927
148
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_feature_extractors.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.modeling.backbone import resnet from maskrcnn_benchmark.modeling.poolers import Pooler from maskrcnn_benchmark.modeling.utils imp...
6,713
38.263158
145
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from .inference import make_roi_box_post_processor from .loss import make_roi_box_loss_evaluator from .roi_box_feature_extractors import make_roi_box_feature_extractor from .roi_box_predictors import make_roi_bo...
3,104
35.529412
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import ( BalancedPositiveNegativeSampler, ) from maskrcnn_benchmark.modeling.box_coder ...
7,135
37.572973
91
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.py
#!/usr/bin/env python3 # 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 ** (sta...
2,501
33.273973
76
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/modeling/roi_heads/box_head/__init__.py
0
0
0
py
MaskTextSpotterV3
MaskTextSpotterV3-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...
4,459
35.859504
87
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/structures/segmentation_mask.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import cv2 import numpy as np import pycocotools.mask as mask_utils import torch from maskrcnn_benchmark.utils.chars import char2num import pyclipper # from PIL import Image from shapely import affinity from shapely.geometry ...
27,175
34.431551
161
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/structures/bounding_box.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import numpy as np import torch # from shapely import affinity # from shapely.geometry import box # transpose FLIP_LEFT_RIGHT = 0 FLIP_TOP_BOTTOM = 1 class BoxList(object): """ This class represents a set of bounding boxes. The boun...
11,570
35.617089
88
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/structures/boxlist_ops.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch from maskrcnn_benchmark.layers import nms as _box_nms from .bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask import numpy as np import shapely from shapely...
7,393
30.46383
90
py
MaskTextSpotterV3
MaskTextSpotterV3-master/maskrcnn_benchmark/structures/__init__.py
0
0
0
py
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/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
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/rotated_icdar2013/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
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/rotated_icdar2013/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...
20,045
42.578261
322
py
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/rotated_icdar2013/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 sys.path.append('../../') from weighted_editdistance import weighted_edit_distance from tqdm import tqdm try: import pickle ...
10,790
39.41573
239
py
MaskTextSpotterV3
MaskTextSpotterV3-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
MaskTextSpotterV3
MaskTextSpotterV3-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...
20,101
42.605206
322
py
MaskTextSpotterV3
MaskTextSpotterV3-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 sys.path.append('../../') from weighted_editdistance import weighted_edit_distance from tqdm import tqdm try: import pickle ...
10,659
39.532319
243
py
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/totaltext/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
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/totaltext/e2e/script.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # encoding=utf8 from collections import namedtuple import rrc_evaluation_funcs_total_text as rrc_evaluation_funcs import importlib from prepare_results import prepare_results_for_evaluation def evaluation_imports(): """ evaluation_imports: Dictionary ( key = module...
19,780
42.763274
322
py
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/totaltext/e2e/prepare_results.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import os import glob sys.path.append('./') import shapely from shapely.geometry import Polygon,MultiPoint import numpy as np import editdistance sys.path.append('../../') from weighted_editdistance import weighted_edit_distance from tqdm import tqdm try: im...
9,314
38.807692
243
py
MaskTextSpotterV3
MaskTextSpotterV3-master/evaluation/totaltext/e2e/rrc_evaluation_funcs_total_text.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 from io import StringIO def print_help(): sys.stdout.write('Usage: python %s.py -g=<gtFile> -s=<submFile> -o=<outputFolder> [-i=<gtImagesFile> -p=<jsonPa...
15,482
41.652893
359
py
HASOC-2021---Hate-Speech-Detection
HASOC-2021---Hate-Speech-Detection-main/main.py
import getopt import sys import tensorflow as tf import os import json import numpy as np import file_utils from datetime import datetime import matplotlib.pyplot as plt import h5py from bert.tokenization.bert_tokenization import FullTokenizer from bert import BertModelLayer from bert.loader import StockBertConfig, map...
7,085
37.934066
179
py
HASOC-2021---Hate-Speech-Detection
HASOC-2021---Hate-Speech-Detection-main/data_loader.py
import pandas as pd import numpy as np from bert.tokenization.bert_tokenization import FullTokenizer from ekphrasis.classes.preprocessor import TextPreProcessor from ekphrasis.classes.tokenizer import SocialTokenizer from ekphrasis.dicts.emoticons import emoticons from tensorflow.keras.preprocessing.text import Tokeniz...
10,369
31.507837
144
py
HASOC-2021---Hate-Speech-Detection
HASOC-2021---Hate-Speech-Detection-main/file_utils.py
import os import json def save_list_to_file(input_list: list, file_path): file = open(file_path, 'w') file.write("\n".join(str(item) for item in input_list)) file.close() def save_string_to_file(text, file_path): file = open(file_path, 'w') file.write(text) file.close() def read_file_to_set(f...
1,070
23.906977
59
py
HASOC-2021---Hate-Speech-Detection
HASOC-2021---Hate-Speech-Detection-main/models.py
import tensorflow as tf import numpy as np from bert import BertModelLayer from bert.loader import StockBertConfig, map_stock_config_to_params, load_stock_weights from tensorflow import keras from tensorflow.keras import layers class MultiHeadSelfAttention(layers.Layer): def __init__(self, embed_dim, num_heads=8):...
17,504
41.799511
166
py
steer
steer-master/ffjord/train_vae_flow.py
# !/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import argparse import time import torch import torch.utils.data import torch.optim as optim import numpy as np import math import random import os import datetime import lib.utils as utils import lib.layers.odefunc as odefunc imp...
14,613
39.707521
124
py
steer
steer-master/ffjord/train_toy.py
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import argparse import os import time import torch import torch.optim as optim import lib.toy_data as toy_data import lib.utils as utils from lib.visualize_flow import visualize_transform import lib.layers.odefunc as odefunc from train_misc imp...
9,288
39.038793
119
py
steer
steer-master/ffjord/train_img2d.py
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import argparse import os import time import torch import torch.optim as optim import lib.utils as utils from lib.visualize_flow import visualize_transform import lib.layers.odefunc as odefunc from train_misc import standard_normal_logprob from...
9,789
37.543307
119
py
steer
steer-master/ffjord/train_cnf.py
import argparse import os import time import numpy as np import torch import torch.optim as optim import torchvision.datasets as dset import torchvision.transforms as tforms from torchvision.utils import save_image import lib.layers as layers import lib.utils as utils import lib.odenvp as odenvp import lib.multiscale...
18,212
39.654018
119
py
steer
steer-master/ffjord/train_discrete_tabular.py
import argparse import os import time import torch import lib.utils as utils from lib.custom_optimizers import Adam import lib.layers as layers import datasets from train_misc import standard_normal_logprob, count_parameters parser = argparse.ArgumentParser() parser.add_argument( '--data', choices=['power', 'g...
8,301
34.177966
120
py
steer
steer-master/ffjord/train_tabular.py
import argparse import os import time import torch import lib.utils as utils import lib.layers.odefunc as odefunc from lib.custom_optimizers import Adam import datasets from train_misc import standard_normal_logprob from train_misc import set_cnf_options, count_nfe, count_parameters, count_total_time from train_mis...
12,249
38.90228
120
py
steer
steer-master/ffjord/train_discrete_toy.py
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import argparse import os import time import torch import torch.optim as optim import lib.layers as layers import lib.toy_data as toy_data import lib.utils as utils from lib.visualize_flow import visualize_transform from train_misc import stand...
6,334
32.877005
119
py
steer
steer-master/ffjord/train_misc.py
import six import math import lib.layers.wrappers.cnf_regularization as reg_lib import lib.spectral_norm as spectral_norm import lib.layers as layers from lib.layers.odefunc import divergence_bf, divergence_approx def standard_normal_logprob(z): logZ = -0.5 * math.log(2 * math.pi) return logZ - z.pow(2) / 2 ...
6,311
30.402985
117
py
steer
steer-master/ffjord/vae_lib/models/VAE.py
from __future__ import print_function import torch import torch.nn as nn import vae_lib.models.flows as flows from vae_lib.models.layers import GatedConv2d, GatedConvTranspose2d class VAE(nn.Module): """ The base VAE class containing gated convolutional encoder and decoder architecture. Can be used as a ...
25,211
33.255435
120
py
steer
steer-master/ffjord/vae_lib/models/CNFVAE.py
import torch import torch.nn as nn from train_misc import build_model_tabular import lib.layers as layers from .VAE import VAE import lib.layers.diffeq_layers as diffeq_layers from lib.layers.odefunc import NONLINEARITIES from torchdiffeq import odeint_adjoint as odeint def get_hidden_dims(args): return tuple(ma...
14,405
33.881356
116
py
steer
steer-master/ffjord/vae_lib/models/layers.py
import torch import torch.nn as nn from torch.nn.parameter import Parameter import numpy as np import torch.nn.functional as F class Identity(nn.Module): def __init__(self): super(Identity, self).__init__() def forward(self, x): return x class GatedConv2d(nn.Module): def __init__(self...
7,128
32.947619
115
py
steer
steer-master/ffjord/vae_lib/models/__init__.py
0
0
0
py
steer
steer-master/ffjord/vae_lib/models/flows.py
""" Collection of flow strategies """ from __future__ import print_function import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F from vae_lib.models.layers import MaskedConv2d, MaskedLinear class Planar(nn.Module): """ PyTorch implementation of planar flows...
9,939
32.133333
118
py
steer
steer-master/ffjord/vae_lib/optimization/loss.py
from __future__ import print_function import numpy as np import torch import torch.nn as nn from vae_lib.utils.distributions import log_normal_diag, log_normal_standard, log_bernoulli import torch.nn.functional as F def binary_loss_function(recon_x, x, z_mu, z_var, z_0, z_k, ldj, beta=1.): """ Computes the b...
10,566
37.849265
116
py
steer
steer-master/ffjord/vae_lib/optimization/training.py
from __future__ import print_function import time import torch from vae_lib.optimization.loss import calculate_loss from vae_lib.utils.visual_evaluation import plot_reconstructions from vae_lib.utils.log_likelihood import calculate_likelihood import numpy as np from train_misc import count_nfe, override_divergence_fn...
5,518
31.087209
120
py
steer
steer-master/ffjord/vae_lib/optimization/__init__.py
0
0
0
py
steer
steer-master/ffjord/vae_lib/utils/distributions.py
from __future__ import print_function import torch import torch.utils.data import math MIN_EPSILON = 1e-5 MAX_EPSILON = 1. - 1e-5 PI = torch.FloatTensor([math.pi]) if torch.cuda.is_available(): PI = PI.cuda() # N(x | mu, var) = 1/sqrt{2pi var} exp[-1/(2 var) (x-mean)(x-mean)] # log N(x| mu, var) = -log sqrt(2pi...
1,768
25.80303
86
py
steer
steer-master/ffjord/vae_lib/utils/plotting.py
from __future__ import division from __future__ import print_function import numpy as np import matplotlib # noninteractive background matplotlib.use('Agg') import matplotlib.pyplot as plt def plot_training_curve(train_loss, validation_loss, fname='training_curve.pdf', labels=None): """ Plots train_loss and ...
4,021
37.304762
106
py
steer
steer-master/ffjord/vae_lib/utils/log_likelihood.py
from __future__ import print_function import time import numpy as np from scipy.misc import logsumexp from vae_lib.optimization.loss import calculate_loss_array def calculate_likelihood(X, model, args, logger, S=5000, MB=500): # set auxiliary variables for number of training and test sets N_test = X.size(0) ...
1,592
25.114754
110
py
steer
steer-master/ffjord/vae_lib/utils/load_data.py
from __future__ import print_function import torch import torch.utils.data as data_utils import pickle from scipy.io import loadmat import numpy as np import os def load_static_mnist(args, **kwargs): """ Dataloading function for static mnist. Outputs image data in vectorized form: each image is a vector of...
7,592
35.859223
116
py
steer
steer-master/ffjord/vae_lib/utils/__init__.py
0
0
0
py
steer
steer-master/ffjord/vae_lib/utils/visual_evaluation.py
from __future__ import print_function import os import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec def plot_reconstructions(data, recon_mean, loss, loss_type, epoch, args): if args.input_type == 'multinomial': # data is already between 0 and 1 ...
2,063
37.222222
119
py
steer
steer-master/ffjord/datasets/power.py
import numpy as np import datasets class POWER: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): trn, val, tst = load_data_normalised() self.trn = self.Data(trn) self.val = self.Da...
1,940
24.88
108
py
steer
steer-master/ffjord/datasets/hepmass.py
import pandas as pd import numpy as np from collections import Counter from os.path import join import datasets class HEPMASS: """ The HEPMASS data set. http://archive.ics.uci.edu/ml/datasets/HEPMASS """ class Data: def __init__(self, data): self.x = data.astype(np.float32)...
2,730
28.365591
112
py