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

lstmeval: Improve output by ensuring 'Truth:' text is encoded the same way as OCR output… #3421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/training/unicharset/lstmtester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ std::string LSTMTester::RunEvalSync(int iteration, const double *training_errors
int error_count = 0;
while (error_count < total_pages_) {
const ImageData *trainingdata = test_data_.GetPageBySerial(eval_iteration);
std::vector<int> truth_labels;
if (!trainer.EncodeString(trainingdata->transcription(), &truth_labels)) {
eval_iteration++;
continue;
}
std::string truth_text = trainer.DecodeLabels(truth_labels);
trainer.SetIteration(++eval_iteration);
NetworkIO fwd_outputs, targets;
Trainability result = trainer.PrepareForBackward(trainingdata, &fwd_outputs, &targets);
Expand All @@ -99,7 +105,7 @@ std::string LSTMTester::RunEvalSync(int iteration, const double *training_errors
word_error += trainer.NewSingleError(tesseract::ET_WORD_RECERR);
++error_count;
if (verbosity > 1 || (verbosity > 0 && result != PERFECT)) {
tprintf("Truth:%s\n", trainingdata->transcription().c_str());
tprintf("Truth:%s\n", truth_text.c_str());
std::vector<int> ocr_labels;
std::vector<int> xcoords;
trainer.LabelsFromOutputs(fwd_outputs, &ocr_labels, &xcoords);
Expand Down