hologerry / Attr2Font

[SIGGRAPH 2020] Attribute2Font: Creating Fonts You Want From Attributes
https://hologerry.github.io/Attr2Font/
Other
227 stars 37 forks source link

What is the char class for? #18

Open chanind opened 3 years ago

chanind commented 3 years ago

It looks like the generator model includes a character classifier output, which classifies the character to one of 52 one-hot values. The number 52 is hardcoded: https://github.com/hologerry/Attr2Font/blob/master/model.py#L231. What is this for? The discriminator takes in a character class param, but then ignores it and never references it https://github.com/hologerry/Attr2Font/blob/master/model.py#L367. Is the char class being in this algorithm a mistake, or is it necessary for the font generation to function? If so, why?

hologerry commented 3 years ago

Thanks for your interest. The number 52 represents 26 upper and lower case letters. In Generator, the charclass is used for the content supervision, i.e., which character is for the input. In Discriminator, the charclass is added during the exploration process, but actually ended up being useless, please just ignore it.

chanind commented 3 years ago

The hardcoded 52 makes sense as 26x2. So that hardcoded value would need to be changed to use this for a real font, as real fonts have more than 52 glyphs? I guess I'm still confused what the charclass is for. If I remove this item from the generator it still seems to work. Am I missing something?

hologerry commented 3 years ago

Yes, the 52 need to be changed according to the number of glyphs in practice. We did not pass the charclass in generator, did you mean the discriminator? The charclass is only used for the content loss (softmax with the content_logit: https://github.com/hologerry/Attr2Font/blob/a5ec8ae2cb17f5725599375a8eab2966781c6c6a/model.py#L308, https://github.com/hologerry/Attr2Font/blob/a5ec8ae2cb17f5725599375a8eab2966781c6c6a/main.py#L162). So, the parameter charclass passed in discriminator is NOT necessary, should be cleaned, just ignore it.

chanind commented 3 years ago

yes that makes sense. Sorry when I said removing from the generator I meant removing the fc layer and content_logits, as well as the criterion_ce and loss_char stuff entirely. It seems like if I remove everything related to the char class and content_logits this it still works. Is that correct / expected?