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
WordArt
WordArt-main/configs/_base_/det_models/dbnet_r50dcnv2_fpnc.py
model = dict( type='DBNet', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=False, style='pytorch', dcn=dict(type='DCNv2', defor...
839
34
79
py
WordArt
WordArt-main/configs/_base_/det_models/psenet_r50_fpnf.py
model_poly = dict( type='PSENet', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50'...
1,509
28.038462
78
py
WordArt
WordArt-main/configs/_base_/det_models/ocr_mask_rcnn_r50_fpn_ohem_poly.py
# model settings model = dict( type='OCRMaskRCNN', text_repr_type='poly', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, init_...
4,264
32.582677
78
py
WordArt
WordArt-main/configs/_base_/det_models/drrg_r50_fpn_unet.py
model = dict( type='DRRG', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50'), ...
689
30.363636
78
py
WordArt
WordArt-main/configs/_base_/det_models/fcenet_r50_fpn.py
model = dict( type='FCENet', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50'), n...
969
27.529412
78
py
WordArt
WordArt-main/configs/_base_/det_models/panet_r50_fpem_ffm.py
model = dict( type='PANet', pretrained='torchvision://resnet50', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='caffe')...
672
29.590909
76
py
WordArt
WordArt-main/configs/_base_/det_models/ocr_mask_rcnn_r50_fpn_ohem.py
# model settings model = dict( type='OCRMaskRCNN', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision...
4,244
32.425197
78
py
WordArt
WordArt-main/configs/_base_/det_models/dbnetpp_r50dcnv2_fpnc.py
model = dict( type='DBNet', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=False, style='pytorch', dcn=dict(type='DCNv2', defor...
961
32.172414
78
py
WordArt
WordArt-main/configs/_base_/det_models/fcenet_r50dcnv2_fpn.py
model = dict( type='FCENet', backbone=dict( type='mmdet.ResNet', depth=50, num_stages=4, out_indices=(1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', dcn=dict(type='DCNv2', deform_g...
1,093
29.388889
78
py
WordArt
WordArt-main/configs/_base_/det_models/panet_r18_fpem_ffm.py
model_poly = dict( type='PANet', backbone=dict( type='mmdet.ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18')...
1,393
30.681818
78
py
WordArt
WordArt-main/docs/en/conf.py
# Copyright (c) OpenMMLab. All rights reserved. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -----------------------...
4,128
29.585185
79
py
WordArt
WordArt-main/docs/zh_cn/conf.py
# Copyright (c) OpenMMLab. All rights reserved. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -----------------------...
4,101
29.161765
79
py
WordArt
WordArt-main/mmocr/apis/inference.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import mmcv import numpy as np import torch from mmcv.ops import RoIPool from mmcv.parallel import collate, scatter from mmcv.runner import load_checkpoint from mmdet.core import get_classes from mmdet.datasets import replace_ImageToTensor from mmdet.data...
8,081
32.8159
79
py
WordArt
WordArt-main/mmocr/apis/test.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import mmcv import numpy as np import torch from mmcv.image import tensor2imgs from mmcv.parallel import DataContainer from mmdet.core import encode_mask_results from .utils import tensor2grayimgs def retrieve_img_tensor_and_meta(data): """Re...
6,152
37.943038
78
py
WordArt
WordArt-main/mmocr/apis/utils.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings import mmcv import numpy as np import torch from mmdet.datasets import replace_ImageToTensor from mmocr.utils import is_2dlist, is_type_list def update_pipeline(cfg, idx=None): if idx is None: if cfg.pipeline is not None: ...
4,324
33.055118
79
py
WordArt
WordArt-main/mmocr/apis/train.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import mmcv import numpy as np import torch import torch.distributed as dist from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import (DistSamplerSeedHook, EpochBasedRunner, Fp16OptimizerHook, Op...
6,512
34.016129
79
py
WordArt
WordArt-main/mmocr/core/visualize.py
# Copyright (c) OpenMMLab. All rights reserved. import math import os import shutil import urllib import warnings import cv2 import mmcv import numpy as np import torch from matplotlib import pyplot as plt from PIL import Image, ImageDraw, ImageFont import mmocr.utils as utils def overlay_mask_img(img, mask): "...
30,432
33.232846
79
py
WordArt
WordArt-main/mmocr/core/evaluation/kie_metric.py
# Copyright (c) OpenMMLab. All rights reserved. import torch def compute_f1_score(preds, gts, ignores=[]): """Compute the F1-score of prediction. Args: preds (Tensor): The predicted probability NxC map with N and C being the sample number and class number respectively. ...
1,033
34.655172
74
py
WordArt
WordArt-main/mmocr/core/deployment/deploy_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import warnings from typing import Any, Iterable import numpy as np import torch from mmdet.models.builder import DETECTORS from mmocr.models.textdet.detectors.single_stage_text_detector import \ SingleStageTextDetector from mmocr.models.textde...
12,040
35.598784
79
py
WordArt
WordArt-main/mmocr/models/builder.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.cnn import ACTIVATION_LAYERS as MMCV_ACTIVATION_LAYERS from mmcv.cnn import UPSAMPLE_LAYERS as MMCV_UPSAMPLE_LAYERS from mmcv.utils import Registry, build_from_cfg from mmdet.models.builder import BACKBONES as MMDET_BACKBON...
4,452
28.104575
79
py
WordArt
WordArt-main/mmocr/models/common/modules/transformer_module.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmocr.models.builder import build_activation_layer class ScaledDotProductAttention(nn.Module): """Scaled Dot-Product Attention Module. This code is adopted from https://g...
5,365
31.521212
76
py
WordArt
WordArt-main/mmocr/models/common/layers/transformer_layers.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.runner import BaseModule from mmocr.models.common.modules import (MultiHeadAttention, PositionwiseFeedForward) class TFEncoderLayer(BaseModule): """Transformer Encoder Layer. Args: ...
6,586
38.208333
77
py
WordArt
WordArt-main/mmocr/models/common/losses/dice_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmocr.models.builder import LOSSES @LOSSES.register_module() class DiceLoss(nn.Module): def __init__(self, eps=1e-6): super().__init__() assert isinstance(eps, float) self.eps = eps def forward(s...
791
23.75
63
py
WordArt
WordArt-main/mmocr/models/common/losses/focal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F class FocalLoss(nn.Module): """Multi-class Focal loss implementation. Args: gamma (float): The larger the gamma, the smaller the loss weight of easier samples. weight...
992
30.03125
71
py
WordArt
WordArt-main/mmocr/models/common/backbones/unet.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule, build_norm_layer from mmcv.runner import BaseModule from mmcv.utils.parrots_wrapper import _BatchNorm from mmocr.models.builder import (BACKBONES, UPSAMPLE_LAYERS, ...
21,543
40.67118
79
py
WordArt
WordArt-main/mmocr/models/kie/extractors/sdmgr.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import mmcv from mmdet.core import bbox2roi from torch import nn from torch.nn import functional as F from mmocr.core import imshow_edge, imshow_node from mmocr.models.builder import DETECTORS, build_roi_extractor from mmocr.models.common.detectors impor...
5,963
34.712575
78
py
WordArt
WordArt-main/mmocr/models/kie/losses/sdmgr_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmdet.models.losses import accuracy from torch import nn from mmocr.models.builder import LOSSES @LOSSES.register_module() class SDMGRLoss(nn.Module): """The implementation the loss of key information extraction proposed in the paper: Spatial ...
1,584
36.738095
78
py
WordArt
WordArt-main/mmocr/models/kie/heads/sdmgr_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmcv.runner import BaseModule from torch import nn from torch.nn import functional as F from mmocr.models.builder import HEADS, build_loss @HEADS.register_module() class SDMGRHead(BaseModule): def __init__(self, num_chars=92, ...
7,269
35.903553
77
py
WordArt
WordArt-main/mmocr/models/ner/decoders/fc_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch.nn as nn import torch.nn.functional as F from mmcv.runner import BaseModule from mmocr.models.builder import DECODERS @DECODERS.register_module() class FCDecoder(BaseModule): """FC Decoder class for Ner. Args: num_labels...
1,374
31.738095
77
py
WordArt
WordArt-main/mmocr/models/ner/utils/bert.py
# ------------------------------------------------------------------------------ # Adapted from https://github.com/lonePatient/BERT-NER-Pytorch # Original licence: Copyright (c) 2020 Weitang Liu, under the MIT License. # ------------------------------------------------------------------------------ import math import...
19,532
39.191358
80
py
WordArt
WordArt-main/mmocr/models/ner/utils/activations.py
# ------------------------------------------------------------------------------ # Adapted from https://github.com/lonePatient/BERT-NER-Pytorch # Original licence: Copyright (c) 2020 Weitang Liu, under the MIT License. # ------------------------------------------------------------------------------ import math import...
943
27.606061
80
py
WordArt
WordArt-main/mmocr/models/ner/losses/masked_cross_entropy_loss.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from torch.nn import CrossEntropyLoss from mmocr.models.builder import LOSSES @LOSSES.register_module() class MaskedCrossEntropyLoss(nn.Module): """The implementation of masked cross entropy loss. The mask has 1 for real tokens and 0 for p...
2,281
39.035088
73
py
WordArt
WordArt-main/mmocr/models/ner/losses/masked_focal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from mmocr.models.builder import LOSSES from mmocr.models.common.losses.focal_loss import FocalLoss @LOSSES.register_module() class MaskedFocalLoss(nn.Module): """The implementation of masked focal loss. The mask has 1 for real tokens and ...
2,272
38.877193
73
py
WordArt
WordArt-main/mmocr/models/textdet/modules/local_graph.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch from mmcv.ops import RoIAlignRotated from .utils import (euclidean_distance_matrix, feature_embedding, normalize_adjacent_matrix) class LocalGraphs: """Generate local graphs for GCN to classify the neighbors of a ...
13,094
42.942953
79
py
WordArt
WordArt-main/mmocr/models/textdet/modules/proposal_local_graph.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np import torch from lanms import merge_quadrangle_n9 as la_nms from mmcv.ops import RoIAlignRotated from mmocr.models.textdet.postprocess.utils import fill_hole from .utils import (euclidean_distance_matrix, feature_embedding, ...
18,637
43.910843
79
py
WordArt
WordArt-main/mmocr/models/textdet/modules/gcn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init class MeanAggregator(nn.Module): def forward(self, features, A): x = torch.bmm(A, features) return x class GraphConv(nn.Module): def __init__(self, i...
2,432
30.597403
78
py
WordArt
WordArt-main/mmocr/models/textdet/detectors/single_stage_text_detector.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmocr.models.builder import DETECTORS from mmocr.models.common.detectors import SingleStageDetector @DETECTORS.register_module() class SingleStageTextDetector(SingleStageDetector): """The class for implementing single stage text detector.""" ...
2,159
33.83871
79
py
WordArt
WordArt-main/mmocr/models/textdet/necks/fpem_ffm.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn.functional as F from mmcv.runner import BaseModule, ModuleList from torch import nn from mmocr.models.builder import NECKS class FPEM(BaseModule): """FPN-like feature fusion module in PANet. Args: in_channels (int): Number of input chan...
5,999
33.482759
79
py
WordArt
WordArt-main/mmocr/models/textdet/necks/fpn_unet.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from mmcv.runner import BaseModule from torch import nn from mmocr.models.builder import NECKS class UpBlock(BaseModule): """Upsample block for DRRG and TextSnake.""" def __init__(self, in_channels, out_channels, in...
3,629
32.611111
79
py
WordArt
WordArt-main/mmocr/models/textdet/necks/fpnf.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, ModuleList, auto_fp16 from mmocr.models.builder import NECKS @NECKS.register_module() class FPNF(BaseModule): """FPN-like fusion module in Shape Robust ...
4,264
32.062016
77
py
WordArt
WordArt-main/mmocr/models/textdet/necks/fpn_cat.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, ModuleList, Sequential, auto_fp16 from mmocr.models.builder import NECKS @NECKS.register_module() class FPNC(BaseModule): """FPN-l...
9,362
33.422794
79
py
WordArt
WordArt-main/mmocr/models/textdet/postprocess/pan_postprocessor.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np import torch from mmcv.ops import pixel_group from mmocr.core import points2boundary from mmocr.models.builder import POSTPROCESSOR from .base_postprocessor import BasePostprocessor @POSTPROCESSOR.register_module() class PANPostprocessor(B...
3,375
38.255814
77
py
WordArt
WordArt-main/mmocr/models/textdet/postprocess/textsnake_postprocessor.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np import torch from skimage.morphology import skeletonize from mmocr.models.builder import POSTPROCESSOR from .base_postprocessor import BasePostprocessor from .utils import centralize, fill_hole, merge_disks @POSTPROCESSOR.register_module(...
4,812
40.491379
79
py
WordArt
WordArt-main/mmocr/models/textdet/postprocess/pse_postprocessor.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np import torch from mmcv.ops import contour_expand from mmocr.core import points2boundary from mmocr.models.builder import POSTPROCESSOR from .base_postprocessor import BasePostprocessor @POSTPROCESSOR.register_module() class PSEPostprocess...
3,190
34.853933
79
py
WordArt
WordArt-main/mmocr/models/textdet/dense_heads/drrg_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import BaseModule from mmocr.models.builder import HEADS, build_loss from mmocr.models.textdet.modules import GCN, LocalGraphs, ProposalLocalGraphs fro...
10,664
40.337209
79
py
WordArt
WordArt-main/mmocr/models/textdet/dense_heads/db_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch import torch.nn as nn from mmcv.runner import BaseModule, Sequential from mmocr.models.builder import HEADS from .head_mixin import HeadMixin @HEADS.register_module() class DBHead(HeadMixin, BaseModule): """The class for DBNet head. ...
3,549
35.979167
79
py
WordArt
WordArt-main/mmocr/models/textdet/dense_heads/pan_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import numpy as np import torch import torch.nn as nn from mmcv.runner import BaseModule from mmocr.models.builder import HEADS from mmocr.utils import check_argument from .head_mixin import HeadMixin @HEADS.register_module() class PANHead(HeadMixin, B...
3,087
32.934066
75
py
WordArt
WordArt-main/mmocr/models/textdet/dense_heads/textsnake_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.runner import BaseModule from mmocr.models.builder import HEADS from .head_mixin import HeadMixin @HEADS.register_module() class TextSnakeHead(HeadMixin, BaseModule): """The class for TextSnake head: TextSnake: A Fle...
2,898
34.353659
77
py
WordArt
WordArt-main/mmocr/models/textdet/dense_heads/fce_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.runner import BaseModule from mmdet.core import multi_apply from mmocr.models.builder import HEADS from ..postprocess.utils import poly_nms from .head_mixin import HeadMixin @HEADS.register_module() class FCEHead(HeadMix...
5,269
34.133333
79
py
WordArt
WordArt-main/mmocr/models/textdet/losses/fce_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn.functional as F from mmdet.core import multi_apply from torch import nn from mmocr.models.builder import LOSSES @LOSSES.register_module() class FCELoss(nn.Module): """The class for implementing FCENet loss. FCENe...
7,914
37.052885
79
py
WordArt
WordArt-main/mmocr/models/textdet/losses/drrg_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from mmdet.core import BitmapMasks from torch import nn from mmocr.models.builder import LOSSES from mmocr.utils import check_argument @LOSSES.register_module() class DRRGLoss(nn.Module): """The class for implementing DR...
10,071
38.653543
79
py
WordArt
WordArt-main/mmocr/models/textdet/losses/db_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from torch import nn from mmocr.models.builder import LOSSES from mmocr.models.common.losses.dice_loss import DiceLoss @LOSSES.register_module() class DBLoss(nn.Module): """The class for implementing DBNet loss. Thi...
6,082
35.644578
78
py
WordArt
WordArt-main/mmocr/models/textdet/losses/textsnake_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from mmdet.core import BitmapMasks from torch import nn from mmocr.models.builder import LOSSES from mmocr.utils import check_argument @LOSSES.register_module() class TextSnakeLoss(nn.Module): """The class for implementi...
7,876
38.189055
78
py
WordArt
WordArt-main/mmocr/models/textdet/losses/pan_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import itertools import warnings import numpy as np import torch import torch.nn.functional as F from mmdet.core import BitmapMasks from torch import nn from mmocr.models.builder import LOSSES from mmocr.utils import check_argument @LOSSES.register_module() class PANL...
12,782
37.272455
79
py
WordArt
WordArt-main/mmocr/models/textrecog/plugins/common.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.cnn import PLUGIN_LAYERS @PLUGIN_LAYERS.register_module() class Maxpool2d(nn.Module): """A wrapper around nn.Maxpool2d(). Args: kernel_size (int or tuple(int)): Kernel size for max pooling layer strid...
6,302
35.645349
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/abinet_vision_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.cnn import ConvModule from mmocr.models.builder import DECODERS from mmocr.models.common.modules import PositionalEncoding from .base_decoder import BaseDecoder @DECODERS.register_module() class ABIVisionDecoder(BaseDecoder)...
6,223
36.047619
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/abinet_language_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import torch import torch.nn as nn from mmcv.cnn.bricks.transformer import BaseTransformerLayer from mmcv.runner import ModuleList from mmocr.models.builder import DECODERS from mmocr.models.common.modules import PositionalEncoding from .base_decoder import ...
6,765
36.175824
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/robust_scanner_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmocr.models.builder import DECODERS, build_decoder from mmocr.models.textrecog.layers import RobustScannerFusionLayer from .base_decoder import BaseDecoder @DECODERS.register_module() class Robust...
6,412
38.832298
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/crnn_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.runner import Sequential from mmocr.models.builder import DECODERS from mmocr.models.textrecog.layers import BidirectionalLSTM from .base_decoder import BaseDecoder @DECODERS.register_module() class CRNNDecoder(BaseDecoder): """Decod...
2,360
32.253521
72
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/position_attention_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn from mmocr.models.builder import DECODERS from mmocr.models.textrecog.layers import (DotProductAttentionLayer, PositionAwareLayer) from .base_decoder import BaseDecoder @DECODERS...
7,394
36.923077
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/sequence_attention_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F from mmocr.models.builder import DECODERS from mmocr.models.textrecog.layers import DotProductAttentionLayer from .base_decoder import BaseDecoder @DECODERS.register_module() class Sequence...
8,603
35.151261
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/nrtr_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import ModuleList from mmocr.models.builder import DECODERS from mmocr.models.common import PositionalEncoding, TFDecoderLayer from .base_decoder import BaseDecoder @DECODE...
6,451
35.247191
78
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/sar_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F import mmocr.utils as utils from mmocr.models.builder import DECODERS from .base_decoder import BaseDecoder @DECODERS.register_module() class ParallelSARDecoder(BaseDecoder): """Impleme...
18,713
38.068894
78
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/master_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import math import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn.bricks.transformer import BaseTransformerLayer from mmcv.runner import ModuleList from mmocr.models.builder import DECODERS from mmocr.models.common.modules import P...
7,670
34.027397
79
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/charcont_decoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import ModuleList from mmocr.models.builder import DECODERS from mmocr.models.common import PositionalEncoding, TFDecoderLayer from .base_decoder import BaseDecoder @DECODE...
7,056
34.109453
78
py
WordArt
WordArt-main/mmocr/models/textrecog/decoders/sar_decoder_with_bs.py
# Copyright (c) OpenMMLab. All rights reserved. from queue import PriorityQueue import torch import torch.nn.functional as F import mmocr.utils as utils from mmocr.models.builder import DECODERS from . import ParallelSARDecoder class DecodeNode: """Node class to save decoded char indices and scores. Args: ...
5,469
32.558282
79
py
WordArt
WordArt-main/mmocr/models/textrecog/necks/fpn_ocr.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, ModuleList from mmocr.models.builder import NECKS @NECKS.register_module() class FPNOCR(BaseModule): """FPN-like Network for segmentation based text rec...
3,173
35.068182
78
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/lstm_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn class BidirectionalLSTM(nn.Module): def __init__(self, nIn, nHidden, nOut): super().__init__() self.rnn = nn.LSTM(nIn, nHidden, bidirectional=True) self.embedding = nn.Linear(nHidden * 2, nOut) def forward(self, i...
561
24.545455
60
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/position_aware_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn class PositionAwareLayer(nn.Module): def __init__(self, dim_model, rnn_layers=2): super().__init__() self.dim_model = dim_model self.rnn = nn.LSTM( input_size=dim_model, hidden_size=dim_model, ...
1,052
27.459459
74
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/satrn_layers.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from mmocr.models.common import MultiHeadAttention class SatrnEncoderLayer(BaseModule): """""" def __init__(self, d_model=...
5,409
31.202381
79
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/robust_scanner_fusion_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.runner import BaseModule class RobustScannerFusionLayer(BaseModule): def __init__(self, dim_model, dim=-1, init_cfg=None): super().__init__(init_cfg=init_cfg) self.dim_model = dim_model self.dim ...
671
25.88
67
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/dot_product_attention_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F class DotProductAttentionLayer(nn.Module): def __init__(self, dim_model=None): super().__init__() self.scale = dim_model**-0.5 if dim_model is not None else 1. def forward(self...
782
26
71
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/corner_crossattn_layers.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from mmocr.models.common import MultiHeadAttention class CornerCrossattnLayer(BaseModule): """""" def __init__(self, d_mod...
5,692
31.718391
79
py
WordArt
WordArt-main/mmocr/models/textrecog/layers/conv_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import build_plugin_layer def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding.""" return nn.Conv2d( in_planes, out_planes, kernel_size=3, stride=stride, padding...
5,745
30.398907
78
py
WordArt
WordArt-main/mmocr/models/textrecog/encoders/sar_encoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F import mmocr.utils as utils from mmocr.models.builder import ENCODERS from .base_encoder import BaseEncoder @ENCODERS.register_module() class SAREncoder(BaseEncoder): """Implementation ...
3,789
32.839286
76
py
WordArt
WordArt-main/mmocr/models/textrecog/encoders/satrn_encoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch.nn as nn from mmcv.runner import ModuleList from mmocr.models.builder import ENCODERS from mmocr.models.textrecog.layers import (Adaptive2DPositionalEncoding, SatrnEncoderLayer) from .base_encoder impor...
3,034
33.885057
78
py
WordArt
WordArt-main/mmocr/models/textrecog/encoders/channel_reduction_encoder.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmocr.models.builder import ENCODERS from .base_encoder import BaseEncoder @ENCODERS.register_module() class ChannelReductionEncoder(BaseEncoder): """Change the channel number with a one by one convoluational layer. Args: in_...
1,140
29.026316
74
py
WordArt
WordArt-main/mmocr/models/textrecog/encoders/nrtr_encoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch.nn as nn from mmcv.runner import ModuleList from mmocr.models.builder import ENCODERS from mmocr.models.common import TFEncoderLayer from .base_encoder import BaseEncoder @ENCODERS.register_module() class NRTREncoder(BaseEncoder): """Trans...
2,887
31.818182
78
py
WordArt
WordArt-main/mmocr/models/textrecog/encoders/corner_encoder.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch.nn as nn from mmcv.runner import ModuleList from mmocr.models.builder import ENCODERS from mmocr.models.textrecog.layers import Adaptive2DPositionalEncoding, CornerCrossattnLayer from .base_encoder import BaseEncoder @ENCODERS.register_module(...
3,387
34.291667
92
py
WordArt
WordArt-main/mmocr/models/textrecog/convertors/base.py
# Copyright (c) OpenMMLab. All rights reserved. from mmocr.models.builder import CONVERTORS from mmocr.utils import list_from_file @CONVERTORS.register_module() class BaseConvertor: """Convert between text, index and tensor for text recognize pipeline. Args: dict_type (str): Type of dict, options are...
4,746
35.79845
79
py
WordArt
WordArt-main/mmocr/models/textrecog/convertors/ctc.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn.functional as F import mmocr.utils as utils from mmocr.models.builder import CONVERTORS from .base import BaseConvertor @CONVERTORS.register_module() class CTCConvertor(BaseConvertor): """Convert between text, index and ten...
5,414
36.089041
78
py
WordArt
WordArt-main/mmocr/models/textrecog/convertors/abi.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import mmocr.utils as utils from mmocr.models.builder import CONVERTORS from .attn import AttnConvertor @CONVERTORS.register_module() class ABIConvertor(AttnConvertor): """Convert between text, index and tensor for encoder-decoder based pipeline. M...
2,718
38.405797
77
py
WordArt
WordArt-main/mmocr/models/textrecog/convertors/seg.py
# Copyright (c) OpenMMLab. All rights reserved. import cv2 import numpy as np import torch import mmocr.utils as utils from mmocr.models.builder import CONVERTORS from .base import BaseConvertor @CONVERTORS.register_module() class SegConvertor(BaseConvertor): """Convert between text, index and tensor for segment...
4,455
33.8125
78
py
WordArt
WordArt-main/mmocr/models/textrecog/convertors/attn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import mmocr.utils as utils from mmocr.models.builder import CONVERTORS from .base import BaseConvertor @CONVERTORS.register_module() class AttnConvertor(BaseConvertor): """Convert between text, index and tensor for encoder-decoder based pipeline. ...
5,244
35.678322
78
py
WordArt
WordArt-main/mmocr/models/textrecog/recognizer/corner_transformer.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from mmocr.models.builder import (RECOGNIZERS, build_backbone, build_convertor, build_decoder, build_encoder, build_loss, build_preprocessor) from .base import BaseRecognize...
6,517
33.125654
79
py
WordArt
WordArt-main/mmocr/models/textrecog/recognizer/base.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict import mmcv import torch import torch.distributed as dist from mmcv.runner import BaseModule, auto_fp16 from mmocr.core import imshow_text_label class BaseRecognizer(BaseModule...
8,426
35.167382
79
py
WordArt
WordArt-main/mmocr/models/textrecog/recognizer/encode_decode_recognizer.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from mmocr.models.builder import (RECOGNIZERS, build_backbone, build_convertor, build_decoder, build_encoder, build_loss, build_preprocessor) from .base import BaseRecognize...
6,121
32.271739
79
py
WordArt
WordArt-main/mmocr/models/textrecog/recognizer/abinet.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from mmocr.models.builder import (RECOGNIZERS, build_backbone, build_convertor, build_decoder, build_encoder, build_fuser, build_loss, build_preprocessor) from .encode_decod...
6,505
32.709845
79
py
WordArt
WordArt-main/mmocr/models/textrecog/recognizer/seg_recognizer.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings from mmocr.models.builder import (RECOGNIZERS, build_backbone, build_convertor, build_head, build_loss, build_neck, build_preprocessor) from .base import BaseRecognizer @RECOGNIZERS.reg...
4,790
30.728477
79
py
WordArt
WordArt-main/mmocr/models/textrecog/fusers/abi_fuser.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.runner import BaseModule from mmocr.models.builder import FUSERS @FUSERS.register_module() class ABIFuser(BaseModule): """Mix and align visual feature and linguistic feature Implementation of language model of `ABINe...
1,705
31.807692
78
py
WordArt
WordArt-main/mmocr/models/textrecog/preprocessor/corner_preprocessor.py
# Modified from https://github.com/clovaai/deep-text-recognition-benchmark # # Licensed under the Apache License, Version 2.0 (the "License");s # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
2,499
33.246575
109
py
WordArt
WordArt-main/mmocr/models/textrecog/preprocessor/tps_preprocessor.py
# Modified from https://github.com/clovaai/deep-text-recognition-benchmark # # Licensed under the Apache License, Version 2.0 (the "License");s # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
11,877
42.036232
79
py
WordArt
WordArt-main/mmocr/models/textrecog/losses/ctc_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn from mmocr.models.builder import LOSSES @LOSSES.register_module() class CTCLoss(nn.Module): """Implementation of loss module for CTC-loss based text recognition. Args: flatten (bool): If True, use flatten...
3,867
36.192308
79
py
WordArt
WordArt-main/mmocr/models/textrecog/losses/ce_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmocr.models.builder import LOSSES @LOSSES.register_module() class CELoss(nn.Module): """Implementation of loss module for encoder-decoder based text recognition method with CrossEntropy loss. Args: ignore_index (int): Sp...
4,660
33.783582
79
py
WordArt
WordArt-main/mmocr/models/textrecog/losses/cc_loss.py
import torch import torch.nn as nn import torch.nn.functional as F class CCLoss(nn.Module): """Implementation of loss module for encoder-decoder based text recognition method with Character Contrastive loss. Args: ignore_index (int): Specifies a target value that is ignored and does n...
5,938
35.660494
80
py
WordArt
WordArt-main/mmocr/models/textrecog/losses/mix_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmocr.models.builder import LOSSES @LOSSES.register_module() class ABILoss(nn.Module): """Implementation of ABINet multiloss that allows mixing different types of losses with weights. ...
4,376
38.790909
79
py
WordArt
WordArt-main/mmocr/models/textrecog/losses/seg_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmocr.models.builder import LOSSES @LOSSES.register_module() class SegLoss(nn.Module): """Implementation of loss module for segmentation based text recognition method. Args: se...
2,507
29.962963
76
py
WordArt
WordArt-main/mmocr/models/textrecog/backbones/resnet_abi.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.runner import BaseModule, Sequential import mmocr.utils as utils from mmocr.models.builder import BACKBONES from mmocr.models.textrecog.layers import BasicBlock @BACKBONES.register_module() class ResNetABI(BaseModule): """Implement R...
4,405
35.114754
79
py
WordArt
WordArt-main/mmocr/models/textrecog/backbones/nrtr_modality_transformer.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.runner import BaseModule from mmocr.models.builder import BACKBONES @BACKBONES.register_module() class NRTRModalityTransform(BaseModule): def __init__(self, input_channels=3, init_cfg=[ ...
1,418
23.894737
64
py
WordArt
WordArt-main/mmocr/models/textrecog/backbones/shallow_cnn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from mmocr.models.builder import BACKBONES @BACKBONES.register_module() class ShallowCNN(BaseModule): """Implement Shallow CNN block for SATRN. SATRN: `On Recognizing Text...
2,000
27.585714
75
py