diff --git a/src/training/lstmtraining.cpp b/src/training/lstmtraining.cpp index fd365423..8852a5ce 100644 --- a/src/training/lstmtraining.cpp +++ b/src/training/lstmtraining.cpp @@ -112,7 +112,10 @@ int main(int argc, char **argv) { tesseract::LSTMTrainer trainer(FLAGS_model_output.c_str(), checkpoint_file.c_str(), FLAGS_debug_interval, static_cast(FLAGS_max_image_MB) * 1048576); - trainer.InitCharSet(FLAGS_traineddata.c_str()); + if (!trainer.InitCharSet(FLAGS_traineddata.c_str())) { + tprintf("Error, failed to read %s\n", FLAGS_traineddata.c_str()); + return EXIT_FAILURE; + } // Reading something from an existing model doesn't require many flags, // so do it now and exit. diff --git a/src/training/unicharset/lstmtrainer.h b/src/training/unicharset/lstmtrainer.h index cdebf989..292b2ef5 100644 --- a/src/training/unicharset/lstmtrainer.h +++ b/src/training/unicharset/lstmtrainer.h @@ -95,9 +95,12 @@ public: // Initializes the character set encode/decode mechanism directly from a // previously setup traineddata containing dawgs, UNICHARSET and // UnicharCompress. Note: Call before InitNetwork! - void InitCharSet(const std::string &traineddata_path) { - ASSERT_HOST(mgr_.Init(traineddata_path.c_str())); - InitCharSet(); + bool InitCharSet(const std::string &traineddata_path) { + bool success = mgr_.Init(traineddata_path.c_str()); + if (success) { + InitCharSet(); + } + return success; } void InitCharSet(const TessdataManager &mgr) { mgr_ = mgr;