Closed githubnameoo closed 2 years ago
I have seen this, but I do not understand 2. How to handle Split characters to train and Validation set
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
['a', 'b', 'c']
['b', 'c']
['d', 'e']
We support the above setting by json files.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))
Thank you for your answer. Could you tell me how to confirm the character and image position in the training image and validational image?
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
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?
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
really appreciate your answer
Closing the issue, assuming the answer resolves the problem. Please re-open the issue as necessary.
Could you follow the document here? https://github.com/clovaai/fewshot-font-generation/blob/main/docs/Dataset.md#12-prepare-image-files