Skip to content

Commit

Permalink
training: Add missing static attributes
Browse files Browse the repository at this point in the history
That fixes several warnings from clang++ like the following one:

    src/training/combine_lang_model.cpp:36:1: warning: no previous extern declaration for non-static variable 'FLAGS_lang_is_rtl' [-Wmissing-variable-declarations]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed May 26, 2019
1 parent a139d55 commit 29f2cff
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 180 deletions.
32 changes: 16 additions & 16 deletions src/training/combine_lang_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
#include "tprintf.h"
#include "unicharset_training_utils.h"

STRING_PARAM_FLAG(input_unicharset, "",
"Filename with unicharset to complete and use in encoding");
STRING_PARAM_FLAG(script_dir, "",
"Directory name for input script unicharsets");
STRING_PARAM_FLAG(words, "",
"File listing words to use for the system dictionary");
STRING_PARAM_FLAG(puncs, "", "File listing punctuation patterns");
STRING_PARAM_FLAG(numbers, "", "File listing number patterns");
STRING_PARAM_FLAG(output_dir, "", "Root directory for output files");
STRING_PARAM_FLAG(version_str, "", "Version string to add to traineddata file");
STRING_PARAM_FLAG(lang, "", "Name of language being processed");
BOOL_PARAM_FLAG(lang_is_rtl, false,
"True if lang being processed is written right-to-left");
BOOL_PARAM_FLAG(pass_through_recoder, false,
"If true, the recoder is a simple pass-through of the"
" unicharset. Otherwise, potentially a compression of it");
static STRING_PARAM_FLAG(input_unicharset, "",
"Filename with unicharset to complete and use in encoding");
static STRING_PARAM_FLAG(script_dir, "",
"Directory name for input script unicharsets");
static STRING_PARAM_FLAG(words, "",
"File listing words to use for the system dictionary");
static STRING_PARAM_FLAG(puncs, "", "File listing punctuation patterns");
static STRING_PARAM_FLAG(numbers, "", "File listing number patterns");
static STRING_PARAM_FLAG(output_dir, "", "Root directory for output files");
static STRING_PARAM_FLAG(version_str, "", "Version string to add to traineddata file");
static STRING_PARAM_FLAG(lang, "", "Name of language being processed");
static BOOL_PARAM_FLAG(lang_is_rtl, false,
"True if lang being processed is written right-to-left");
static BOOL_PARAM_FLAG(pass_through_recoder, false,
"If true, the recoder is a simple pass-through of the "
"unicharset. Otherwise, potentially a compression of it");

int main(int argc, char** argv) {
// Sets properties on the input unicharset file, and writes:
Expand Down
28 changes: 14 additions & 14 deletions src/training/commontraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,27 @@ using tesseract::ShapeTable;
// -M 0.625 -B 0.05 -I 1.0 -C 1e-6.
CLUSTERCONFIG Config = { elliptical, 0.625, 0.05, 1.0, 1e-6, 0 };
FEATURE_DEFS_STRUCT feature_defs;
CCUtil ccutil;
static CCUtil ccutil;

INT_PARAM_FLAG(debug_level, 0, "Level of Trainer debugging");
INT_PARAM_FLAG(load_images, 0, "Load images with tr files");
STRING_PARAM_FLAG(configfile, "", "File to load more configs from");
static INT_PARAM_FLAG(load_images, 0, "Load images with tr files");
static STRING_PARAM_FLAG(configfile, "", "File to load more configs from");
STRING_PARAM_FLAG(D, "", "Directory to write output files to");
STRING_PARAM_FLAG(F, "font_properties", "File listing font properties");
static STRING_PARAM_FLAG(F, "font_properties", "File listing font properties");
STRING_PARAM_FLAG(X, "", "File listing font xheights");
STRING_PARAM_FLAG(U, "unicharset", "File to load unicharset from");
STRING_PARAM_FLAG(O, "", "File to write unicharset to");
STRING_PARAM_FLAG(output_trainer, "", "File to write trainer to");
static STRING_PARAM_FLAG(output_trainer, "", "File to write trainer to");
STRING_PARAM_FLAG(test_ch, "", "UTF8 test character string");
DOUBLE_PARAM_FLAG(clusterconfig_min_samples_fraction, Config.MinSamples,
"Min number of samples per proto as % of total");
DOUBLE_PARAM_FLAG(clusterconfig_max_illegal, Config.MaxIllegal,
"Max percentage of samples in a cluster which have more"
" than 1 feature in that cluster");
DOUBLE_PARAM_FLAG(clusterconfig_independence, Config.Independence,
"Desired independence between dimensions");
DOUBLE_PARAM_FLAG(clusterconfig_confidence, Config.Confidence,
"Desired confidence in prototypes created");
static DOUBLE_PARAM_FLAG(clusterconfig_min_samples_fraction, Config.MinSamples,
"Min number of samples per proto as % of total");
static DOUBLE_PARAM_FLAG(clusterconfig_max_illegal, Config.MaxIllegal,
"Max percentage of samples in a cluster which have more"
" than 1 feature in that cluster");
static DOUBLE_PARAM_FLAG(clusterconfig_independence, Config.Independence,
"Desired independence between dimensions");
static DOUBLE_PARAM_FLAG(clusterconfig_confidence, Config.Confidence,
"Desired confidence in prototypes created");

/**
* This routine parses the command line arguments that were
Expand Down
19 changes: 9 additions & 10 deletions src/training/lstmeval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// File: lstmeval.cpp
// Description: Evaluation program for LSTM-based networks.
// Author: Ray Smith
// Created: Wed Nov 23 12:20:06 PST 2016
//
// (C) Copyright 2016, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,15 +24,15 @@
#include "strngs.h"
#include "tprintf.h"

STRING_PARAM_FLAG(model, "", "Name of model file (training or recognition)");
STRING_PARAM_FLAG(traineddata, "",
"If model is a training checkpoint, then traineddata must "
"be the traineddata file that was given to the trainer");
STRING_PARAM_FLAG(eval_listfile, "",
"File listing sample files in lstmf training format.");
INT_PARAM_FLAG(max_image_MB, 2000, "Max memory to use for images.");
INT_PARAM_FLAG(verbosity, 1,
"Amount of diagnosting information to output (0-2).");
static STRING_PARAM_FLAG(model, "", "Name of model file (training or recognition)");
static STRING_PARAM_FLAG(traineddata, "",
"If model is a training checkpoint, then traineddata must "
"be the traineddata file that was given to the trainer");
static STRING_PARAM_FLAG(eval_listfile, "",
"File listing sample files in lstmf training format.");
static INT_PARAM_FLAG(max_image_MB, 2000, "Max memory to use for images.");
static INT_PARAM_FLAG(verbosity, 1,
"Amount of diagnosting information to output (0-2).");

int main(int argc, char **argv) {
tesseract::CheckSharedLibraryVersion();
Expand Down
71 changes: 35 additions & 36 deletions src/training/lstmtraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// File: lstmtraining.cpp
// Description: Training program for LSTM-based networks.
// Author: Ray Smith
// Created: Fri May 03 11:05:06 PST 2013
//
// (C) Copyright 2013, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -28,41 +27,41 @@
#include "tprintf.h"
#include "unicharset_training_utils.h"

INT_PARAM_FLAG(debug_interval, 0, "How often to display the alignment.");
STRING_PARAM_FLAG(net_spec, "", "Network specification");
INT_PARAM_FLAG(net_mode, 192, "Controls network behavior.");
INT_PARAM_FLAG(perfect_sample_delay, 0,
"How many imperfect samples between perfect ones.");
DOUBLE_PARAM_FLAG(target_error_rate, 0.01, "Final error rate in percent.");
DOUBLE_PARAM_FLAG(weight_range, 0.1, "Range of initial random weights.");
DOUBLE_PARAM_FLAG(learning_rate, 10.0e-4, "Weight factor for new deltas.");
DOUBLE_PARAM_FLAG(momentum, 0.5, "Decay factor for repeating deltas.");
DOUBLE_PARAM_FLAG(adam_beta, 0.999, "Decay factor for repeating deltas.");
INT_PARAM_FLAG(max_image_MB, 6000, "Max memory to use for images.");
STRING_PARAM_FLAG(continue_from, "", "Existing model to extend");
STRING_PARAM_FLAG(model_output, "lstmtrain", "Basename for output models");
STRING_PARAM_FLAG(train_listfile, "",
"File listing training files in lstmf training format.");
STRING_PARAM_FLAG(eval_listfile, "",
"File listing eval files in lstmf training format.");
BOOL_PARAM_FLAG(stop_training, false,
"Just convert the training model to a runtime model.");
BOOL_PARAM_FLAG(convert_to_int, false,
"Convert the recognition model to an integer model.");
BOOL_PARAM_FLAG(sequential_training, false,
"Use the training files sequentially instead of round-robin.");
INT_PARAM_FLAG(append_index, -1, "Index in continue_from Network at which to"
" attach the new network defined by net_spec");
BOOL_PARAM_FLAG(debug_network, false,
"Get info on distribution of weight values");
INT_PARAM_FLAG(max_iterations, 0, "If set, exit after this many iterations");
STRING_PARAM_FLAG(traineddata, "",
"Combined Dawgs/Unicharset/Recoder for language model");
STRING_PARAM_FLAG(old_traineddata, "",
"When changing the character set, this specifies the old"
" character set that is to be replaced");
BOOL_PARAM_FLAG(randomly_rotate, false,
"Train OSD and randomly turn training samples upside-down");
static INT_PARAM_FLAG(debug_interval, 0, "How often to display the alignment.");
static STRING_PARAM_FLAG(net_spec, "", "Network specification");
static INT_PARAM_FLAG(net_mode, 192, "Controls network behavior.");
static INT_PARAM_FLAG(perfect_sample_delay, 0,
"How many imperfect samples between perfect ones.");
static DOUBLE_PARAM_FLAG(target_error_rate, 0.01, "Final error rate in percent.");
static DOUBLE_PARAM_FLAG(weight_range, 0.1, "Range of initial random weights.");
static DOUBLE_PARAM_FLAG(learning_rate, 10.0e-4, "Weight factor for new deltas.");
static DOUBLE_PARAM_FLAG(momentum, 0.5, "Decay factor for repeating deltas.");
static DOUBLE_PARAM_FLAG(adam_beta, 0.999, "Decay factor for repeating deltas.");
static INT_PARAM_FLAG(max_image_MB, 6000, "Max memory to use for images.");
static STRING_PARAM_FLAG(continue_from, "", "Existing model to extend");
static STRING_PARAM_FLAG(model_output, "lstmtrain", "Basename for output models");
static STRING_PARAM_FLAG(train_listfile, "",
"File listing training files in lstmf training format.");
static STRING_PARAM_FLAG(eval_listfile, "",
"File listing eval files in lstmf training format.");
static BOOL_PARAM_FLAG(stop_training, false,
"Just convert the training model to a runtime model.");
static BOOL_PARAM_FLAG(convert_to_int, false,
"Convert the recognition model to an integer model.");
static BOOL_PARAM_FLAG(sequential_training, false,
"Use the training files sequentially instead of round-robin.");
static INT_PARAM_FLAG(append_index, -1, "Index in continue_from Network at which to"
" attach the new network defined by net_spec");
static BOOL_PARAM_FLAG(debug_network, false,
"Get info on distribution of weight values");
static INT_PARAM_FLAG(max_iterations, 0, "If set, exit after this many iterations");
static STRING_PARAM_FLAG(traineddata, "",
"Combined Dawgs/Unicharset/Recoder for language model");
static STRING_PARAM_FLAG(old_traineddata, "",
"When changing the character set, this specifies the old"
" character set that is to be replaced");
static BOOL_PARAM_FLAG(randomly_rotate, false,
"Train OSD and randomly turn training samples upside-down");

// Number of training images to train between calls to MaintainCheckpoints.
const int kNumPagesPerBatch = 100;
Expand Down
12 changes: 6 additions & 6 deletions src/training/mergenf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
#include "params.h"

/*-------------------once in subfeat---------------------------------*/
double_VAR(training_angle_match_scale, 1.0, "Angle Match Scale ...");
static double_VAR(training_angle_match_scale, 1.0, "Angle Match Scale ...");

double_VAR(training_similarity_midpoint, 0.0075, "Similarity Midpoint ...");
static double_VAR(training_similarity_midpoint, 0.0075, "Similarity Midpoint ...");

double_VAR(training_similarity_curl, 2.0, "Similarity Curl ...");
static double_VAR(training_similarity_curl, 2.0, "Similarity Curl ...");

/*-----------------------------once in fasttrain----------------------------------*/
double_VAR(training_tangent_bbox_pad, 0.5, "Tangent bounding box pad ...");
static double_VAR(training_tangent_bbox_pad, 0.5, "Tangent bounding box pad ...");

double_VAR(training_orthogonal_bbox_pad, 2.5, "Orthogonal bounding box pad ...");
static double_VAR(training_orthogonal_bbox_pad, 2.5, "Orthogonal bounding box pad ...");

double_VAR(training_angle_pad, 45.0, "Angle pad ...");
static double_VAR(training_angle_pad, 45.0, "Angle pad ...");

/**
* Compare protos p1 and p2 and return an estimate of the
Expand Down
4 changes: 2 additions & 2 deletions src/training/set_unicharset_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "unicharset_training_utils.h"

// The directory that is searched for universal script unicharsets.
STRING_PARAM_FLAG(script_dir, "",
"Directory name for input script unicharsets/xheights");
static STRING_PARAM_FLAG(script_dir, "",
"Directory name for input script unicharsets/xheights");

int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion();
Expand Down
12 changes: 6 additions & 6 deletions src/training/shapeclustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
#include "params.h"
#include "strngs.h"

INT_PARAM_FLAG(display_cloud_font, -1,
"Display cloud of this font, canonical_class1");
INT_PARAM_FLAG(display_canonical_font, -1,
"Display canonical sample of this font, canonical_class2");
STRING_PARAM_FLAG(canonical_class1, "", "Class to show ambigs for");
STRING_PARAM_FLAG(canonical_class2, "", "Class to show ambigs for");
static INT_PARAM_FLAG(display_cloud_font, -1,
"Display cloud of this font, canonical_class1");
static INT_PARAM_FLAG(display_canonical_font, -1,
"Display canonical sample of this font, canonical_class2");
static STRING_PARAM_FLAG(canonical_class1, "", "Class to show ambigs for");
static STRING_PARAM_FLAG(canonical_class2, "", "Class to show ambigs for");

// Loads training data, if requested displays debug information, otherwise
// creates the master shape table by shape clustering and writes it to a file.
Expand Down
Loading

0 comments on commit 29f2cff

Please sign in to comment.