Skip to content

Commit

Permalink
Make python package (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonbings authored Feb 15, 2022
1 parent 3685703 commit f73206b
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 43 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install black
run: pip install --upgrade black==22.1.0
- name: Run black
Expand All @@ -42,8 +42,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install isort
run: pip install --upgrade isort==5.10.1
- name: Run isort
Expand All @@ -65,8 +65,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install mypy
run: pip install --upgrade mypy
- name: Run mypy
Expand All @@ -88,8 +88,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install pylint
run: pip install --upgrade pylint
- name: Run pylint
Expand All @@ -112,8 +112,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install pytest
run: pip install --upgrade pytest
- name: Run pytest
Expand All @@ -136,8 +136,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install pytest
run: pip install --upgrade pytest
- name: Run pytest
Expand All @@ -164,8 +164,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install pytest
run: pip install --upgrade pytest
- name: Run pytest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
python-version: 3.8
- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel
- name: Install requirements
run: pip install --upgrade -r requirements.txt
- name: Install synthtiger
run: pip install .
- name: Install sphinx
run: pip install --upgrade sphinx furo
- name: Build docs
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
graft synthtiger
global-exclude *.py[cod] .DS_Store
prune tests
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 🐯 SynthTIGER: Synthetic Text Image Generator

[![PyPI version](https://img.shields.io/pypi/v/synthtiger)](https://pypi.org/project/synthtiger/)
[![CI](https://github.com/clovaai/synthtiger/actions/workflows/ci.yml/badge.svg)](https://github.com/clovaai/synthtiger/actions/workflows/ci.yml)
[![Docs](https://github.com/clovaai/synthtiger/actions/workflows/docs.yml/badge.svg)](https://github.com/clovaai/synthtiger/actions/workflows/docs.yml)
[![License](https://img.shields.io/github/license/clovaai/synthtiger)](LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

[Paper](https://arxiv.org/abs/2107.09313) | [Documentation](https://clovaai.github.io/synthtiger/) | [Datasets](#datasets)

SynthTIGER is synthetic text image generator for OCR model.
Expand All @@ -8,33 +14,28 @@ SynthTIGER is synthetic text image generator for OCR model.

## Contents

- [Updates](#updates)
- [Documentation](#documentation)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [Datasets](#datasets)
- [Citation](#citation)
- [License](#license)

## Updates

**Oct 23, 2021**: Dataset was split into several smaller files.

## Documentation

The documentation is available at <https://clovaai.github.io/synthtiger/>.

You can check API reference in this documentation.

## Prerequisites
## Installation

SynthTIGER requires `python>=3.6` and `libraqm`. If you want install dependencies, see [dependencies](depends).

Run following command before use it.
To install SynthTIGER from PyPI:

```bash
$ pip install -r requirements.txt
$ pip install synthtiger
```

## Usage
Expand All @@ -45,7 +46,7 @@ $ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
```

```
usage: gen.py [-h] [-o PATH] [-c INTEGER] [-w INTEGER] [-v] SCRIPT NAME [CONFIG]
usage: synthtiger [-h] [-o PATH] [-c INTEGER] [-w INTEGER] [-v] SCRIPT NAME [CONFIG]
positional arguments:
SCRIPT Script file path.
Expand All @@ -69,18 +70,18 @@ optional arguments:

```bash
# horizontal
python gen.py -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_horizontal.yaml
synthtiger -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_horizontal.yaml

# vertical
python gen.py -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_vertical.yaml
synthtiger -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_vertical.yaml
```

<img src="https://user-images.githubusercontent.com/12423224/153699084-1d5fbb15-0ca0-4a85-9639-6f2c4c1bf9ec.png" width="50%"/>

#### Multiline text images

```bash
python gen.py -o results -w 4 -v examples/multiline/template.py Multiline examples/multiline/config.yaml
synthtiger -o results -w 4 -v examples/multiline/template.py Multiline examples/multiline/config.yaml
```

<img src="https://user-images.githubusercontent.com/12423224/153699088-cdeb3eb3-e117-4959-abf4-8454ad95d886.png" width="75%"/>
Expand Down
14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

74 changes: 74 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os

from setuptools import find_packages, setup

ROOT = os.path.abspath(os.path.dirname(__file__))


def read_version():
data = {}
path = os.path.join(ROOT, "synthtiger", "_version.py")
with open(path, "r", encoding="utf-8") as fp:
exec(fp.read(), data)
return data["__version__"]


def read_long_description():
path = os.path.join(ROOT, "README.md")
with open(path, "r", encoding="utf-8") as fp:
text = fp.read()
return text


setup(
name="synthtiger",
version=read_version(),
description="Synthetic text image generator for OCR model",
long_description=read_long_description(),
long_description_content_type="text/markdown",
author="Moonbin Yim, Yoonsik Kim, Han-Cheol Cho, Sungrae Park",
url="https://github.com/clovaai/synthtiger",
license="MIT",
packages=find_packages(exclude=["tests"]),
include_package_data=True,
python_requires=">=3.6",
install_requires=[
"arabic-reshaper",
"blend-modes",
"fonttools",
"imgaug",
"numpy",
"opencv-python",
"pillow>=8.2.0",
"pygame",
"python-bidi",
"pytweening",
"pyyaml",
"regex",
"scipy",
],
entry_points={
"console_scripts": [
"synthtiger = synthtiger.main:main",
],
},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
1 change: 1 addition & 0 deletions synthtiger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

from synthtiger import components, layers, templates, utils
from synthtiger._version import __version__
from synthtiger.gen import generator, read_config, read_template

__all__ = [
Expand Down
9 changes: 9 additions & 0 deletions synthtiger/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
SynthTIGER
Copyright (c) 2021-present NAVER Corp.
MIT license
"""

from synthtiger.main import main

main()
1 change: 1 addition & 0 deletions synthtiger/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
File renamed without changes.

0 comments on commit f73206b

Please sign in to comment.