Skip to main content

Text Image Augmentor: data generator for text recognition

Project description

Text-Image-Augmentor

한글 이미지 인식 데이터셋을 위한 데이터 증강 라이브러리

목적

OCR 텍스트 인식 모델을 개발할 때, 필요한 학습 데이터셋 수를 늘리기 위한 목적으로 개발

개요

증강 데이터는 크게 두 가지 왜곡 방식으로 이루어져 있습니다. 하나는 글자의 형태에 변형을 가하는 형상 왜곡 방식이고, 다른 하나는 글자와 배경의 색에 변형을 가하는 색상 왜곡 방식입니다. 글씨 이미지는 색상보다, 형상에 의해 더 많은 영향을 받습니다. 이에 따라, 해당 라이브러리는 글자의 형태 변환을 위주로 이미지에 적용하도록 구성하였습니다.

**CLI 환경(command line interface)**으로 구성하여 연구자들과 개발자들이 쉽게 쓸 수 있도록 구성하였고, 라이브러리는 데이미지 증강 라이브러리 중 하나인 imgaug를 기반으로 작성하였습니다.

설치

  1. pypi에서 패키지 설치하기

    pip install textaug
    
    • caution : 아직 pypi에 배포하지 않은 상태입니다. Test code 작성 완료 후, 배포하도록 하겠습니다.
  2. Repository로부터 설치하기

    # 해당 디렉토리로부터 다운받은 후, 아래를 실행시키면 됩니다.
    python3 setup.py install
    

사용방법

해당 프로그램은 Command Line Interface(Terminal, CMD, shell) 등 환경에서 실행시킬 수 있습니다.

example
textaug <input_dir> <output_dir> --multiples=3

위 코드를 실행시키면, input_dir 내 이미지 파일들을 읽어들여, output_dir에 증강 이미지들이 저장됩니다. input_dir 내 이미지 파일 (ex 안녕.png) 이 존재한다면, output_dir에는 무작위로 증강된 3개의 이미지 (ex 0_안녕.png, 1_안녕.png, 2_안녕.png)가 저장됩니다.

Option

아래의 요소들은 증강 이미지의 노이즈 수준을 결정짓는 데 이용됩니다. 필요한 수준의 노이즈를 아래를 통해 정하시길 바랍니다.

  • --multiples : 하나의 이미지 당 몇 개의 증강 이미지를 생성할 것인지 결정, 정수형으로 입력되어야 합니다.

  • --blur : 이미지의 흐릿한 수준을 결정. 각 값에 대한 흐릿한 정도는 아래와 같습니다.

    blur=0 blur=2 blur=4 blur = 6 blur=8
  • --noise : 이미지 배경에 노이즈 수준을 결정. 각 값에 대한 노이즈 정도는 아래와 같습니다.

    noise=0 noise=1 noise=20 noise=30 noise=40
  • --rotate : 이미지의 회전 변환 수준을 결정. 각 값에 대한 변환 정도는 아래와 같습니다.

    rotate=0 rotate=2 rotate=4 rotate=6 rotate=8
    rotate_2 rotate_4 rotate_6 rotate_8
  • --shear : 이미지의 전단 변환 수준을 결정. 각 값에 대한 변환 정도는 아래와 같습니다.

    shear=0 shear=2 shear=4 shear=6 shear=8
  • --elastic : 이미지의 Elastic 변환 수준을 결정. 각 값에 대한 변환 정도는 아래와 같습니다.

    elastic=0 elastic=1 elastic=2 elastic=3 elastic=4
    elastic_0 elastic_1 elastic_2 elastic_3

Copyright 2019, NIA(한국정보화진흥원), All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textaug-1.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textaug-1.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file textaug-1.0.2.tar.gz.

File metadata

  • Download URL: textaug-1.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.4.2 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.6

File hashes

Hashes for textaug-1.0.2.tar.gz
Algorithm Hash digest
SHA256 424fbd29d5a230e86f32044193e3e55d0f28d9a36c2dffb25d0b286f2407e56a
MD5 6aa2fc1e2e9489bcb881fb2534425c37
BLAKE2b-256 097ab5f3777fe085025d6d620883a4d33adc8e1723becce36791edd5d3b4cc50

See more details on using hashes here.

File details

Details for the file textaug-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: textaug-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.4.2 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.6

File hashes

Hashes for textaug-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d1e46af98a438567da3a4c620ce9d06568afdf7ce37856eb467ae25e8a5b297
MD5 57785b69e4c8b6b573aa811978234f45
BLAKE2b-256 46ce2d4eed379d138404a86ad99ee7e1256a5ec22dc638b01da7c327fddbe0c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page