Skip to content

Eiuyc/Hanzi-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hanzi Generator

This tool can generate Hanzi image

Install

# Pillow and opencv are required
python -m pip install Pillow
python -m pip install opencv-python

# Use pip to install HanziG
python -m pip install -U HanziG -i https://test.pypi.org/simple 

Usage

from PIL import Image
from HanziG import Generator

g = Generator()
for i in range(10):
    img, label = g.gen_sample()
    img = Image.fromarray(img)
    word = label['word']
    img.save(f'{word}.jpg')

g.config(mode='multiple', grid=[5,5])
for i in range(10):
    img, label = g.gen_sample()
    img = Image.fromarray(img)
    img.save(f'{i}.jpg')
    for i in label['words']:
        print(i['word'])
        print(i['location'])

Outputs

Format

Output is always this format:

image, label

For single mode, label is in this format:

{
    'word': word, # Hanzi
    'index': index # integer
}

For multiple mode, label is in this format:

{
    'words': [word_1, word_2, ..., word_n],
}

word_i shall be like this:

{
    'word': word, # Hanzi
    'index': index, # integer
    'size': size, # tuple, for example (64, 64)
    'location': location # tuple, for example (256, 128)
},

Image Example

single mode result

multiple mode result

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages