tesseract v5.3.3.20231005
|
#include <lstmtrainer.h>
Public Member Functions | |
LSTMTrainer () | |
LSTMTrainer (const char *model_base, const char *checkpoint_name, int debug_interval, int64_t max_memory) | |
virtual | ~LSTMTrainer () |
bool | TryLoadingCheckpoint (const char *filename, const char *old_traineddata) |
bool | InitCharSet (const std::string &traineddata_path) |
void | InitCharSet (const TessdataManager &mgr) |
bool | InitNetwork (const char *network_spec, int append_index, int net_flags, float weight_range, float learning_rate, float momentum, float adam_beta) |
int | InitTensorFlowNetwork (const std::string &tf_proto) |
void | InitIterations () |
double | ActivationError () const |
double | CharError () const |
const double * | error_rates () const |
double | best_error_rate () const |
int | best_iteration () const |
int | learning_iteration () const |
int32_t | improvement_steps () const |
void | set_perfect_delay (int delay) |
const std::vector< char > & | best_trainer () const |
double | NewSingleError (ErrorTypes type) const |
double | LastSingleError (ErrorTypes type) const |
const DocumentCache & | training_data () const |
DocumentCache * | mutable_training_data () |
Trainability | GridSearchDictParams (const ImageData *trainingdata, int iteration, double min_dict_ratio, double dict_ratio_step, double max_dict_ratio, double min_cert_offset, double cert_offset_step, double max_cert_offset, std::string &results) |
void | DebugNetwork () |
bool | LoadAllTrainingData (const std::vector< std::string > &filenames, CachingStrategy cache_strategy, bool randomly_rotate) |
bool | MaintainCheckpoints (const TestCallback &tester, std::stringstream &log_msg) |
bool | MaintainCheckpointsSpecific (int iteration, const std::vector< char > *train_model, const std::vector< char > *rec_model, TestCallback tester, std::stringstream &log_msg) |
void | PrepareLogMsg (std::stringstream &log_msg) const |
void | LogIterations (const char *intro_str, std::stringstream &log_msg) const |
bool | TransitionTrainingStage (float error_threshold) |
int | CurrentTrainingStage () const |
bool | Serialize (SerializeAmount serialize_amount, const TessdataManager *mgr, TFile *fp) const |
bool | DeSerialize (const TessdataManager *mgr, TFile *fp) |
void | StartSubtrainer (std::stringstream &log_msg) |
SubTrainerResult | UpdateSubtrainer (std::stringstream &log_msg) |
void | ReduceLearningRates (LSTMTrainer *samples_trainer, std::stringstream &log_msg) |
int | ReduceLayerLearningRates (TFloat factor, int num_samples, LSTMTrainer *samples_trainer) |
bool | EncodeString (const std::string &str, std::vector< int > *labels) const |
const ImageData * | TrainOnLine (LSTMTrainer *samples_trainer, bool batch) |
Trainability | TrainOnLine (const ImageData *trainingdata, bool batch) |
Trainability | PrepareForBackward (const ImageData *trainingdata, NetworkIO *fwd_outputs, NetworkIO *targets) |
bool | SaveTrainingDump (SerializeAmount serialize_amount, const LSTMTrainer &trainer, std::vector< char > *data) const |
bool | ReadTrainingDump (const std::vector< char > &data, LSTMTrainer &trainer) const |
bool | ReadSizedTrainingDump (const char *data, int size, LSTMTrainer &trainer) const |
bool | ReadLocalTrainingDump (const TessdataManager *mgr, const char *data, int size) |
void | SetupCheckpointInfo () |
bool | SaveTraineddata (const char *filename) |
void | SaveRecognitionDump (std::vector< char > *data) const |
std::string | DumpFilename () const |
void | FillErrorBuffer (double new_error, ErrorTypes type) |
std::vector< int > | MapRecoder (const UNICHARSET &old_chset, const UnicharCompress &old_recoder) const |
![]() | |
LSTMRecognizer () | |
LSTMRecognizer (const std::string &language_data_path_prefix) | |
~LSTMRecognizer () | |
int | NumOutputs () const |
int | training_iteration () const |
int | sample_iteration () const |
float | learning_rate () const |
LossType | OutputLossType () const |
bool | SimpleTextOutput () const |
bool | IsIntMode () const |
bool | IsRecoding () const |
bool | IsTensorFlow () const |
std::vector< std::string > | EnumerateLayers () const |
Network * | GetLayer (const std::string &id) const |
float | GetLayerLearningRate (const std::string &id) const |
const char * | GetNetwork () const |
float | GetAdamBeta () const |
float | GetMomentum () const |
void | ScaleLearningRate (double factor) |
void | ScaleLayerLearningRate (const std::string &id, double factor) |
void | SetLearningRate (float learning_rate) |
void | SetLayerLearningRate (const std::string &id, float learning_rate) |
void | ConvertToInt () |
const UNICHARSET & | GetUnicharset () const |
UNICHARSET & | GetUnicharset () |
const UnicharCompress & | GetRecoder () const |
const Dict * | GetDict () const |
Dict * | GetDict () |
void | SetIteration (int iteration) |
int | NumInputs () const |
int | null_char () const |
bool | Load (const ParamsVectors *params, const std::string &lang, TessdataManager *mgr) |
bool | Serialize (const TessdataManager *mgr, TFile *fp) const |
bool | DeSerialize (const TessdataManager *mgr, TFile *fp) |
bool | LoadCharsets (const TessdataManager *mgr) |
bool | LoadRecoder (TFile *fp) |
bool | LoadDictionary (const ParamsVectors *params, const std::string &lang, TessdataManager *mgr) |
void | RecognizeLine (const ImageData &image_data, float invert_threshold, bool debug, double worst_dict_cert, const TBOX &line_box, PointerVector< WERD_RES > *words, int lstm_choice_mode=0, int lstm_choice_amount=5) |
void | OutputStats (const NetworkIO &outputs, float *min_output, float *mean_output, float *sd) |
bool | RecognizeLine (const ImageData &image_data, float invert_threshold, bool debug, bool re_invert, bool upside_down, float *scale_factor, NetworkIO *inputs, NetworkIO *outputs) |
std::string | DecodeLabels (const std::vector< int > &labels) |
void | DisplayForward (const NetworkIO &inputs, const std::vector< int > &labels, const std::vector< int > &label_coords, const char *window_name, ScrollView **window) |
void | LabelsFromOutputs (const NetworkIO &outputs, std::vector< int > *labels, std::vector< int > *xcoords) |
Static Public Member Functions | |
static bool | EncodeString (const std::string &str, const UNICHARSET &unicharset, const UnicharCompress *recoder, bool simple_text, int null_char, std::vector< int > *labels) |
Protected Member Functions | |
void | InitCharSet () |
void | SetNullChar () |
void | EmptyConstructor () |
bool | DebugLSTMTraining (const NetworkIO &inputs, const ImageData &trainingdata, const NetworkIO &fwd_outputs, const std::vector< int > &truth_labels, const NetworkIO &outputs) |
void | DisplayTargets (const NetworkIO &targets, const char *window_name, ScrollView **window) |
bool | ComputeTextTargets (const NetworkIO &outputs, const std::vector< int > &truth_labels, NetworkIO *targets) |
bool | ComputeCTCTargets (const std::vector< int > &truth_labels, NetworkIO *outputs, NetworkIO *targets) |
double | ComputeErrorRates (const NetworkIO &deltas, double char_error, double word_error) |
double | ComputeRMSError (const NetworkIO &deltas) |
double | ComputeWinnerError (const NetworkIO &deltas) |
double | ComputeCharError (const std::vector< int > &truth_str, const std::vector< int > &ocr_str) |
double | ComputeWordError (std::string *truth_str, std::string *ocr_str) |
void | UpdateErrorBuffer (double new_error, ErrorTypes type) |
void | RollErrorBuffers () |
std::string | UpdateErrorGraph (int iteration, double error_rate, const std::vector< char > &model_data, const TestCallback &tester) |
![]() | |
void | SetRandomSeed () |
void | DisplayLSTMOutput (const std::vector< int > &labels, const std::vector< int > &xcoords, int height, ScrollView *window) |
void | DebugActivationPath (const NetworkIO &outputs, const std::vector< int > &labels, const std::vector< int > &xcoords) |
void | DebugActivationRange (const NetworkIO &outputs, const char *label, int best_choice, int x_start, int x_end) |
void | LabelsViaReEncode (const NetworkIO &output, std::vector< int > *labels, std::vector< int > *xcoords) |
void | LabelsViaSimpleText (const NetworkIO &output, std::vector< int > *labels, std::vector< int > *xcoords) |
const char * | DecodeLabel (const std::vector< int > &labels, unsigned start, unsigned *end, int *decoded) |
const char * | DecodeSingleLabel (int label) |
Static Protected Attributes | |
static const int | kRollingBufferSize_ = 1000 |
Definition at line 84 of file lstmtrainer.h.
tesseract::LSTMTrainer::LSTMTrainer | ( | ) |
Definition at line 77 of file lstmtrainer.cpp.
tesseract::LSTMTrainer::LSTMTrainer | ( | const char * | model_base, |
const char * | checkpoint_name, | ||
int | debug_interval, | ||
int64_t | max_memory | ||
) |
Definition at line 83 of file lstmtrainer.cpp.
|
virtual |
Definition at line 94 of file lstmtrainer.cpp.
|
inline |
Definition at line 130 of file lstmtrainer.h.
|
inline |
Definition at line 139 of file lstmtrainer.h.
|
inline |
Definition at line 142 of file lstmtrainer.h.
|
inline |
Definition at line 154 of file lstmtrainer.h.
|
inline |
Definition at line 133 of file lstmtrainer.h.
|
protected |
Definition at line 1323 of file lstmtrainer.cpp.
|
protected |
Definition at line 1254 of file lstmtrainer.cpp.
|
protected |
Definition at line 1265 of file lstmtrainer.cpp.
|
protected |
Definition at line 1285 of file lstmtrainer.cpp.
|
protected |
Definition at line 1232 of file lstmtrainer.cpp.
|
protected |
Definition at line 1304 of file lstmtrainer.cpp.
|
protected |
Definition at line 1351 of file lstmtrainer.cpp.
|
inline |
Definition at line 217 of file lstmtrainer.h.
|
protected |
Definition at line 1154 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::DebugNetwork | ( | ) |
Definition at line 289 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::DeSerialize | ( | const TessdataManager * | mgr, |
TFile * | fp | ||
) |
Definition at line 511 of file lstmtrainer.cpp.
|
protected |
Definition at line 1195 of file lstmtrainer.cpp.
std::string tesseract::LSTMTrainer::DumpFilename | ( | ) | const |
Definition at line 1053 of file lstmtrainer.cpp.
|
protected |
Definition at line 1137 of file lstmtrainer.cpp.
|
static |
Definition at line 813 of file lstmtrainer.cpp.
|
inline |
Definition at line 254 of file lstmtrainer.h.
|
inline |
Definition at line 136 of file lstmtrainer.h.
void tesseract::LSTMTrainer::FillErrorBuffer | ( | double | new_error, |
ErrorTypes | type | ||
) |
Definition at line 1065 of file lstmtrainer.cpp.
Trainability tesseract::LSTMTrainer::GridSearchDictParams | ( | const ImageData * | trainingdata, |
int | iteration, | ||
double | min_dict_ratio, | ||
double | dict_ratio_step, | ||
double | max_dict_ratio, | ||
double | min_cert_offset, | ||
double | cert_offset_step, | ||
double | max_cert_offset, | ||
std::string & | results | ||
) |
Definition at line 236 of file lstmtrainer.cpp.
|
inline |
Definition at line 148 of file lstmtrainer.h.
|
protected |
Definition at line 1115 of file lstmtrainer.cpp.
|
inline |
Definition at line 100 of file lstmtrainer.h.
|
inline |
Definition at line 107 of file lstmtrainer.h.
void tesseract::LSTMTrainer::InitIterations | ( | ) |
Definition at line 208 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::InitNetwork | ( | const char * | network_spec, |
int | append_index, | ||
int | net_flags, | ||
float | weight_range, | ||
float | learning_rate, | ||
float | momentum, | ||
float | adam_beta | ||
) |
Definition at line 164 of file lstmtrainer.cpp.
int tesseract::LSTMTrainer::InitTensorFlowNetwork | ( | const std::string & | tf_proto | ) |
|
inline |
Definition at line 164 of file lstmtrainer.h.
|
inline |
Definition at line 145 of file lstmtrainer.h.
bool tesseract::LSTMTrainer::LoadAllTrainingData | ( | const std::vector< std::string > & | filenames, |
CachingStrategy | cache_strategy, | ||
bool | randomly_rotate | ||
) |
Definition at line 296 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::LogIterations | ( | const char * | intro_str, |
std::stringstream & | log_msg | ||
) | const |
Definition at line 407 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::MaintainCheckpoints | ( | const TestCallback & | tester, |
std::stringstream & | log_msg | ||
) |
Definition at line 309 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::MaintainCheckpointsSpecific | ( | int | iteration, |
const std::vector< char > * | train_model, | ||
const std::vector< char > * | rec_model, | ||
TestCallback | tester, | ||
std::stringstream & | log_msg | ||
) |
std::vector< int > tesseract::LSTMTrainer::MapRecoder | ( | const UNICHARSET & | old_chset, |
const UnicharCompress & | old_recoder | ||
) | const |
Definition at line 1074 of file lstmtrainer.cpp.
|
inline |
Definition at line 172 of file lstmtrainer.h.
|
inline |
Definition at line 158 of file lstmtrainer.h.
Trainability tesseract::LSTMTrainer::PrepareForBackward | ( | const ImageData * | trainingdata, |
NetworkIO * | fwd_outputs, | ||
NetworkIO * | targets | ||
) |
Definition at line 902 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::PrepareLogMsg | ( | std::stringstream & | log_msg | ) | const |
Definition at line 395 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::ReadLocalTrainingDump | ( | const TessdataManager * | mgr, |
const char * | data, | ||
int | size | ||
) |
Definition at line 1022 of file lstmtrainer.cpp.
|
inline |
Definition at line 307 of file lstmtrainer.h.
|
inline |
Definition at line 300 of file lstmtrainer.h.
int tesseract::LSTMTrainer::ReduceLayerLearningRates | ( | TFloat | factor, |
int | num_samples, | ||
LSTMTrainer * | samples_trainer | ||
) |
Definition at line 694 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::ReduceLearningRates | ( | LSTMTrainer * | samples_trainer, |
std::stringstream & | log_msg | ||
) |
Definition at line 675 of file lstmtrainer.cpp.
|
protected |
Definition at line 1405 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::SaveRecognitionDump | ( | std::vector< char > * | data | ) | const |
Definition at line 1043 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveTraineddata | ( | const char * | filename | ) |
Definition at line 1034 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveTrainingDump | ( | SerializeAmount | serialize_amount, |
const LSTMTrainer & | trainer, | ||
std::vector< char > * | data | ||
) | const |
Definition at line 1013 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::Serialize | ( | SerializeAmount | serialize_amount, |
const TessdataManager * | mgr, | ||
TFile * | fp | ||
) | const |
Definition at line 427 of file lstmtrainer.cpp.
|
inline |
Definition at line 151 of file lstmtrainer.h.
|
protected |
Definition at line 1128 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::SetupCheckpointInfo | ( | ) |
void tesseract::LSTMTrainer::StartSubtrainer | ( | std::stringstream & | log_msg | ) |
Definition at line 605 of file lstmtrainer.cpp.
|
inline |
Definition at line 169 of file lstmtrainer.h.
Trainability tesseract::LSTMTrainer::TrainOnLine | ( | const ImageData * | trainingdata, |
bool | batch | ||
) |
Definition at line 869 of file lstmtrainer.cpp.
|
inline |
Definition at line 268 of file lstmtrainer.h.
bool tesseract::LSTMTrainer::TransitionTrainingStage | ( | float | error_threshold | ) |
Definition at line 417 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::TryLoadingCheckpoint | ( | const char * | filename, |
const char * | old_traineddata | ||
) |
Definition at line 105 of file lstmtrainer.cpp.
|
protected |
Definition at line 1389 of file lstmtrainer.cpp.
|
protected |
Definition at line 1425 of file lstmtrainer.cpp.
SubTrainerResult tesseract::LSTMTrainer::UpdateSubtrainer | ( | std::stringstream & | log_msg | ) |
Definition at line 633 of file lstmtrainer.cpp.
|
protected |
Definition at line 408 of file lstmtrainer.h.
|
protected |
Definition at line 462 of file lstmtrainer.h.
|
protected |
Definition at line 463 of file lstmtrainer.h.
|
protected |
Definition at line 435 of file lstmtrainer.h.
|
protected |
Definition at line 437 of file lstmtrainer.h.
|
protected |
Definition at line 439 of file lstmtrainer.h.
|
protected |
Definition at line 449 of file lstmtrainer.h.
|
protected |
Definition at line 428 of file lstmtrainer.h.
|
protected |
Definition at line 452 of file lstmtrainer.h.
|
protected |
Definition at line 419 of file lstmtrainer.h.
|
protected |
Definition at line 423 of file lstmtrainer.h.
|
protected |
Definition at line 412 of file lstmtrainer.h.
|
protected |
Definition at line 417 of file lstmtrainer.h.
|
protected |
Definition at line 484 of file lstmtrainer.h.
|
protected |
Definition at line 457 of file lstmtrainer.h.
|
protected |
Definition at line 486 of file lstmtrainer.h.
|
protected |
Definition at line 465 of file lstmtrainer.h.
|
staticprotected |
Definition at line 483 of file lstmtrainer.h.
|
protected |
Definition at line 480 of file lstmtrainer.h.
|
protected |
Definition at line 469 of file lstmtrainer.h.
|
protected |
Definition at line 488 of file lstmtrainer.h.
|
protected |
Definition at line 421 of file lstmtrainer.h.
|
protected |
Definition at line 430 of file lstmtrainer.h.
|
protected |
Definition at line 477 of file lstmtrainer.h.
|
protected |
Definition at line 471 of file lstmtrainer.h.
|
protected |
Definition at line 425 of file lstmtrainer.h.
|
protected |
Definition at line 414 of file lstmtrainer.h.
|
protected |
Definition at line 447 of file lstmtrainer.h.
|
protected |
Definition at line 455 of file lstmtrainer.h.
|
protected |
Definition at line 410 of file lstmtrainer.h.
|
protected |
Definition at line 426 of file lstmtrainer.h.
|
protected |
Definition at line 459 of file lstmtrainer.h.
|
protected |
Definition at line 441 of file lstmtrainer.h.
|
protected |
Definition at line 443 of file lstmtrainer.h.
|
protected |
Definition at line 445 of file lstmtrainer.h.
|
protected |
Definition at line 450 of file lstmtrainer.h.