Skip to content

Commit 29f2cff

Browse files
committed
training: Add missing static attributes
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 <[email protected]>
1 parent a139d55 commit 29f2cff

9 files changed

+179
-180
lines changed

src/training/combine_lang_model.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@
2222
#include "tprintf.h"
2323
#include "unicharset_training_utils.h"
2424

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

4242
int main(int argc, char** argv) {
4343
// Sets properties on the input unicharset file, and writes:

src/training/commontraining.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,27 @@ using tesseract::ShapeTable;
8787
// -M 0.625 -B 0.05 -I 1.0 -C 1e-6.
8888
CLUSTERCONFIG Config = { elliptical, 0.625, 0.05, 1.0, 1e-6, 0 };
8989
FEATURE_DEFS_STRUCT feature_defs;
90-
CCUtil ccutil;
90+
static CCUtil ccutil;
9191

9292
INT_PARAM_FLAG(debug_level, 0, "Level of Trainer debugging");
93-
INT_PARAM_FLAG(load_images, 0, "Load images with tr files");
94-
STRING_PARAM_FLAG(configfile, "", "File to load more configs from");
93+
static INT_PARAM_FLAG(load_images, 0, "Load images with tr files");
94+
static STRING_PARAM_FLAG(configfile, "", "File to load more configs from");
9595
STRING_PARAM_FLAG(D, "", "Directory to write output files to");
96-
STRING_PARAM_FLAG(F, "font_properties", "File listing font properties");
96+
static STRING_PARAM_FLAG(F, "font_properties", "File listing font properties");
9797
STRING_PARAM_FLAG(X, "", "File listing font xheights");
9898
STRING_PARAM_FLAG(U, "unicharset", "File to load unicharset from");
9999
STRING_PARAM_FLAG(O, "", "File to write unicharset to");
100-
STRING_PARAM_FLAG(output_trainer, "", "File to write trainer to");
100+
static STRING_PARAM_FLAG(output_trainer, "", "File to write trainer to");
101101
STRING_PARAM_FLAG(test_ch, "", "UTF8 test character string");
102-
DOUBLE_PARAM_FLAG(clusterconfig_min_samples_fraction, Config.MinSamples,
103-
"Min number of samples per proto as % of total");
104-
DOUBLE_PARAM_FLAG(clusterconfig_max_illegal, Config.MaxIllegal,
105-
"Max percentage of samples in a cluster which have more"
106-
" than 1 feature in that cluster");
107-
DOUBLE_PARAM_FLAG(clusterconfig_independence, Config.Independence,
108-
"Desired independence between dimensions");
109-
DOUBLE_PARAM_FLAG(clusterconfig_confidence, Config.Confidence,
110-
"Desired confidence in prototypes created");
102+
static DOUBLE_PARAM_FLAG(clusterconfig_min_samples_fraction, Config.MinSamples,
103+
"Min number of samples per proto as % of total");
104+
static DOUBLE_PARAM_FLAG(clusterconfig_max_illegal, Config.MaxIllegal,
105+
"Max percentage of samples in a cluster which have more"
106+
" than 1 feature in that cluster");
107+
static DOUBLE_PARAM_FLAG(clusterconfig_independence, Config.Independence,
108+
"Desired independence between dimensions");
109+
static DOUBLE_PARAM_FLAG(clusterconfig_confidence, Config.Confidence,
110+
"Desired confidence in prototypes created");
111111

112112
/**
113113
* This routine parses the command line arguments that were

src/training/lstmeval.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// File: lstmeval.cpp
33
// Description: Evaluation program for LSTM-based networks.
44
// Author: Ray Smith
5-
// Created: Wed Nov 23 12:20:06 PST 2016
65
//
76
// (C) Copyright 2016, Google Inc.
87
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,15 +24,15 @@
2524
#include "strngs.h"
2625
#include "tprintf.h"
2726

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

3837
int main(int argc, char **argv) {
3938
tesseract::CheckSharedLibraryVersion();

src/training/lstmtraining.cpp

+35-36
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// File: lstmtraining.cpp
33
// Description: Training program for LSTM-based networks.
44
// Author: Ray Smith
5-
// Created: Fri May 03 11:05:06 PST 2013
65
//
76
// (C) Copyright 2013, Google Inc.
87
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,41 +27,41 @@
2827
#include "tprintf.h"
2928
#include "unicharset_training_utils.h"
3029

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

6766
// Number of training images to train between calls to MaintainCheckpoints.
6867
const int kNumPagesPerBatch = 100;

src/training/mergenf.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
#include "params.h"
3434

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

38-
double_VAR(training_similarity_midpoint, 0.0075, "Similarity Midpoint ...");
38+
static double_VAR(training_similarity_midpoint, 0.0075, "Similarity Midpoint ...");
3939

40-
double_VAR(training_similarity_curl, 2.0, "Similarity Curl ...");
40+
static double_VAR(training_similarity_curl, 2.0, "Similarity Curl ...");
4141

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

45-
double_VAR(training_orthogonal_bbox_pad, 2.5, "Orthogonal bounding box pad ...");
45+
static double_VAR(training_orthogonal_bbox_pad, 2.5, "Orthogonal bounding box pad ...");
4646

47-
double_VAR(training_angle_pad, 45.0, "Angle pad ...");
47+
static double_VAR(training_angle_pad, 45.0, "Angle pad ...");
4848

4949
/**
5050
* Compare protos p1 and p2 and return an estimate of the

src/training/set_unicharset_properties.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "unicharset_training_utils.h"
1919

2020
// The directory that is searched for universal script unicharsets.
21-
STRING_PARAM_FLAG(script_dir, "",
22-
"Directory name for input script unicharsets/xheights");
21+
static STRING_PARAM_FLAG(script_dir, "",
22+
"Directory name for input script unicharsets/xheights");
2323

2424
int main(int argc, char** argv) {
2525
tesseract::CheckSharedLibraryVersion();

src/training/shapeclustering.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
#include "params.h"
2929
#include "strngs.h"
3030

31-
INT_PARAM_FLAG(display_cloud_font, -1,
32-
"Display cloud of this font, canonical_class1");
33-
INT_PARAM_FLAG(display_canonical_font, -1,
34-
"Display canonical sample of this font, canonical_class2");
35-
STRING_PARAM_FLAG(canonical_class1, "", "Class to show ambigs for");
36-
STRING_PARAM_FLAG(canonical_class2, "", "Class to show ambigs for");
31+
static INT_PARAM_FLAG(display_cloud_font, -1,
32+
"Display cloud of this font, canonical_class1");
33+
static INT_PARAM_FLAG(display_canonical_font, -1,
34+
"Display canonical sample of this font, canonical_class2");
35+
static STRING_PARAM_FLAG(canonical_class1, "", "Class to show ambigs for");
36+
static STRING_PARAM_FLAG(canonical_class2, "", "Class to show ambigs for");
3737

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

0 commit comments

Comments
 (0)