Skip to content

Commit f73206b

Browse files
authored
Make python package (#19)
1 parent 3685703 commit f73206b

10 files changed

Lines changed: 118 additions & 43 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
python-version: ${{ matrix.python }}
2020
- name: Upgrade pip, setuptools and wheel
2121
run: python -m pip install --upgrade pip setuptools wheel
22-
- name: Install requirements
23-
run: pip install --upgrade -r requirements.txt
22+
- name: Install synthtiger
23+
run: pip install .
2424
- name: Install black
2525
run: pip install --upgrade black==22.1.0
2626
- name: Run black
@@ -42,8 +42,8 @@ jobs:
4242
python-version: ${{ matrix.python }}
4343
- name: Upgrade pip, setuptools and wheel
4444
run: python -m pip install --upgrade pip setuptools wheel
45-
- name: Install requirements
46-
run: pip install --upgrade -r requirements.txt
45+
- name: Install synthtiger
46+
run: pip install .
4747
- name: Install isort
4848
run: pip install --upgrade isort==5.10.1
4949
- name: Run isort
@@ -65,8 +65,8 @@ jobs:
6565
python-version: ${{ matrix.python }}
6666
- name: Upgrade pip, setuptools and wheel
6767
run: python -m pip install --upgrade pip setuptools wheel
68-
- name: Install requirements
69-
run: pip install --upgrade -r requirements.txt
68+
- name: Install synthtiger
69+
run: pip install .
7070
- name: Install mypy
7171
run: pip install --upgrade mypy
7272
- name: Run mypy
@@ -88,8 +88,8 @@ jobs:
8888
python-version: ${{ matrix.python }}
8989
- name: Upgrade pip, setuptools and wheel
9090
run: python -m pip install --upgrade pip setuptools wheel
91-
- name: Install requirements
92-
run: pip install --upgrade -r requirements.txt
91+
- name: Install synthtiger
92+
run: pip install .
9393
- name: Install pylint
9494
run: pip install --upgrade pylint
9595
- name: Run pylint
@@ -112,8 +112,8 @@ jobs:
112112
python-version: ${{ matrix.python }}
113113
- name: Upgrade pip, setuptools and wheel
114114
run: python -m pip install --upgrade pip setuptools wheel
115-
- name: Install requirements
116-
run: pip install --upgrade -r requirements.txt
115+
- name: Install synthtiger
116+
run: pip install .
117117
- name: Install pytest
118118
run: pip install --upgrade pytest
119119
- name: Run pytest
@@ -136,8 +136,8 @@ jobs:
136136
python-version: ${{ matrix.python }}
137137
- name: Upgrade pip, setuptools and wheel
138138
run: python -m pip install --upgrade pip setuptools wheel
139-
- name: Install requirements
140-
run: pip install --upgrade -r requirements.txt
139+
- name: Install synthtiger
140+
run: pip install .
141141
- name: Install pytest
142142
run: pip install --upgrade pytest
143143
- name: Run pytest
@@ -164,8 +164,8 @@ jobs:
164164
python-version: ${{ matrix.python }}
165165
- name: Upgrade pip, setuptools and wheel
166166
run: python -m pip install --upgrade pip setuptools wheel
167-
- name: Install requirements
168-
run: pip install --upgrade -r requirements.txt
167+
- name: Install synthtiger
168+
run: pip install .
169169
- name: Install pytest
170170
run: pip install --upgrade pytest
171171
- name: Run pytest

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
python-version: 3.8
1919
- name: Upgrade pip, setuptools and wheel
2020
run: python -m pip install --upgrade pip setuptools wheel
21-
- name: Install requirements
22-
run: pip install --upgrade -r requirements.txt
21+
- name: Install synthtiger
22+
run: pip install .
2323
- name: Install sphinx
2424
run: pip install --upgrade sphinx furo
2525
- name: Build docs

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
graft synthtiger
2+
global-exclude *.py[cod] .DS_Store
3+
prune tests

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 🐯 SynthTIGER: Synthetic Text Image Generator
22

3+
[![PyPI version](https://img.shields.io/pypi/v/synthtiger)](https://pypi.org/project/synthtiger/)
4+
[![CI](https://github.com/clovaai/synthtiger/actions/workflows/ci.yml/badge.svg)](https://github.com/clovaai/synthtiger/actions/workflows/ci.yml)
5+
[![Docs](https://github.com/clovaai/synthtiger/actions/workflows/docs.yml/badge.svg)](https://github.com/clovaai/synthtiger/actions/workflows/docs.yml)
6+
[![License](https://img.shields.io/github/license/clovaai/synthtiger)](LICENSE)
7+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
8+
39
[Paper](https://arxiv.org/abs/2107.09313) | [Documentation](https://clovaai.github.io/synthtiger/) | [Datasets](#datasets)
410

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

915
## Contents
1016

11-
- [Updates](#updates)
1217
- [Documentation](#documentation)
13-
- [Prerequisites](#prerequisites)
18+
- [Installation](#installation)
1419
- [Usage](#usage)
1520
- [Advanced Usage](#advanced-usage)
1621
- [Datasets](#datasets)
1722
- [Citation](#citation)
1823
- [License](#license)
1924

20-
## Updates
21-
22-
**Oct 23, 2021**: Dataset was split into several smaller files.
23-
2425
## Documentation
2526

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

2829
You can check API reference in this documentation.
2930

30-
## Prerequisites
31+
## Installation
3132

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

34-
Run following command before use it.
35+
To install SynthTIGER from PyPI:
3536

3637
```bash
37-
$ pip install -r requirements.txt
38+
$ pip install synthtiger
3839
```
3940

4041
## Usage
@@ -45,7 +46,7 @@ $ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
4546
```
4647

4748
```
48-
usage: gen.py [-h] [-o PATH] [-c INTEGER] [-w INTEGER] [-v] SCRIPT NAME [CONFIG]
49+
usage: synthtiger [-h] [-o PATH] [-c INTEGER] [-w INTEGER] [-v] SCRIPT NAME [CONFIG]
4950
5051
positional arguments:
5152
SCRIPT Script file path.
@@ -69,18 +70,18 @@ optional arguments:
6970

7071
```bash
7172
# horizontal
72-
python gen.py -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_horizontal.yaml
73+
synthtiger -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_horizontal.yaml
7374

7475
# vertical
75-
python gen.py -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_vertical.yaml
76+
synthtiger -o results -w 4 -v examples/synthtiger/template.py SynthTiger examples/synthtiger/config_vertical.yaml
7677
```
7778

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

8081
#### Multiline text images
8182

8283
```bash
83-
python gen.py -o results -w 4 -v examples/multiline/template.py Multiline examples/multiline/config.yaml
84+
synthtiger -o results -w 4 -v examples/multiline/template.py Multiline examples/multiline/config.yaml
8485
```
8586

8687
<img src="https://user-images.githubusercontent.com/12423224/153699088-cdeb3eb3-e117-4959-abf4-8454ad95d886.png" width="75%"/>

requirements.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

setup.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import os
2+
3+
from setuptools import find_packages, setup
4+
5+
ROOT = os.path.abspath(os.path.dirname(__file__))
6+
7+
8+
def read_version():
9+
data = {}
10+
path = os.path.join(ROOT, "synthtiger", "_version.py")
11+
with open(path, "r", encoding="utf-8") as fp:
12+
exec(fp.read(), data)
13+
return data["__version__"]
14+
15+
16+
def read_long_description():
17+
path = os.path.join(ROOT, "README.md")
18+
with open(path, "r", encoding="utf-8") as fp:
19+
text = fp.read()
20+
return text
21+
22+
23+
setup(
24+
name="synthtiger",
25+
version=read_version(),
26+
description="Synthetic text image generator for OCR model",
27+
long_description=read_long_description(),
28+
long_description_content_type="text/markdown",
29+
author="Moonbin Yim, Yoonsik Kim, Han-Cheol Cho, Sungrae Park",
30+
url="https://github.com/clovaai/synthtiger",
31+
license="MIT",
32+
packages=find_packages(exclude=["tests"]),
33+
include_package_data=True,
34+
python_requires=">=3.6",
35+
install_requires=[
36+
"arabic-reshaper",
37+
"blend-modes",
38+
"fonttools",
39+
"imgaug",
40+
"numpy",
41+
"opencv-python",
42+
"pillow>=8.2.0",
43+
"pygame",
44+
"python-bidi",
45+
"pytweening",
46+
"pyyaml",
47+
"regex",
48+
"scipy",
49+
],
50+
entry_points={
51+
"console_scripts": [
52+
"synthtiger = synthtiger.main:main",
53+
],
54+
},
55+
classifiers=[
56+
"Development Status :: 4 - Beta",
57+
"Intended Audience :: Developers",
58+
"Intended Audience :: Information Technology",
59+
"Intended Audience :: Science/Research",
60+
"License :: OSI Approved :: MIT License",
61+
"Operating System :: OS Independent",
62+
"Programming Language :: Python",
63+
"Programming Language :: Python :: 3",
64+
"Programming Language :: Python :: 3.6",
65+
"Programming Language :: Python :: 3.7",
66+
"Programming Language :: Python :: 3.8",
67+
"Programming Language :: Python :: 3.9",
68+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
69+
"Topic :: Scientific/Engineering :: Image Processing",
70+
"Topic :: Scientific/Engineering :: Image Recognition",
71+
"Topic :: Software Development :: Libraries",
72+
"Topic :: Software Development :: Libraries :: Python Modules",
73+
],
74+
)

synthtiger/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
from synthtiger import components, layers, templates, utils
8+
from synthtiger._version import __version__
89
from synthtiger.gen import generator, read_config, read_template
910

1011
__all__ = [

synthtiger/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
SynthTIGER
3+
Copyright (c) 2021-present NAVER Corp.
4+
MIT license
5+
"""
6+
7+
from synthtiger.main import main
8+
9+
main()

synthtiger/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0"
File renamed without changes.

0 commit comments

Comments
 (0)