parlance / ctcdecode

PyTorch CTC Decoder bindings
MIT License
829 stars 245 forks source link

memory usage for large label sizes #99

Open mohamad-hasan-sohan-ajini opened 5 years ago

mohamad-hasan-sohan-ajini commented 5 years ago

Hi

I trained a multilingual OCR model using using CTC loss function. As I used JTL to train different languages, the output size is 146 (including blank). I tried to use ctcdecoder.CTCBeamDecoder to decode the network output but instantiating this class with 146 labels takes huge amount of ram (and time also). Bellow is the table of allocated memory wrt label size:

label size memory used (in GB)
40 .73
80 1.2
120 2.29
160 6.85

As the table shows, memory usage grow faster than linear order, thus the decoder is not applicable with models contains plenty of outputs! Is there any plan for supporting improving memory usage of decoder? Or is there any thing I could do to alleviate the issue?

Best regards.