clovaai / fewshot-font-generation

The unified repository for few-shot font generation methods. This repository includes FUNIT (ICCV'19), DM-Font (ECCV'20), LF-Font (AAAI'21) and MX-Font (ICCV'21).
Other
211 stars 37 forks source link

Hello, may I ask how to process data when using images as training sets in LFFont? #6

Closed githubnameoo closed 2 years ago

SanghyukChun commented 2 years ago

Could you follow the document here? https://github.com/clovaai/fewshot-font-generation/blob/main/docs/Dataset.md#12-prepare-image-files

githubnameoo commented 2 years ago

I have seen this, but I do not understand 2. How to handle Split characters to train and Validation set

SanghyukChun commented 2 years ago

Our implementation supports manual train/validation splits for controllable and reproducible experiments. Assume you have a list of characters like ['a', 'b', 'c', 'd', 'e'], and you would like to use the train/validation as

You can check examples here: https://github.com/clovaai/fewshot-font-generation/tree/main/data/chn Please check train_chars.json, val_seen_chars.json, and val_unseen_chars.json.

If you do not need to split them, then you can skip 2.

If you mean that you do not know how to split your character list to separated json files, it might help

import numpy as np
import json

full_chars = ['a', 'b', 'c', 'd', 'e']
np.random.shuffle(full_chars)
# now full_chars is shuffled
# for example, full_chars = ['c', 'b', 'e', 'a', 'd']

n_train_chars = 3
train_chars = full_chars[:n_train_chars]
# train_chars = ['c', 'b', 'e']

n_var_seen_chars = 2
val_seen_chars = train_chars[:n_var_seen_chars]
# seen_val_chars = ['c', 'b']

var_unseen_chars = full_chars[n_train_chars:]
# var_unseen_chars = ['a', 'd']

with open('train_chars.json', 'w') as fout:
    fout.write(json.dumps(train_chars))

with open('val_seen_chars.json', 'w') as fout:
    fout.write(json.dumps(val_seen_chars))

with open('val_unseen_chars.json', 'w') as fout:
    fout.write(json.dumps(val_unseen_chars))
githubnameoo commented 2 years ago

Thank you for your answer. Could you tell me how to confirm the character and image position in the training image and validational image?

SanghyukChun commented 2 years ago

Sorry I cannot understand what "position" means. If you mean the location of each file, please edit your configure file following this document https://github.com/clovaai/fewshot-font-generation/blob/main/docs/Dataset.md#5-modify-the-data-configuration-file-cfgsdatatraincustomyaml

githubnameoo commented 2 years ago

Are there target style and source style images in PNG folder? Or two target style images, how to configure the source style image and target style image folder and corresponding characters? 捕获

SanghyukChun commented 2 years ago

If you mean how to split train / validation fonts, split them by directories, such as

|-- train_dir
    |-- train_font1
    |-- train_font2
|-- val_dir
    |-- val_font1
    |-- val_font2
|-- eval_dir
...

and edit your configuration file.

Please read the document first. https://github.com/clovaai/fewshot-font-generation/blob/main/docs/Dataset.md#5-modify-the-data-configuration-file-cfgsdatatraincustomyaml

You can specify train / val data directory by train / data_dir val / data_dir in the configuration file

githubnameoo commented 2 years ago

really appreciate your answer

SanghyukChun commented 2 years ago

Closing the issue, assuming the answer resolves the problem. Please re-open the issue as necessary.