X-rayLaser / pytorch-handwriting-synthesis-toolkit

Handwriting generation and handwriting synthesis as described in Alex Graves's paper https://arxiv.org/abs/1308.0850. Pytorch implementation.
MIT License
66 stars 11 forks source link

Training with Arabic Online Handwriting Data #2

Open pj-mathematician opened 1 year ago

pj-mathematician commented 1 year ago

Can you please suggest the modifications that I should apply, so that I can train the given model for Arabic Handwriting sequences. Arabic text is written from right to left, which might be the reason for which this model isnt yielding correct results. Thanks. Example arabic online handwriting model is ADAB

X-rayLaser commented 1 year ago

Yes, it is quite possibly the reason. I vaguely recall that in the code the attention window slides from left to right. If that's the case then, neural net might look at the least relevant part of a character string when predicting next point.

Have you tried to reverse the order of the text transcript (apple -> elppa) on a level of a dataset? Perhaps you can decorate the dataset class you have like this:

class ReversedTextDataset:
    def __init__(self, ds):
      self.ds = ds
    def __getitem__(self, indx):
      handwriting, text = self.ds[indx]      
      return handwriting, text[::-1]
    def __len__(self):
      return len(self.ds)
pj-mathematician commented 1 year ago

Thank you, this seems promising. I will try it out on my data.

X-rayLaser commented 1 year ago

By the way, could you show a couple of typical samples generated by the neural net? It's just that there may be other issues with code besides the neural side (e.g. some rendering bugs).

X-rayLaser commented 1 year ago

Yep, try that. It might be the quickest fix.