mirror of https://github.com/open-mmlab/mmocr.git
mv data_convert_util to mmocr (#96)
* mv data_convert_util to mmocr * update * rm bracketpull/98/head
parent
bba33a3f4f
commit
b058fdcb4e
|
@ -3,7 +3,8 @@ from mmcv.utils import Registry, build_from_cfg
|
|||
from .check_argument import (equal_len, is_2dlist, is_3dlist, is_ndarray_list,
|
||||
is_none_or_type, is_type_list, valid_boundary)
|
||||
from .collect_env import collect_env
|
||||
from .img_util import drop_orientation
|
||||
from .data_convert_util import convert_annotations
|
||||
from .img_util import drop_orientation, is_not_png
|
||||
from .lmdb_util import lmdb_converter
|
||||
from .logger import get_root_logger
|
||||
|
||||
|
@ -11,5 +12,5 @@ __all__ = [
|
|||
'Registry', 'build_from_cfg', 'get_root_logger', 'collect_env',
|
||||
'is_3dlist', 'is_ndarray_list', 'is_type_list', 'is_none_or_type',
|
||||
'equal_len', 'is_2dlist', 'valid_boundary', 'lmdb_converter',
|
||||
'drop_orientation'
|
||||
'drop_orientation', 'convert_annotations', 'is_not_png'
|
||||
]
|
||||
|
|
|
@ -1,25 +1,6 @@
|
|||
import os.path as osp
|
||||
|
||||
import mmcv
|
||||
|
||||
|
||||
def is_not_png(img_file):
|
||||
"""Check img_file is not png image.
|
||||
|
||||
Args:
|
||||
img_file(str): The input image file name
|
||||
|
||||
Returns:
|
||||
The bool flag indicating whether it is not png
|
||||
"""
|
||||
assert isinstance(img_file, str)
|
||||
assert img_file
|
||||
|
||||
suffix = osp.splitext(img_file)[1]
|
||||
|
||||
return (suffix not in ['.PNG', '.png'])
|
||||
|
||||
|
||||
def convert_annotations(image_infos, out_json_name):
|
||||
"""Convert the annotation into coco style.
|
||||
|
|
@ -32,3 +32,20 @@ def drop_orientation(img_file):
|
|||
os.remove(img_file)
|
||||
print(f'{img_file} has orientation info. Ignore it by converting to png')
|
||||
return target_file
|
||||
|
||||
|
||||
def is_not_png(img_file):
|
||||
"""Check img_file is not png image.
|
||||
|
||||
Args:
|
||||
img_file(str): The input image file name
|
||||
|
||||
Returns:
|
||||
The bool flag indicating whether it is not png
|
||||
"""
|
||||
assert isinstance(img_file, str)
|
||||
assert img_file
|
||||
|
||||
suffix = os.path.splitext(img_file)[1]
|
||||
|
||||
return suffix not in ['.PNG', '.png']
|
||||
|
|
|
@ -7,9 +7,8 @@ from functools import partial
|
|||
import mmcv
|
||||
import numpy as np
|
||||
from shapely.geometry import Polygon
|
||||
from tools.data.utils.common import convert_annotations, is_not_png
|
||||
|
||||
from mmocr.utils import drop_orientation
|
||||
from mmocr.utils import convert_annotations, drop_orientation, is_not_png
|
||||
|
||||
|
||||
def collect_files(img_dir, gt_dir, split):
|
||||
|
|
|
@ -6,9 +6,8 @@ from functools import partial
|
|||
import mmcv
|
||||
import numpy as np
|
||||
from shapely.geometry import Polygon
|
||||
from tools.data.utils.common import convert_annotations, is_not_png
|
||||
|
||||
from mmocr.utils import drop_orientation
|
||||
from mmocr.utils import convert_annotations, drop_orientation, is_not_png
|
||||
|
||||
|
||||
def collect_files(img_dir, gt_dir):
|
||||
|
|
|
@ -8,9 +8,8 @@ import mmcv
|
|||
import numpy as np
|
||||
import scipy.io as scio
|
||||
from shapely.geometry import Polygon
|
||||
from tools.data_converter.common import convert_annotations, is_not_png
|
||||
|
||||
from mmocr.utils import drop_orientation
|
||||
from mmocr.utils import convert_annotations, drop_orientation, is_not_png
|
||||
|
||||
|
||||
def collect_files(img_dir, gt_dir, split):
|
||||
|
|
Loading…
Reference in New Issue