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

Segmentation fault when using integer models for LSTM training #1573

Closed
DihuiLai opened this issue May 12, 2018 · 12 comments
Closed

Segmentation fault when using integer models for LSTM training #1573

DihuiLai opened this issue May 12, 2018 · 12 comments

Comments

@DihuiLai
Copy link

I am running the tutorial on training lstm by fine tuning it following the link https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#fine-tuning-for-impact

The training works OK when I follow the tutorial instruction and fine tune from .lstm extracted from tessdata/best/eng.traineddata. However the training failed when I try to extract .lstm from tessdata/eng.traineddata

Environment

  • Tesseract Version: tesseract 4.0.0-beta.1-232-g45a6

  • Platform: <ubuntu 16.04>

The code I am trying to execute:
training/lstmtraining --model_output ~/tesstutorial/impact_from_full/impact --continue_from ~/tesstutorial/impact_from_full/eng.lstm --traineddata tessdata/eng.traineddata --train_listfile ~/tesstutorial/engeval/eng.training_files.txt --max_iterations 400

The eng.lstm is extracted by "training/combine_tessdata -e tessdata/eng.traineddata ~/tesstutorial/impact_from_full/eng.lstm"

The code will work if I use the tessdata/best/eng.traineddata

The error that I got:
Loaded file /home/dlai/tesstutorial/impact_from_full/eng.lstm, unpacking...
Warning: LSTMTrainer deserialized an LSTMRecognizer!
Continuing from /home/dlai/tesstutorial/impact_from_full/eng.lstm
Loaded 72/72 pages (1-72) of document /home/dlai/tesstutorial/engeval/eng.FreeSans.exp0.lstmf
!int_mode_:Error:Assert failed:in file weightmatrix.cpp, line 244
Segmentation fault (core dumped)

Thanks very much

Dihui

@Shreeshrii
Copy link
Collaborator

However the training failed when I try to extract .lstm from tessdata/eng.traineddata

Both tessdata and tessdata_fast have integer models which cannot be used for lstmtraining..
Only the float models in tessdata_best can be used for it.

Of course, it should give an appropriate error message and not crash.

@stweil Is it possible to add an error msg for 4.0.0?

@DihuiLai
Copy link
Author

Thanks for your response, Shreeshrii,

I did read some comments on the integerize in your documentations and should have guessed this.

Still, is there a way to integerize the fine tuned model from the tessdata_best ? The speed of the model on tessdata_best is too slow for our application.

Dihui

@Shreeshrii
Copy link
Collaborator

The best files can be converted to integer by the following command

Usage for compacting LSTM component to int:
  combine_tessdata -c traineddata_file

The tessdata repo has the integer version of best models plus the old legacy model also.

@Shreeshrii
Copy link
Collaborator

Shreeshrii commented May 14, 2018

@DihuiLai Please change issue title to

Segmentation fault when using integer models for LSTM training

@stweil
Copy link
Contributor

stweil commented May 14, 2018

Segmentation fault when using integer models for LSTM trining

s/trining/training/

@stweil Is it possible to add an error msg for 4.0.0?

Yes, I think so. I added the issue to the planning list.

@zdenop, please add the "bug" label to this issue.

@Shreeshrii
Copy link
Collaborator

@stweil Thanks for fixing the typo :-) Good to know that it can be fixed for 4.0.0.

@DihuiLai DihuiLai changed the title Segmentation fault when training from .lstm extracted from tessdata/eng.traineddata Segmentation fault when using integer models for LSTM trining May 14, 2018
@DihuiLai
Copy link
Author

Changed @Shreeshrii

@DihuiLai DihuiLai changed the title Segmentation fault when using integer models for LSTM trining Segmentation fault when using integer models for LSTM training May 14, 2018
@zdenop zdenop added the bug label May 15, 2018
@DihuiLai
Copy link
Author

DihuiLai commented Sep 6, 2018

The problem is solved and I am closing the issue

@DihuiLai DihuiLai closed this as completed Sep 6, 2018
@amitdo
Copy link
Collaborator

amitdo commented Sep 17, 2018

AFAIK this issue was not solved.

@stweil
Copy link
Contributor

stweil commented Sep 17, 2018

It was only clarified that it was caused by training based on an integer model which is not allowed.
So that's an error which can be easily avoided. Of course the error handling needs to be improved here. @zdenop or @DihuiLai, please reopen this issue.

Although this is a bug, I think it can be fixed after 4.0.0, as training won't be done by most users of Tesseract.

@zdenop zdenop reopened this Sep 18, 2018
@zdenop
Copy link
Contributor

zdenop commented Sep 30, 2018

@stweil : can you send PR, so we can fix this for 4.0 release?

@stweil stweil added this to the 4.1.0 milestone Feb 19, 2019
@stweil stweil modified the milestones: 4.1.0, 5.0.0 Aug 29, 2019
@tesseract-ocr tesseract-ocr deleted a comment from msute Jul 23, 2020
stweil added a commit to stweil/tesseract that referenced this issue Sep 6, 2021
Tesseract currently cannot continue LSTM training from an
integer (fast) model.

Report this to users who try it nevertheless instead of crashing
with an assertion.

Signed-off-by: Stefan Weil <[email protected]>
egorpugin added a commit that referenced this issue Sep 6, 2021
Abort LSTM training with integer model (fixes issue #1573)
stweil added a commit that referenced this issue Sep 6, 2021
Tesseract currently cannot continue LSTM training from an
integer (fast) model.

Report this to users who try it nevertheless instead of crashing
with an assertion.

Signed-off-by: Stefan Weil <[email protected]>
@stweil
Copy link
Contributor

stweil commented Sep 6, 2021

The issue is now fixed in commits ec87dd4 (master) and 15aee49 (4.1 branch).

@stweil stweil closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants