Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about training #3

Closed
XuyangPan opened this issue May 8, 2021 · 9 comments
Closed

about training #3

XuyangPan opened this issue May 8, 2021 · 9 comments

Comments

@XuyangPan
Copy link

Thanks for your amazing work. I tried to train mxfont model following the default configuration, but how I get reference image and what the dataset format is.

please give the detail description.
Thanks.

@8uos
Copy link
Collaborator

8uos commented May 10, 2021

Hi, thanks for your interest in our work.

The truetype font files (.ttf) and decomposition information file (.json) are needed to train the model.
Also, the file of available characters is needed for each ttf file and you can generate it automatically using the get_chars_from_ttf.py.
Please refer readme for the detailed file format and the usage.
You can find the example data structure under the data directory.
Thanks.

@XuyangPan
Copy link
Author

I steped through the TTFTrainDataset(especially the function init() and getitem()) in the project code, and the some varaibles values were recorded. Their values were summarized in the following:

font : MaShanZheng-Regular.ttf, ZCOOLKuaiLe-Regular.ttf
character num: 6448
primals num: 371
decomposition num: 19739

data_list: [('MaShanZheng-Regular', '一'), ...], length: 12892
trg_img: a character image with font and character from one of data_list
trg_dec: corresponding character components
style_imgs: three character images with fonts and characters. Fonts are same with trg_img's, characters are different with trg_img's, and three character images are drawn with different characters
style_decs: corresponding character components
char_imgs: three character images with fonts and characters. Fonts are different with trg_img's, characters are same with trg_img's, and three character images are drawn with same characters
char_decs: corresponding character components

@XuyangPan
Copy link
Author

Hi, thanks for your reply.

I want to use few-shot reference glyphs to train model for generating a personal font library. What confuses me is reference images that paper metioned . Figure 1 and Table 1 presenting results with using only four reference images, so I think there should be four style images as model input for training. But the code project was not like that as expected.

I red the paper and run the project code many times, wish good reply and proper explaination.

Many thanks.

@8uos
Copy link
Collaborator

8uos commented May 11, 2021

Hi, I think that you are trying to generate the glyph images from your own font file. Is it right?

Note that, our model is able to generate new fonts without additional training.
So, if you only want to generate glyphs, you don't have to train the model with reference images.

For the generation, 1) reference style images (.png), 2) a font file to use as source (.ttf), 3) character list to generate (.txt, optional) are needed.
Please refer here for detailed instruction.

Sorry for the confusion.

@XuyangPan
Copy link
Author

Many thanks for your timely reply.

Provided that I have some my handwritten character images, it is by learning their features that the mxfont model finally can generate integral font library with my handwritten character features. Is it right?

So, I want to figure out how to train mxfont model with some my handwritten character images.

@XuyangPan
Copy link
Author

I used data directory and default configuration to trained mxfont model. The trained result was in following:
1620726400(1)

In the evaluation, 300000.pth was used for model weights and Hanyi four style images were generated with Hanyi Senty Candy-color.ttf file (from https://www.sentyfont.com/candy.htm). The result went bad.

1620726944(1)
1620726970(1)
1620726992(1)

@SanghyukChun
Copy link
Collaborator

@XuyangPan
Hi, thanks for your questions.
I presume that your purpose is only creating a new font with four references.
MX-Font aims to solve "few-shot font generation"; once you have a model, the model can generate a full font library with a few references without any fine-tuning.

If you want to create your own font using a few samples (as 4 characters in our paper), you don't have to train or fine-tune anything. But I presume that you train something (so you have 30000.pth) that is not correct way to use MX-Font inference. Please just follow https://github.com/clovaai/mxfont#test again for the details, and please check whether you correctly run eval.py, not train.py

python eval.py \
    cfgs/eval.yaml \
    --weight generator.pth \
    --result_dir path/to/save/images

@XuyangPan
Copy link
Author

@SanghyukChun @8uos
many thanks to you.

With the help of your kind reply, I figured out application scenario of mxfont model and how to generate target character image.

Hope you enjoy your life.

@SanghyukChun
Copy link
Collaborator

Closing the issue, assuming the problem is resolved.
Please re-open the issue as necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants