jpuigcerver / Laia

Laia: A deep learning toolkit for HTR based on Torch
MIT License
146 stars 57 forks source link

Convert the pretrained model #36

Closed rafikg closed 5 years ago

rafikg commented 5 years ago

@jpuigcerver Hi, thanks for sharing this well written code. Did you try to convert convert the pretrained model to pytorch model ? Actually, I am trying to do it but still having problems

jpuigcerver commented 5 years ago

Thank you for showing interest in it!

I know that PyTorch has the "legacy" module, which, if I recall correctly, allows you to use Lua models. However, I have never tried it.

I ported Laia to PyTorch: https://github.com/jpuigcerver/PyLaia but it's actually a new toolkit, and old Lua models can not directly be used. Sadly, I did not have time to write proper documentation for PyLaia, since I was developing it while writing my thesis. If you want to use it, I recommend starting from the IAM example: https://github.com/jpuigcerver/PyLaia/tree/refactor_kws_egs_master/egs/iam-htr which should be functional (if it's not, please tell me).

rafikg commented 5 years ago

@jpuigcerver Thanks for your answer. Actually, I build your model using pytorch and I try to extract the weights form your lua pretrained model and transfer them to my model. I do the convolution parts correctly but I have a problem about the cudnn.BLSTM in lua and nn.lstm() in pytorch. It seems that in lua, all the parameters are flatten but not in nn.lstm() see my post https://stackoverflow.com/questions/55507905/cudnn-blstm-weight-and-biaises