mirror of
https://github.com/open-mmlab/mmocr.git
synced 2025-06-03 21:54:47 +08:00
remove some deprecated files causing import errors
This commit is contained in:
parent
13bd2837ae
commit
3f24e34a5d
@ -1,23 +1,24 @@
|
|||||||
# Copyright (c) OpenMMLab. All rights reserved.
|
# Copyright (c) OpenMMLab. All rights reserved.
|
||||||
from . import utils
|
from . import utils
|
||||||
from .base_dataset import BaseDataset
|
from .base_dataset import BaseDataset
|
||||||
from .builder import DATASETS, LOADERS, PARSERS, TRANSFORMS
|
from .builder import LOADERS, PARSERS, TRANSFORMS
|
||||||
from .icdar_dataset import IcdarDataset
|
from .icdar_dataset import IcdarDataset
|
||||||
|
# TODO: check this
|
||||||
from .kie_dataset import KIEDataset
|
from .kie_dataset import KIEDataset
|
||||||
from .ner_dataset import NerDataset
|
from .ner_dataset import NerDataset
|
||||||
from .ocr_dataset import OCRDataset
|
from .ocr_dataset import OCRDataset
|
||||||
from .ocr_seg_dataset import OCRSegDataset
|
from .ocr_seg_dataset import OCRSegDataset
|
||||||
from .openset_kie_dataset import OpensetKIEDataset
|
from .openset_kie_dataset import OpensetKIEDataset
|
||||||
from .pipelines import CustomFormatBundle, DBNetTargets, FCENetTargets
|
from .pipelines import DBNetTargets, FCENetTargets
|
||||||
from .text_det_dataset import TextDetDataset
|
from .text_det_dataset import TextDetDataset
|
||||||
from .uniform_concat_dataset import UniformConcatDataset
|
from .uniform_concat_dataset import UniformConcatDataset
|
||||||
from .utils import * # NOQA
|
from .utils import * # NOQA
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'DATASETS', 'IcdarDataset', 'BaseDataset', 'OCRDataset', 'TextDetDataset',
|
'IcdarDataset', 'BaseDataset', 'OCRDataset', 'TextDetDataset',
|
||||||
'CustomFormatBundle', 'DBNetTargets', 'OCRSegDataset', 'KIEDataset',
|
'KIEDataset', 'DBNetTargets', 'OCRSegDataset', 'FCENetTargets',
|
||||||
'FCENetTargets', 'NerDataset', 'UniformConcatDataset', 'OpensetKIEDataset',
|
'NerDataset', 'UniformConcatDataset', 'OpensetKIEDataset', 'TRANSFORMS',
|
||||||
'TRANSFORMS', 'PARSERS', 'LOADERS'
|
'PARSERS', 'LOADERS'
|
||||||
]
|
]
|
||||||
|
|
||||||
__all__ += utils.__all__
|
__all__ += utils.__all__
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Copyright (c) OpenMMLab. All rights reserved.
|
# Copyright (c) OpenMMLab. All rights reserved.
|
||||||
from .box_utils import sort_vertex, sort_vertex8
|
from .box_utils import sort_vertex, sort_vertex8
|
||||||
from .custom_format_bundle import CustomFormatBundle
|
|
||||||
from .dbnet_transforms import EastRandomCrop, ImgAug
|
from .dbnet_transforms import EastRandomCrop, ImgAug
|
||||||
from .kie_transforms import KIEFormatBundle, ResizeNoImg
|
from .kie_transforms import ResizeNoImg
|
||||||
from .loading import (LoadImageFromLMDB, LoadImageFromNdarray,
|
from .loading import (LoadImageFromLMDB, LoadImageFromNdarray,
|
||||||
LoadTextAnnotations)
|
LoadTextAnnotations)
|
||||||
from .ner_transforms import NerTransform, ToTensorNER
|
from .ner_transforms import NerTransform, ToTensorNER
|
||||||
@ -21,14 +20,14 @@ from .transforms import (ColorJitter, PyramidRescale, RandomCropFlip,
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'LoadTextAnnotations', 'NormalizeOCR', 'OnlineCropOCR', 'ResizeOCR',
|
'LoadTextAnnotations', 'NormalizeOCR', 'OnlineCropOCR', 'ResizeOCR',
|
||||||
'ToTensorOCR', 'CustomFormatBundle', 'DBNetTargets', 'PANetTargets',
|
'ToTensorOCR', 'DBNetTargets', 'PANetTargets', 'ColorJitter',
|
||||||
'ColorJitter', 'RandomCropInstances', 'RandomRotateTextDet',
|
'RandomCropInstances', 'RandomRotateTextDet', 'ScaleAspectJitter',
|
||||||
'ScaleAspectJitter', 'MultiRotateAugOCR', 'OCRSegTargets', 'FancyPCA',
|
'MultiRotateAugOCR', 'OCRSegTargets', 'FancyPCA',
|
||||||
'RandomCropPolyInstances', 'RandomRotatePolyInstances', 'RandomPaddingOCR',
|
'RandomCropPolyInstances', 'RandomRotatePolyInstances', 'RandomPaddingOCR',
|
||||||
'ImgAug', 'EastRandomCrop', 'RandomRotateImageBox', 'OpencvToPil',
|
'ImgAug', 'EastRandomCrop', 'RandomRotateImageBox', 'OpencvToPil',
|
||||||
'PilToOpencv', 'KIEFormatBundle', 'SquareResizePad', 'TextSnakeTargets',
|
'PilToOpencv', 'SquareResizePad', 'TextSnakeTargets', 'sort_vertex',
|
||||||
'sort_vertex', 'LoadImageFromNdarray', 'sort_vertex8', 'FCENetTargets',
|
'LoadImageFromNdarray', 'sort_vertex8', 'FCENetTargets', 'RandomScaling',
|
||||||
'RandomScaling', 'RandomCropFlip', 'NerTransform', 'ToTensorNER',
|
'RandomCropFlip', 'NerTransform', 'ToTensorNER', 'ResizeNoImg',
|
||||||
'ResizeNoImg', 'PyramidRescale', 'OneOfWrapper', 'RandomWrapper',
|
'PyramidRescale', 'OneOfWrapper', 'RandomWrapper', 'TorchVisionWrapper',
|
||||||
'TorchVisionWrapper', 'LoadImageFromLMDB'
|
'LoadImageFromLMDB'
|
||||||
]
|
]
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
# Copyright (c) OpenMMLab. All rights reserved.
|
|
||||||
import numpy as np
|
|
||||||
from mmcv.parallel import DataContainer as DC
|
|
||||||
from mmdet.datasets.pipelines.formatting import DefaultFormatBundle
|
|
||||||
|
|
||||||
from mmocr.core.visualize import overlay_mask_img, show_feature
|
|
||||||
from mmocr.registry import TRANSFORMS
|
|
||||||
|
|
||||||
|
|
||||||
@TRANSFORMS.register_module()
|
|
||||||
class CustomFormatBundle(DefaultFormatBundle):
|
|
||||||
"""Custom formatting bundle.
|
|
||||||
|
|
||||||
It formats common fields such as 'img' and 'proposals' as done in
|
|
||||||
DefaultFormatBundle, while other fields such as 'gt_kernels' and
|
|
||||||
'gt_effective_region_mask' will be formatted to DC as follows:
|
|
||||||
|
|
||||||
- gt_kernels: to DataContainer (cpu_only=True)
|
|
||||||
- gt_effective_mask: to DataContainer (cpu_only=True)
|
|
||||||
|
|
||||||
Args:
|
|
||||||
keys (list[str]): Fields to be formatted to DC only.
|
|
||||||
call_super (bool): If True, format common fields
|
|
||||||
by DefaultFormatBundle, else format fields in keys above only.
|
|
||||||
visualize (dict): If flag=True, visualize gt mask for debugging.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self,
|
|
||||||
keys=[],
|
|
||||||
call_super=True,
|
|
||||||
visualize=dict(flag=False, boundary_key=None)):
|
|
||||||
|
|
||||||
super().__init__()
|
|
||||||
self.visualize = visualize
|
|
||||||
self.keys = keys
|
|
||||||
self.call_super = call_super
|
|
||||||
|
|
||||||
def __call__(self, results):
|
|
||||||
|
|
||||||
if self.visualize['flag']:
|
|
||||||
img = results['img'].astype(np.uint8)
|
|
||||||
boundary_key = self.visualize['boundary_key']
|
|
||||||
if boundary_key is not None:
|
|
||||||
img = overlay_mask_img(img, results[boundary_key].masks[0])
|
|
||||||
|
|
||||||
features = [img]
|
|
||||||
names = ['img']
|
|
||||||
to_uint8 = [1]
|
|
||||||
|
|
||||||
for k in results['mask_fields']:
|
|
||||||
for iter in range(len(results[k].masks)):
|
|
||||||
features.append(results[k].masks[iter])
|
|
||||||
names.append(k + str(iter))
|
|
||||||
to_uint8.append(0)
|
|
||||||
show_feature(features, names, to_uint8)
|
|
||||||
|
|
||||||
if self.call_super:
|
|
||||||
results = super().__call__(results)
|
|
||||||
|
|
||||||
for k in self.keys:
|
|
||||||
results[k] = DC(results[k], cpu_only=True)
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return self.__class__.__name__
|
|
@ -1,8 +1,6 @@
|
|||||||
# Copyright (c) OpenMMLab. All rights reserved.
|
# Copyright (c) OpenMMLab. All rights reserved.
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from mmcv import rescale_size
|
from mmcv import rescale_size
|
||||||
from mmcv.parallel import DataContainer as DC
|
|
||||||
from mmdet.datasets.pipelines.formatting import DefaultFormatBundle, to_tensor
|
|
||||||
|
|
||||||
from mmocr.registry import TRANSFORMS
|
from mmocr.registry import TRANSFORMS
|
||||||
|
|
||||||
@ -40,52 +38,53 @@ class ResizeNoImg:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@TRANSFORMS.register_module()
|
# @TRANSFORMS.register_module()
|
||||||
class KIEFormatBundle(DefaultFormatBundle):
|
# class KIEFormatBundle(DefaultFormatBundle):
|
||||||
"""Key information extraction formatting bundle.
|
# """Key information extraction formatting bundle.
|
||||||
|
|
||||||
Based on the DefaultFormatBundle, itt simplifies the pipeline of formatting
|
# Based on the DefaultFormatBundle, itt simplifies the pipeline of
|
||||||
common fields, including "img", "proposals", "gt_bboxes", "gt_labels",
|
# formatting
|
||||||
"gt_masks", "gt_semantic_seg", "relations" and "texts".
|
# common fields, including "img", "proposals", "gt_bboxes", "gt_labels",
|
||||||
These fields are formatted as follows.
|
# "gt_masks", "gt_semantic_seg", "relations" and "texts".
|
||||||
|
# These fields are formatted as follows.
|
||||||
|
|
||||||
- img: (1) transpose, (2) to tensor, (3) to DataContainer (stack=True)
|
# - img: (1) transpose, (2) to tensor, (3) to DataContainer (stack=True)
|
||||||
- proposals: (1) to tensor, (2) to DataContainer
|
# - proposals: (1) to tensor, (2) to DataContainer
|
||||||
- gt_bboxes: (1) to tensor, (2) to DataContainer
|
# - gt_bboxes: (1) to tensor, (2) to DataContainer
|
||||||
- gt_bboxes_ignore: (1) to tensor, (2) to DataContainer
|
# - gt_bboxes_ignore: (1) to tensor, (2) to DataContainer
|
||||||
- gt_labels: (1) to tensor, (2) to DataContainer
|
# - gt_labels: (1) to tensor, (2) to DataContainer
|
||||||
- gt_masks: (1) to tensor, (2) to DataContainer (cpu_only=True)
|
# - gt_masks: (1) to tensor, (2) to DataContainer (cpu_only=True)
|
||||||
- gt_semantic_seg: (1) unsqueeze dim-0 (2) to tensor,
|
# - gt_semantic_seg: (1) unsqueeze dim-0 (2) to tensor,
|
||||||
(3) to DataContainer (stack=True)
|
# (3) to DataContainer (stack=True)
|
||||||
- relations: (1) scale, (2) to tensor, (3) to DataContainer
|
# - relations: (1) scale, (2) to tensor, (3) to DataContainer
|
||||||
- texts: (1) to tensor, (2) to DataContainer
|
# - texts: (1) to tensor, (2) to DataContainer
|
||||||
"""
|
# """
|
||||||
|
|
||||||
def __call__(self, results):
|
# def __call__(self, results):
|
||||||
"""Call function to transform and format common fields in results.
|
# """Call function to transform and format common fields in results.
|
||||||
|
|
||||||
Args:
|
# Args:
|
||||||
results (dict): Result dict contains the data to convert.
|
# results (dict): Result dict contains the data to convert.
|
||||||
|
|
||||||
Returns:
|
# Returns:
|
||||||
dict: The result dict contains the data that is formatted with
|
# dict: The result dict contains the data that is formatted with
|
||||||
default bundle.
|
# default bundle.
|
||||||
"""
|
# """
|
||||||
super().__call__(results)
|
# super().__call__(results)
|
||||||
if 'ann_info' in results:
|
# if 'ann_info' in results:
|
||||||
for key in ['relations', 'texts']:
|
# for key in ['relations', 'texts']:
|
||||||
value = results['ann_info'][key]
|
# value = results['ann_info'][key]
|
||||||
if key == 'relations' and 'scale_factor' in results:
|
# if key == 'relations' and 'scale_factor' in results:
|
||||||
scale_factor = results['scale_factor']
|
# scale_factor = results['scale_factor']
|
||||||
if isinstance(scale_factor, float):
|
# if isinstance(scale_factor, float):
|
||||||
sx = sy = scale_factor
|
# sx = sy = scale_factor
|
||||||
else:
|
# else:
|
||||||
sx, sy = results['scale_factor'][:2]
|
# sx, sy = results['scale_factor'][:2]
|
||||||
r = sx / sy
|
# r = sx / sy
|
||||||
factor = np.array([sx, sy, r, 1, r]).astype(np.float32)
|
# factor = np.array([sx, sy, r, 1, r]).astype(np.float32)
|
||||||
value = value * factor[None, None]
|
# value = value * factor[None, None]
|
||||||
results[key] = DC(to_tensor(value))
|
# results[key] = DC(to_tensor(value))
|
||||||
return results
|
# return results
|
||||||
|
|
||||||
def __repr__(self):
|
# def __repr__(self):
|
||||||
return self.__class__.__name__
|
# return self.__class__.__name__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user