mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Remove Tensorflow support
Tensorflow was never used because of missing models. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
daaa902a5e
commit
d7c0a05ffa
28
Makefile.am
28
Makefile.am
@ -110,7 +110,6 @@ lib_LTLIBRARIES = libtesseract.la
|
|||||||
libtesseract_la_LDFLAGS = $(LEPTONICA_LIBS)
|
libtesseract_la_LDFLAGS = $(LEPTONICA_LIBS)
|
||||||
libtesseract_la_LDFLAGS += $(libarchive_LIBS)
|
libtesseract_la_LDFLAGS += $(libarchive_LIBS)
|
||||||
libtesseract_la_LDFLAGS += $(libcurl_LIBS)
|
libtesseract_la_LDFLAGS += $(libcurl_LIBS)
|
||||||
libtesseract_la_LDFLAGS += $(TENSORFLOW_LIBS)
|
|
||||||
if T_WIN
|
if T_WIN
|
||||||
libtesseract_la_LDFLAGS += -no-undefined -lws2_32
|
libtesseract_la_LDFLAGS += -no-undefined -lws2_32
|
||||||
else
|
else
|
||||||
@ -509,10 +508,6 @@ libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/cutil
|
|||||||
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/dict
|
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/dict
|
||||||
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/lstm
|
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/lstm
|
||||||
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
libtesseract_lstm_la_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
||||||
if TENSORFLOW
|
|
||||||
libtesseract_lstm_la_CPPFLAGS += -DINCLUDE_TENSORFLOW
|
|
||||||
libtesseract_lstm_la_CPPFLAGS += -I/usr/include/tensorflow
|
|
||||||
endif
|
|
||||||
if !NO_TESSDATA_PREFIX
|
if !NO_TESSDATA_PREFIX
|
||||||
libtesseract_lstm_la_CPPFLAGS += -DTESSDATA_PREFIX='"@datadir@"'
|
libtesseract_lstm_la_CPPFLAGS += -DTESSDATA_PREFIX='"@datadir@"'
|
||||||
endif
|
endif
|
||||||
@ -535,7 +530,6 @@ noinst_HEADERS += src/lstm/reversed.h
|
|||||||
noinst_HEADERS += src/lstm/series.h
|
noinst_HEADERS += src/lstm/series.h
|
||||||
noinst_HEADERS += src/lstm/static_shape.h
|
noinst_HEADERS += src/lstm/static_shape.h
|
||||||
noinst_HEADERS += src/lstm/stridemap.h
|
noinst_HEADERS += src/lstm/stridemap.h
|
||||||
noinst_HEADERS += src/lstm/tfnetwork.h
|
|
||||||
noinst_HEADERS += src/lstm/weightmatrix.h
|
noinst_HEADERS += src/lstm/weightmatrix.h
|
||||||
|
|
||||||
noinst_LTLIBRARIES += libtesseract_lstm.la
|
noinst_LTLIBRARIES += libtesseract_lstm.la
|
||||||
@ -556,10 +550,6 @@ libtesseract_lstm_la_SOURCES += src/lstm/reconfig.cpp
|
|||||||
libtesseract_lstm_la_SOURCES += src/lstm/reversed.cpp
|
libtesseract_lstm_la_SOURCES += src/lstm/reversed.cpp
|
||||||
libtesseract_lstm_la_SOURCES += src/lstm/series.cpp
|
libtesseract_lstm_la_SOURCES += src/lstm/series.cpp
|
||||||
libtesseract_lstm_la_SOURCES += src/lstm/stridemap.cpp
|
libtesseract_lstm_la_SOURCES += src/lstm/stridemap.cpp
|
||||||
if TENSORFLOW
|
|
||||||
libtesseract_lstm_la_SOURCES += src/lstm/tfnetwork.cpp
|
|
||||||
libtesseract_lstm_la_SOURCES += src/lstm/tfnetwork.pb.cc
|
|
||||||
endif
|
|
||||||
libtesseract_lstm_la_SOURCES += src/lstm/weightmatrix.cpp
|
libtesseract_lstm_la_SOURCES += src/lstm/weightmatrix.cpp
|
||||||
|
|
||||||
# Rules for src/textord.
|
# Rules for src/textord.
|
||||||
@ -730,7 +720,6 @@ tesseract_LDFLAGS = $(OPENMP_CXXFLAGS)
|
|||||||
|
|
||||||
tesseract_LDADD = libtesseract.la
|
tesseract_LDADD = libtesseract.la
|
||||||
tesseract_LDADD += $(LEPTONICA_LIBS)
|
tesseract_LDADD += $(LEPTONICA_LIBS)
|
||||||
tesseract_LDADD += $(TENSORFLOW_LIBS)
|
|
||||||
tesseract_LDADD += $(libarchive_LIBS)
|
tesseract_LDADD += $(libarchive_LIBS)
|
||||||
tesseract_LDADD += $(libcurl_LIBS)
|
tesseract_LDADD += $(libcurl_LIBS)
|
||||||
|
|
||||||
@ -900,7 +889,6 @@ EXTRA_PROGRAMS += $(trainingtools)
|
|||||||
extralib = libtesseract.la
|
extralib = libtesseract.la
|
||||||
extralib += $(libarchive_LIBS)
|
extralib += $(libarchive_LIBS)
|
||||||
extralib += $(LEPTONICA_LIBS)
|
extralib += $(LEPTONICA_LIBS)
|
||||||
extralib += $(TENSORFLOW_LIBS)
|
|
||||||
if T_WIN
|
if T_WIN
|
||||||
extralib += -lws2_32
|
extralib += -lws2_32
|
||||||
endif
|
endif
|
||||||
@ -1008,7 +996,6 @@ fuzzer-api: unittest/fuzzers/fuzzer-api.cpp
|
|||||||
$< \
|
$< \
|
||||||
$(builddir)/.libs/libtesseract.a \
|
$(builddir)/.libs/libtesseract.a \
|
||||||
$(LEPTONICA_LIBS) \
|
$(LEPTONICA_LIBS) \
|
||||||
$(TENSORFLOW_LIBS) \
|
|
||||||
$(libarchive_LIBS) \
|
$(libarchive_LIBS) \
|
||||||
$(libcurl_LIBS) \
|
$(libcurl_LIBS) \
|
||||||
-o $@
|
-o $@
|
||||||
@ -1028,7 +1015,6 @@ fuzzer-api-512x256: unittest/fuzzers/fuzzer-api.cpp
|
|||||||
$< \
|
$< \
|
||||||
$(builddir)/.libs/libtesseract.a \
|
$(builddir)/.libs/libtesseract.a \
|
||||||
$(LEPTONICA_LIBS) \
|
$(LEPTONICA_LIBS) \
|
||||||
$(TENSORFLOW_LIBS) \
|
|
||||||
$(libarchive_LIBS) \
|
$(libarchive_LIBS) \
|
||||||
$(libcurl_LIBS) \
|
$(libcurl_LIBS) \
|
||||||
-o $@
|
-o $@
|
||||||
@ -1141,10 +1127,6 @@ endif # ENABLE_TRAINING
|
|||||||
unittest_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
unittest_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
||||||
unittest_CPPFLAGS += -I$(top_srcdir)/src/wordrec
|
unittest_CPPFLAGS += -I$(top_srcdir)/src/wordrec
|
||||||
unittest_CPPFLAGS += -I$(top_srcdir)/unittest
|
unittest_CPPFLAGS += -I$(top_srcdir)/unittest
|
||||||
if TENSORFLOW
|
|
||||||
unittest_CPPFLAGS += -DINCLUDE_TENSORFLOW
|
|
||||||
unittest_CPPFLAGS += -I/usr/include/tensorflow
|
|
||||||
endif # TENSORFLOW
|
|
||||||
|
|
||||||
# Build googletest:
|
# Build googletest:
|
||||||
check_LTLIBRARIES = libgtest.la libgtest_main.la libgmock.la libgmock_main.la
|
check_LTLIBRARIES = libgtest.la libgtest_main.la libgmock.la libgmock_main.la
|
||||||
@ -1172,7 +1154,6 @@ GTEST_LIBS = libgtest.la libgtest_main.la -lpthread
|
|||||||
GMOCK_LIBS = libgmock.la libgmock_main.la
|
GMOCK_LIBS = libgmock.la libgmock_main.la
|
||||||
TESS_LIBS = $(GTEST_LIBS)
|
TESS_LIBS = $(GTEST_LIBS)
|
||||||
TESS_LIBS += libtesseract.la $(libarchive_LIBS)
|
TESS_LIBS += libtesseract.la $(libarchive_LIBS)
|
||||||
TESS_LIBS += $(TENSORFLOW_LIBS)
|
|
||||||
TRAINING_LIBS = libtesseract_training.la
|
TRAINING_LIBS = libtesseract_training.la
|
||||||
TRAINING_LIBS += $(TESS_LIBS)
|
TRAINING_LIBS += $(TESS_LIBS)
|
||||||
unittest_CPPFLAGS += -isystem $(top_srcdir)/unittest/third_party/googletest/googletest/include
|
unittest_CPPFLAGS += -isystem $(top_srcdir)/unittest/third_party/googletest/googletest/include
|
||||||
@ -1419,10 +1400,6 @@ networkio_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
|||||||
networkio_test_LDADD = $(TESS_LIBS)
|
networkio_test_LDADD = $(TESS_LIBS)
|
||||||
|
|
||||||
normstrngs_test_SOURCES = unittest/normstrngs_test.cc
|
normstrngs_test_SOURCES = unittest/normstrngs_test.cc
|
||||||
if TENSORFLOW
|
|
||||||
normstrngs_test_SOURCES += unittest/third_party/utf/rune.c
|
|
||||||
normstrngs_test_SOURCES += unittest/util/utf8/unilib.cc
|
|
||||||
endif # TENSORFLOW
|
|
||||||
normstrngs_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
normstrngs_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||||
normstrngs_test_LDADD = $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
|
normstrngs_test_LDADD = $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
|
||||||
|
|
||||||
@ -1441,11 +1418,6 @@ pagesegmode_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
|||||||
pagesegmode_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
|
pagesegmode_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
|
||||||
|
|
||||||
pango_font_info_test_SOURCES = unittest/pango_font_info_test.cc
|
pango_font_info_test_SOURCES = unittest/pango_font_info_test.cc
|
||||||
if TENSORFLOW
|
|
||||||
pango_font_info_test_SOURCES += unittest/third_party/utf/rune.c
|
|
||||||
pango_font_info_test_SOURCES += unittest/util/utf8/unicodetext.cc
|
|
||||||
pango_font_info_test_SOURCES += unittest/util/utf8/unilib.cc
|
|
||||||
endif # TENSORFLOW
|
|
||||||
pango_font_info_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
pango_font_info_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||||
pango_font_info_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
|
pango_font_info_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
|
||||||
pango_font_info_test_LDADD += $(ICU_I18N_LIBS)
|
pango_font_info_test_LDADD += $(ICU_I18N_LIBS)
|
||||||
|
19
configure.ac
19
configure.ac
@ -270,25 +270,6 @@ AC_ARG_WITH([curl],
|
|||||||
AS_HELP_STRING([--with-curl],
|
AS_HELP_STRING([--with-curl],
|
||||||
[Build with libcurl which supports processing an image URL @<:@default=check@:>@]),
|
[Build with libcurl which supports processing an image URL @<:@default=check@:>@]),
|
||||||
[], [with_curl=check])
|
[], [with_curl=check])
|
||||||
AC_ARG_WITH([tensorflow],
|
|
||||||
AS_HELP_STRING([--with-tensorflow],
|
|
||||||
[support TensorFlow @<:@default=check@:>@]),
|
|
||||||
[], [with_tensorflow=check])
|
|
||||||
|
|
||||||
# Check whether to build with support for TensorFlow.
|
|
||||||
AM_CONDITIONAL([TENSORFLOW], false)
|
|
||||||
TENSORFLOW_LIBS=
|
|
||||||
AS_IF([test "x$with_tensorflow" != xno],
|
|
||||||
[AC_CHECK_HEADERS([tensorflow/core/framework/graph.pb.h],
|
|
||||||
[AC_SUBST([TENSORFLOW_LIBS], ["-lprotobuf -ltensorflow_cc"])
|
|
||||||
AM_CONDITIONAL([TENSORFLOW], true)
|
|
||||||
],
|
|
||||||
[if test "x$with_tensorflow" != xcheck; then
|
|
||||||
AC_MSG_FAILURE(
|
|
||||||
[--with-tensorflow was given, but test for libtensorflow-dev failed])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
# https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html
|
# https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html
|
||||||
m4_define([MY_CHECK_FRAMEWORK],
|
m4_define([MY_CHECK_FRAMEWORK],
|
||||||
|
@ -38,9 +38,6 @@
|
|||||||
#include "scrollview.h"
|
#include "scrollview.h"
|
||||||
#include "series.h"
|
#include "series.h"
|
||||||
#include "statistc.h"
|
#include "statistc.h"
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
|
||||||
# include "tfnetwork.h"
|
|
||||||
#endif
|
|
||||||
#include "tprintf.h"
|
#include "tprintf.h"
|
||||||
|
|
||||||
namespace tesseract {
|
namespace tesseract {
|
||||||
@ -287,11 +284,7 @@ Network *Network::CreateFromFile(TFile *fp) {
|
|||||||
network = new Series(name);
|
network = new Series(name);
|
||||||
break;
|
break;
|
||||||
case NT_TENSORFLOW:
|
case NT_TENSORFLOW:
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
tprintf("Unsupported TensorFlow model\n");
|
||||||
network = new TFNetwork(name);
|
|
||||||
#else
|
|
||||||
tprintf("TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
// All variants of FullyConnected.
|
// All variants of FullyConnected.
|
||||||
case NT_SOFTMAX:
|
case NT_SOFTMAX:
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// File: tfnetwork.cpp
|
|
||||||
// Description: Encapsulation of an entire tensorflow graph as a
|
|
||||||
// Tesseract Network.
|
|
||||||
// Author: Ray Smith
|
|
||||||
//
|
|
||||||
// (C) Copyright 2016, Google Inc.
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
|
||||||
|
|
||||||
# include "tfnetwork.h"
|
|
||||||
|
|
||||||
# include <allheaders.h>
|
|
||||||
# include "input.h"
|
|
||||||
# include "networkscratch.h"
|
|
||||||
|
|
||||||
using tensorflow::Status;
|
|
||||||
using tensorflow::Tensor;
|
|
||||||
using tensorflow::TensorShape;
|
|
||||||
|
|
||||||
namespace tesseract {
|
|
||||||
|
|
||||||
TFNetwork::TFNetwork(const std::string &name) : Network(NT_TENSORFLOW, name, 0, 0) {}
|
|
||||||
|
|
||||||
int TFNetwork::InitFromProtoStr(const std::string &proto_str) {
|
|
||||||
if (!model_proto_.ParseFromString(proto_str))
|
|
||||||
return 0;
|
|
||||||
return InitFromProto();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Writes to the given file. Returns false in case of error.
|
|
||||||
// Should be overridden by subclasses, but called by their Serialize.
|
|
||||||
bool TFNetwork::Serialize(TFile *fp) const {
|
|
||||||
if (!Network::Serialize(fp))
|
|
||||||
return false;
|
|
||||||
std::string proto_str;
|
|
||||||
model_proto_.SerializeToString(&proto_str);
|
|
||||||
// TODO: optimize and avoid copy from proto_str to data.
|
|
||||||
std::vector<char> data(proto_str.size());
|
|
||||||
memcpy(&data[0], proto_str.data(), proto_str.size());
|
|
||||||
return fp->Serialize(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reads from the given file. Returns false in case of error.
|
|
||||||
// Should be overridden by subclasses, but NOT called by their DeSerialize.
|
|
||||||
bool TFNetwork::DeSerialize(TFile *fp) {
|
|
||||||
std::vector<char> data;
|
|
||||||
if (!fp->DeSerialize(data))
|
|
||||||
return false;
|
|
||||||
if (!model_proto_.ParseFromArray(&data[0], data.size())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return InitFromProto();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Runs forward propagation of activations on the input line.
|
|
||||||
// See Network for a detailed discussion of the arguments.
|
|
||||||
void TFNetwork::Forward(bool debug, const NetworkIO &input, const TransposedArray *input_transpose,
|
|
||||||
NetworkScratch *scratch, NetworkIO *output) {
|
|
||||||
std::vector<std::pair<std::string, Tensor>> tf_inputs;
|
|
||||||
int depth = input_shape_.depth();
|
|
||||||
ASSERT_HOST(depth == input.NumFeatures());
|
|
||||||
// TODO(rays) Allow batching. For now batch_size = 1.
|
|
||||||
const StrideMap &stride_map = input.stride_map();
|
|
||||||
// TF requires a tensor of shape float[batch, height, width, depth].
|
|
||||||
TensorShape shape{1, stride_map.Size(FD_HEIGHT), stride_map.Size(FD_WIDTH), depth};
|
|
||||||
Tensor input_tensor(tensorflow::DT_FLOAT, shape);
|
|
||||||
// The flat() member gives a 1d array, with a data() member to get the data.
|
|
||||||
auto eigen_tensor = input_tensor.flat<float>();
|
|
||||||
memcpy(eigen_tensor.data(), input.f(0), input.Width() * depth * sizeof(input.f(0)[0]));
|
|
||||||
// Add the tensor to the vector of inputs.
|
|
||||||
tf_inputs.emplace_back(model_proto_.image_input(), input_tensor);
|
|
||||||
|
|
||||||
// Provide tensors giving the width and/or height of the image if they are
|
|
||||||
// required. Some tf ops require a separate tensor with knowledge of the
|
|
||||||
// size of the input as they cannot obtain it from the input tensor. This is
|
|
||||||
// usually true in the case of ops that process a batch of variable-sized
|
|
||||||
// objects.
|
|
||||||
if (!model_proto_.image_widths().empty()) {
|
|
||||||
TensorShape size_shape{1};
|
|
||||||
Tensor width_tensor(tensorflow::DT_INT64, size_shape);
|
|
||||||
auto eigen_wtensor = width_tensor.flat<tensorflow::int64>();
|
|
||||||
*eigen_wtensor.data() = stride_map.Size(FD_WIDTH);
|
|
||||||
tf_inputs.emplace_back(model_proto_.image_widths(), width_tensor);
|
|
||||||
}
|
|
||||||
if (!model_proto_.image_heights().empty()) {
|
|
||||||
TensorShape size_shape{1};
|
|
||||||
Tensor height_tensor(tensorflow::DT_INT64, size_shape);
|
|
||||||
auto eigen_htensor = height_tensor.flat<tensorflow::int64>();
|
|
||||||
*eigen_htensor.data() = stride_map.Size(FD_HEIGHT);
|
|
||||||
tf_inputs.emplace_back(model_proto_.image_heights(), height_tensor);
|
|
||||||
}
|
|
||||||
std::vector<std::string> target_layers = {model_proto_.output_layer()};
|
|
||||||
std::vector<Tensor> outputs;
|
|
||||||
Status s = session_->Run(tf_inputs, target_layers, {}, &outputs);
|
|
||||||
if (!s.ok())
|
|
||||||
tprintf("session->Run failed:%s\n", s.error_message().c_str());
|
|
||||||
ASSERT_HOST(s.ok());
|
|
||||||
ASSERT_HOST(outputs.size() == 1);
|
|
||||||
const Tensor &output_tensor = outputs[0];
|
|
||||||
// Check the dimensions of the output.
|
|
||||||
ASSERT_HOST(output_tensor.shape().dims() == 3);
|
|
||||||
int output_batch = output_tensor.shape().dim_size(0);
|
|
||||||
int output_steps = output_tensor.shape().dim_size(1);
|
|
||||||
int output_depth = output_tensor.shape().dim_size(2);
|
|
||||||
ASSERT_HOST(output_batch == 1);
|
|
||||||
ASSERT_HOST(output_depth == output_shape_.depth());
|
|
||||||
output->Resize2d(false, output_steps, output_depth);
|
|
||||||
auto eigen_output = output_tensor.flat<float>();
|
|
||||||
memcpy(output->f(0), eigen_output.data(), output_steps * output_depth * sizeof(output->f(0)[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
int TFNetwork::InitFromProto() {
|
|
||||||
spec_ = model_proto_.spec();
|
|
||||||
input_shape_.SetShape(model_proto_.batch_size(), std::max(0, model_proto_.y_size()),
|
|
||||||
std::max(0, model_proto_.x_size()), model_proto_.depth());
|
|
||||||
output_shape_.SetShape(model_proto_.batch_size(), 1, 0, model_proto_.num_classes());
|
|
||||||
output_shape_.set_loss_type(model_proto_.using_ctc() ? LT_CTC : LT_SOFTMAX);
|
|
||||||
ni_ = input_shape_.height();
|
|
||||||
no_ = output_shape_.depth();
|
|
||||||
// Initialize the session_ with the graph. Since we can't get the graph
|
|
||||||
// back from the session_, we have to keep the proto as well
|
|
||||||
tensorflow::SessionOptions options;
|
|
||||||
session_.reset(NewSession(options));
|
|
||||||
Status s = session_->Create(model_proto_.graph());
|
|
||||||
if (s.ok())
|
|
||||||
return model_proto_.global_step();
|
|
||||||
tprintf("Session_->Create returned '%s'\n", s.error_message().c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace tesseract
|
|
||||||
|
|
||||||
#endif // ifdef INCLUDE_TENSORFLOW
|
|
@ -1,106 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// File: tfnetwork.h
|
|
||||||
// Description: Encapsulation of an entire tensorflow graph as a
|
|
||||||
// Tesseract Network.
|
|
||||||
// Author: Ray Smith
|
|
||||||
//
|
|
||||||
// (C) Copyright 2016, Google Inc.
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef TESSERACT_LSTM_TFNETWORK_H_
|
|
||||||
#define TESSERACT_LSTM_TFNETWORK_H_
|
|
||||||
|
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
|
||||||
|
|
||||||
# include <memory>
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
# include "network.h"
|
|
||||||
# include "static_shape.h"
|
|
||||||
# include "tensorflow/core/framework/graph.pb.h"
|
|
||||||
# include "tensorflow/core/public/session.h"
|
|
||||||
# include "tfnetwork.pb.h"
|
|
||||||
|
|
||||||
namespace tesseract {
|
|
||||||
|
|
||||||
class TFNetwork : public Network {
|
|
||||||
public:
|
|
||||||
explicit TFNetwork(const std::string &name);
|
|
||||||
virtual ~TFNetwork() = default;
|
|
||||||
|
|
||||||
// Returns the required shape input to the network.
|
|
||||||
StaticShape InputShape() const override {
|
|
||||||
return input_shape_;
|
|
||||||
}
|
|
||||||
// Returns the shape output from the network given an input shape (which may
|
|
||||||
// be partially unknown ie zero).
|
|
||||||
StaticShape OutputShape(const StaticShape &input_shape) const override {
|
|
||||||
return output_shape_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string spec() const override {
|
|
||||||
return spec_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deserializes *this from a serialized TFNetwork proto. Returns 0 if failed,
|
|
||||||
// otherwise the global step of the serialized graph.
|
|
||||||
int InitFromProtoStr(const std::string &proto_str);
|
|
||||||
// The number of classes in this network should be equal to those in the
|
|
||||||
// recoder_ in LSTMRecognizer.
|
|
||||||
int num_classes() const {
|
|
||||||
return output_shape_.depth();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Writes to the given file. Returns false in case of error.
|
|
||||||
// Should be overridden by subclasses, but called by their Serialize.
|
|
||||||
bool Serialize(TFile *fp) const override;
|
|
||||||
// Reads from the given file. Returns false in case of error.
|
|
||||||
// Should be overridden by subclasses, but NOT called by their DeSerialize.
|
|
||||||
bool DeSerialize(TFile *fp) override;
|
|
||||||
|
|
||||||
// Runs forward propagation of activations on the input line.
|
|
||||||
// See Network for a detailed discussion of the arguments.
|
|
||||||
void Forward(bool debug, const NetworkIO &input, const TransposedArray *input_transpose,
|
|
||||||
NetworkScratch *scratch, NetworkIO *output) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Runs backward propagation of errors on the deltas line.
|
|
||||||
// See Network for a detailed discussion of the arguments.
|
|
||||||
bool Backward(bool debug, const NetworkIO &fwd_deltas, NetworkScratch *scratch,
|
|
||||||
NetworkIO *back_deltas) override {
|
|
||||||
tprintf("Must override Network::Backward for type %d\n", type_);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugWeights() override {
|
|
||||||
tprintf("Must override Network::DebugWeights for type %d\n", type_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int InitFromProto();
|
|
||||||
|
|
||||||
// The original network definition for reference.
|
|
||||||
std::string spec_;
|
|
||||||
// Input tensor parameters.
|
|
||||||
StaticShape input_shape_;
|
|
||||||
// Output tensor parameters.
|
|
||||||
StaticShape output_shape_;
|
|
||||||
// The tensor flow graph is contained in here.
|
|
||||||
std::unique_ptr<tensorflow::Session> session_;
|
|
||||||
// The serialized graph is also contained in here.
|
|
||||||
TFNetworkModel model_proto_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace tesseract.
|
|
||||||
|
|
||||||
#endif // ifdef INCLUDE_TENSORFLOW
|
|
||||||
|
|
||||||
#endif // TESSERACT_TENSORFLOW_TFNETWORK_H_
|
|
@ -1,929 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: tfnetwork.proto
|
|
||||||
|
|
||||||
#include "tfnetwork.pb.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <google/protobuf/descriptor.h>
|
|
||||||
#include <google/protobuf/generated_message_reflection.h>
|
|
||||||
#include <google/protobuf/io/coded_stream.h>
|
|
||||||
#include <google/protobuf/reflection_ops.h>
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
|
||||||
#include <google/protobuf/stubs/port.h>
|
|
||||||
#include <google/protobuf/wire_format.h>
|
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
|
||||||
// This is a temporary google only hack
|
|
||||||
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
|
||||||
# include "third_party/protobuf/version.h"
|
|
||||||
#endif
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
|
|
||||||
namespace protobuf_tensorflow_2fcore_2fframework_2fgraph_2eproto {
|
|
||||||
extern PROTOBUF_INTERNAL_EXPORT_protobuf_tensorflow_2fcore_2fframework_2fgraph_2eproto ::google::
|
|
||||||
protobuf::internal::SCCInfo<3>
|
|
||||||
scc_info_GraphDef;
|
|
||||||
} // namespace protobuf_tensorflow_2fcore_2fframework_2fgraph_2eproto
|
|
||||||
namespace tesseract {
|
|
||||||
class TFNetworkModelDefaultTypeInternal {
|
|
||||||
public:
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<TFNetworkModel> _instance;
|
|
||||||
} _TFNetworkModel_default_instance_;
|
|
||||||
} // namespace tesseract
|
|
||||||
namespace protobuf_tfnetwork_2eproto {
|
|
||||||
static void InitDefaultsTFNetworkModel() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
{
|
|
||||||
void *ptr = &::tesseract::_TFNetworkModel_default_instance_;
|
|
||||||
new (ptr)::tesseract::TFNetworkModel();
|
|
||||||
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
|
||||||
}
|
|
||||||
::tesseract::TFNetworkModel::InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::internal::SCCInfo<1> scc_info_TFNetworkModel = {
|
|
||||||
{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1,
|
|
||||||
InitDefaultsTFNetworkModel},
|
|
||||||
{
|
|
||||||
&protobuf_tensorflow_2fcore_2fframework_2fgraph_2eproto::scc_info_GraphDef.base,
|
|
||||||
}};
|
|
||||||
|
|
||||||
void InitDefaults() {
|
|
||||||
::google::protobuf::internal::InitSCC(&scc_info_TFNetworkModel.base);
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::Metadata file_level_metadata[1];
|
|
||||||
|
|
||||||
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(
|
|
||||||
protodesc_cold) = {
|
|
||||||
~0u, // no _has_bits_
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel,
|
|
||||||
_internal_metadata_),
|
|
||||||
~0u, // no _extensions_
|
|
||||||
~0u, // no _oneof_case_
|
|
||||||
~0u, // no _weak_field_map_
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, graph_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, global_step_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, spec_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, depth_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, x_size_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, y_size_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, batch_size_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, num_classes_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, using_ctc_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, image_input_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, image_widths_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, image_heights_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::tesseract::TFNetworkModel, output_layer_),
|
|
||||||
};
|
|
||||||
static const ::google::protobuf::internal::MigrationSchema
|
|
||||||
schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
|
||||||
{0, -1, sizeof(::tesseract::TFNetworkModel)},
|
|
||||||
};
|
|
||||||
|
|
||||||
static ::google::protobuf::Message const *const file_default_instances[] = {
|
|
||||||
reinterpret_cast<const ::google::protobuf::Message *>(
|
|
||||||
&::tesseract::_TFNetworkModel_default_instance_),
|
|
||||||
};
|
|
||||||
|
|
||||||
void protobuf_AssignDescriptors() {
|
|
||||||
AddDescriptors();
|
|
||||||
AssignDescriptors("tfnetwork.proto", schemas, file_default_instances, TableStruct::offsets,
|
|
||||||
file_level_metadata, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
static ::google::protobuf::internal::once_flag once;
|
|
||||||
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string &) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string &) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddDescriptorsImpl() {
|
|
||||||
InitDefaults();
|
|
||||||
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
|
||||||
"\n\017tfnetwork.proto\022\ttesseract\032%tensorflow"
|
|
||||||
"/core/framework/graph.proto\"\233\002\n\016TFNetwor"
|
|
||||||
"kModel\022#\n\005graph\030\001 \001(\0132\024.tensorflow.Graph"
|
|
||||||
"Def\022\023\n\013global_step\030\002 \001(\003\022\014\n\004spec\030\003 \001(\t\022\r"
|
|
||||||
"\n\005depth\030\004 \001(\005\022\016\n\006x_size\030\005 \001(\005\022\016\n\006y_size\030"
|
|
||||||
"\006 \001(\005\022\022\n\nbatch_size\030\010 \001(\005\022\023\n\013num_classes"
|
|
||||||
"\030\t \001(\005\022\021\n\tusing_ctc\030\n \001(\010\022\023\n\013image_input"
|
|
||||||
"\030\013 \001(\t\022\024\n\014image_widths\030\014 \001(\t\022\025\n\rimage_he"
|
|
||||||
"ights\030\r \001(\t\022\024\n\014output_layer\030\016 \001(\tb\006proto"
|
|
||||||
"3"};
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, 361);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile("tfnetwork.proto",
|
|
||||||
&protobuf_RegisterTypes);
|
|
||||||
::protobuf_tensorflow_2fcore_2fframework_2fgraph_2eproto::AddDescriptors();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddDescriptors() {
|
|
||||||
static ::google::protobuf::internal::once_flag once;
|
|
||||||
::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at dynamic initialization time.
|
|
||||||
struct StaticDescriptorInitializer {
|
|
||||||
StaticDescriptorInitializer() {
|
|
||||||
AddDescriptors();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer;
|
|
||||||
} // namespace protobuf_tfnetwork_2eproto
|
|
||||||
namespace tesseract {
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
void TFNetworkModel::InitAsDefaultInstance() {
|
|
||||||
::tesseract::_TFNetworkModel_default_instance_._instance.get_mutable()->graph_ =
|
|
||||||
const_cast<::tensorflow::GraphDef *>(::tensorflow::GraphDef::internal_default_instance());
|
|
||||||
}
|
|
||||||
void TFNetworkModel::clear_graph() {
|
|
||||||
if (GetArenaNoVirtual() == NULL && graph_ != NULL) {
|
|
||||||
delete graph_;
|
|
||||||
}
|
|
||||||
graph_ = NULL;
|
|
||||||
}
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
|
||||||
const int TFNetworkModel::kGraphFieldNumber;
|
|
||||||
const int TFNetworkModel::kGlobalStepFieldNumber;
|
|
||||||
const int TFNetworkModel::kSpecFieldNumber;
|
|
||||||
const int TFNetworkModel::kDepthFieldNumber;
|
|
||||||
const int TFNetworkModel::kXSizeFieldNumber;
|
|
||||||
const int TFNetworkModel::kYSizeFieldNumber;
|
|
||||||
const int TFNetworkModel::kBatchSizeFieldNumber;
|
|
||||||
const int TFNetworkModel::kNumClassesFieldNumber;
|
|
||||||
const int TFNetworkModel::kUsingCtcFieldNumber;
|
|
||||||
const int TFNetworkModel::kImageInputFieldNumber;
|
|
||||||
const int TFNetworkModel::kImageWidthsFieldNumber;
|
|
||||||
const int TFNetworkModel::kImageHeightsFieldNumber;
|
|
||||||
const int TFNetworkModel::kOutputLayerFieldNumber;
|
|
||||||
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
|
||||||
|
|
||||||
TFNetworkModel::TFNetworkModel() : ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
|
||||||
::google::protobuf::internal::InitSCC(&protobuf_tfnetwork_2eproto::scc_info_TFNetworkModel.base);
|
|
||||||
SharedCtor();
|
|
||||||
// @@protoc_insertion_point(constructor:tesseract.TFNetworkModel)
|
|
||||||
}
|
|
||||||
TFNetworkModel::TFNetworkModel(const TFNetworkModel &from)
|
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
|
||||||
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
|
||||||
spec_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (from.spec().size() > 0) {
|
|
||||||
spec_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.spec_);
|
|
||||||
}
|
|
||||||
image_input_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (from.image_input().size() > 0) {
|
|
||||||
image_input_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_input_);
|
|
||||||
}
|
|
||||||
image_widths_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (from.image_widths().size() > 0) {
|
|
||||||
image_widths_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_widths_);
|
|
||||||
}
|
|
||||||
image_heights_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (from.image_heights().size() > 0) {
|
|
||||||
image_heights_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_heights_);
|
|
||||||
}
|
|
||||||
output_layer_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (from.output_layer().size() > 0) {
|
|
||||||
output_layer_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.output_layer_);
|
|
||||||
}
|
|
||||||
if (from.has_graph()) {
|
|
||||||
graph_ = new ::tensorflow::GraphDef(*from.graph_);
|
|
||||||
} else {
|
|
||||||
graph_ = NULL;
|
|
||||||
}
|
|
||||||
::memcpy(&global_step_, &from.global_step_,
|
|
||||||
static_cast<size_t>(reinterpret_cast<char *>(&using_ctc_) -
|
|
||||||
reinterpret_cast<char *>(&global_step_)) +
|
|
||||||
sizeof(using_ctc_));
|
|
||||||
// @@protoc_insertion_point(copy_constructor:tesseract.TFNetworkModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::SharedCtor() {
|
|
||||||
spec_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_input_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_widths_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_heights_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
output_layer_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
::memset(&graph_, 0,
|
|
||||||
static_cast<size_t>(reinterpret_cast<char *>(&using_ctc_) -
|
|
||||||
reinterpret_cast<char *>(&graph_)) +
|
|
||||||
sizeof(using_ctc_));
|
|
||||||
}
|
|
||||||
|
|
||||||
TFNetworkModel::~TFNetworkModel() {
|
|
||||||
// @@protoc_insertion_point(destructor:tesseract.TFNetworkModel)
|
|
||||||
SharedDtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::SharedDtor() {
|
|
||||||
spec_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_input_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_widths_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_heights_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
output_layer_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (this != internal_default_instance())
|
|
||||||
delete graph_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::SetCachedSize(int size) const {
|
|
||||||
_cached_size_.Set(size);
|
|
||||||
}
|
|
||||||
const ::google::protobuf::Descriptor *TFNetworkModel::descriptor() {
|
|
||||||
::protobuf_tfnetwork_2eproto::protobuf_AssignDescriptorsOnce();
|
|
||||||
return ::protobuf_tfnetwork_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TFNetworkModel &TFNetworkModel::default_instance() {
|
|
||||||
::google::protobuf::internal::InitSCC(&protobuf_tfnetwork_2eproto::scc_info_TFNetworkModel.base);
|
|
||||||
return *internal_default_instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::Clear() {
|
|
||||||
// @@protoc_insertion_point(message_clear_start:tesseract.TFNetworkModel)
|
|
||||||
::google::protobuf::uint32 cached_has_bits = 0;
|
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
|
||||||
(void)cached_has_bits;
|
|
||||||
|
|
||||||
spec_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_input_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_widths_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
image_heights_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
output_layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
if (GetArenaNoVirtual() == NULL && graph_ != NULL) {
|
|
||||||
delete graph_;
|
|
||||||
}
|
|
||||||
graph_ = NULL;
|
|
||||||
::memset(&global_step_, 0,
|
|
||||||
static_cast<size_t>(reinterpret_cast<char *>(&using_ctc_) -
|
|
||||||
reinterpret_cast<char *>(&global_step_)) +
|
|
||||||
sizeof(using_ctc_));
|
|
||||||
_internal_metadata_.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TFNetworkModel::MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream *input) {
|
|
||||||
#define DO_(EXPRESSION) \
|
|
||||||
if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) \
|
|
||||||
goto failure
|
|
||||||
::google::protobuf::uint32 tag;
|
|
||||||
// @@protoc_insertion_point(parse_start:tesseract.TFNetworkModel)
|
|
||||||
for (;;) {
|
|
||||||
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
|
||||||
tag = p.first;
|
|
||||||
if (!p.second)
|
|
||||||
goto handle_unusual;
|
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
case 1: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, mutable_graph()));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
case 2: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
|
|
||||||
input, &global_step_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string spec = 3;
|
|
||||||
case 3: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(input,
|
|
||||||
this->mutable_spec()));
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->spec().data(), static_cast<int>(this->spec().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
|
||||||
"tesseract.TFNetworkModel.spec"));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
case 4: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &depth_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
case 5: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &x_size_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
case 6: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &y_size_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
case 8: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(64u /* 64 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &batch_size_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
case 9: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(72u /* 72 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &num_classes_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
case 10: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(80u /* 80 & 0xFF */)) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(input, &using_ctc_)));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
case 11: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(90u /* 90 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
|
||||||
input, this->mutable_image_input()));
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_input().data(), static_cast<int>(this->image_input().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
|
||||||
"tesseract.TFNetworkModel.image_input"));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
case 12: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(98u /* 98 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
|
||||||
input, this->mutable_image_widths()));
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_widths().data(), static_cast<int>(this->image_widths().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
|
||||||
"tesseract.TFNetworkModel.image_widths"));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
case 13: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(106u /* 106 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
|
||||||
input, this->mutable_image_heights()));
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_heights().data(), static_cast<int>(this->image_heights().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
|
||||||
"tesseract.TFNetworkModel.image_heights"));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
case 14: {
|
|
||||||
if (static_cast<::google::protobuf::uint8>(tag) ==
|
|
||||||
static_cast<::google::protobuf::uint8>(114u /* 114 & 0xFF */)) {
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
|
||||||
input, this->mutable_output_layer()));
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->output_layer().data(), static_cast<int>(this->output_layer().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
|
||||||
"tesseract.TFNetworkModel.output_layer"));
|
|
||||||
} else {
|
|
||||||
goto handle_unusual;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
handle_unusual:
|
|
||||||
if (tag == 0) {
|
|
||||||
goto success;
|
|
||||||
}
|
|
||||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
|
||||||
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
success:
|
|
||||||
// @@protoc_insertion_point(parse_success:tesseract.TFNetworkModel)
|
|
||||||
return true;
|
|
||||||
failure:
|
|
||||||
// @@protoc_insertion_point(parse_failure:tesseract.TFNetworkModel)
|
|
||||||
return false;
|
|
||||||
#undef DO_
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::SerializeWithCachedSizes(
|
|
||||||
::google::protobuf::io::CodedOutputStream *output) const {
|
|
||||||
// @@protoc_insertion_point(serialize_start:tesseract.TFNetworkModel)
|
|
||||||
::google::protobuf::uint32 cached_has_bits = 0;
|
|
||||||
(void)cached_has_bits;
|
|
||||||
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
if (this->has_graph()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
|
|
||||||
1, this->_internal_graph(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
if (this->global_step() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->global_step(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string spec = 3;
|
|
||||||
if (this->spec().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->spec().data(), static_cast<int>(this->spec().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE, "tesseract.TFNetworkModel.spec");
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(3, this->spec(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
if (this->depth() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->depth(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
if (this->x_size() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->x_size(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
if (this->y_size() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->y_size(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
if (this->batch_size() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(8, this->batch_size(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
if (this->num_classes() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(9, this->num_classes(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
if (this->using_ctc() != 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteBool(10, this->using_ctc(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
if (this->image_input().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_input().data(), static_cast<int>(this->image_input().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_input");
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(11, this->image_input(),
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
if (this->image_widths().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_widths().data(), static_cast<int>(this->image_widths().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_widths");
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(12, this->image_widths(),
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
if (this->image_heights().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_heights().data(), static_cast<int>(this->image_heights().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_heights");
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(13, this->image_heights(),
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
if (this->output_layer().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->output_layer().data(), static_cast<int>(this->output_layer().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.output_layer");
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(14, this->output_layer(),
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_internal_metadata_.have_unknown_fields() &&
|
|
||||||
::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
|
||||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
|
||||||
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault()
|
|
||||||
? _internal_metadata_.unknown_fields()
|
|
||||||
: _internal_metadata_.default_instance()),
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(serialize_end:tesseract.TFNetworkModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::uint8 *TFNetworkModel::InternalSerializeWithCachedSizesToArray(
|
|
||||||
bool deterministic, ::google::protobuf::uint8 *target) const {
|
|
||||||
(void)deterministic; // Unused
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:tesseract.TFNetworkModel)
|
|
||||||
::google::protobuf::uint32 cached_has_bits = 0;
|
|
||||||
(void)cached_has_bits;
|
|
||||||
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
if (this->has_graph()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessageToArray(
|
|
||||||
1, this->_internal_graph(), deterministic, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
if (this->global_step() != 0) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(2, this->global_step(),
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string spec = 3;
|
|
||||||
if (this->spec().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->spec().data(), static_cast<int>(this->spec().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE, "tesseract.TFNetworkModel.spec");
|
|
||||||
target =
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringToArray(3, this->spec(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
if (this->depth() != 0) {
|
|
||||||
target =
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->depth(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
if (this->x_size() != 0) {
|
|
||||||
target =
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->x_size(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
if (this->y_size() != 0) {
|
|
||||||
target =
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->y_size(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
if (this->batch_size() != 0) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(8, this->batch_size(),
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
if (this->num_classes() != 0) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(9, this->num_classes(),
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
if (this->using_ctc() != 0) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->using_ctc(),
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
if (this->image_input().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_input().data(), static_cast<int>(this->image_input().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_input");
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
|
|
||||||
11, this->image_input(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
if (this->image_widths().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_widths().data(), static_cast<int>(this->image_widths().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_widths");
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
|
|
||||||
12, this->image_widths(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
if (this->image_heights().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->image_heights().data(), static_cast<int>(this->image_heights().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.image_heights");
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
|
|
||||||
13, this->image_heights(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
if (this->output_layer().size() > 0) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->output_layer().data(), static_cast<int>(this->output_layer().length()),
|
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"tesseract.TFNetworkModel.output_layer");
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
|
|
||||||
14, this->output_layer(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_internal_metadata_.have_unknown_fields() &&
|
|
||||||
::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
|
||||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
|
||||||
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault()
|
|
||||||
? _internal_metadata_.unknown_fields()
|
|
||||||
: _internal_metadata_.default_instance()),
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:tesseract.TFNetworkModel)
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t TFNetworkModel::ByteSizeLong() const {
|
|
||||||
// @@protoc_insertion_point(message_byte_size_start:tesseract.TFNetworkModel)
|
|
||||||
size_t total_size = 0;
|
|
||||||
|
|
||||||
if ((_internal_metadata_.have_unknown_fields() &&
|
|
||||||
::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
|
||||||
total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
|
||||||
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault()
|
|
||||||
? _internal_metadata_.unknown_fields()
|
|
||||||
: _internal_metadata_.default_instance()));
|
|
||||||
}
|
|
||||||
// string spec = 3;
|
|
||||||
if (this->spec().size() > 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(this->spec());
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
if (this->image_input().size() > 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(this->image_input());
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
if (this->image_widths().size() > 0) {
|
|
||||||
total_size +=
|
|
||||||
1 + ::google::protobuf::internal::WireFormatLite::StringSize(this->image_widths());
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
if (this->image_heights().size() > 0) {
|
|
||||||
total_size +=
|
|
||||||
1 + ::google::protobuf::internal::WireFormatLite::StringSize(this->image_heights());
|
|
||||||
}
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
if (this->output_layer().size() > 0) {
|
|
||||||
total_size +=
|
|
||||||
1 + ::google::protobuf::internal::WireFormatLite::StringSize(this->output_layer());
|
|
||||||
}
|
|
||||||
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
if (this->has_graph()) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSize(*graph_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
if (this->global_step() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size(this->global_step());
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
if (this->depth() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(this->depth());
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
if (this->x_size() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(this->x_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
if (this->y_size() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(this->y_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
if (this->batch_size() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(this->batch_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
if (this->num_classes() != 0) {
|
|
||||||
total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(this->num_classes());
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
if (this->using_ctc() != 0) {
|
|
||||||
total_size += 1 + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
|
|
||||||
SetCachedSize(cached_size);
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::MergeFrom(const ::google::protobuf::Message &from) {
|
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:tesseract.TFNetworkModel)
|
|
||||||
GOOGLE_DCHECK_NE(&from, this);
|
|
||||||
const TFNetworkModel *source =
|
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const TFNetworkModel>(&from);
|
|
||||||
if (source == NULL) {
|
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tesseract.TFNetworkModel)
|
|
||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
|
||||||
} else {
|
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:tesseract.TFNetworkModel)
|
|
||||||
MergeFrom(*source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::MergeFrom(const TFNetworkModel &from) {
|
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:tesseract.TFNetworkModel)
|
|
||||||
GOOGLE_DCHECK_NE(&from, this);
|
|
||||||
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
|
||||||
::google::protobuf::uint32 cached_has_bits = 0;
|
|
||||||
(void)cached_has_bits;
|
|
||||||
|
|
||||||
if (from.spec().size() > 0) {
|
|
||||||
spec_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.spec_);
|
|
||||||
}
|
|
||||||
if (from.image_input().size() > 0) {
|
|
||||||
image_input_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_input_);
|
|
||||||
}
|
|
||||||
if (from.image_widths().size() > 0) {
|
|
||||||
image_widths_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_widths_);
|
|
||||||
}
|
|
||||||
if (from.image_heights().size() > 0) {
|
|
||||||
image_heights_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.image_heights_);
|
|
||||||
}
|
|
||||||
if (from.output_layer().size() > 0) {
|
|
||||||
output_layer_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
from.output_layer_);
|
|
||||||
}
|
|
||||||
if (from.has_graph()) {
|
|
||||||
mutable_graph()->::tensorflow::GraphDef::MergeFrom(from.graph());
|
|
||||||
}
|
|
||||||
if (from.global_step() != 0) {
|
|
||||||
set_global_step(from.global_step());
|
|
||||||
}
|
|
||||||
if (from.depth() != 0) {
|
|
||||||
set_depth(from.depth());
|
|
||||||
}
|
|
||||||
if (from.x_size() != 0) {
|
|
||||||
set_x_size(from.x_size());
|
|
||||||
}
|
|
||||||
if (from.y_size() != 0) {
|
|
||||||
set_y_size(from.y_size());
|
|
||||||
}
|
|
||||||
if (from.batch_size() != 0) {
|
|
||||||
set_batch_size(from.batch_size());
|
|
||||||
}
|
|
||||||
if (from.num_classes() != 0) {
|
|
||||||
set_num_classes(from.num_classes());
|
|
||||||
}
|
|
||||||
if (from.using_ctc() != 0) {
|
|
||||||
set_using_ctc(from.using_ctc());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::CopyFrom(const ::google::protobuf::Message &from) {
|
|
||||||
// @@protoc_insertion_point(generalized_copy_from_start:tesseract.TFNetworkModel)
|
|
||||||
if (&from == this)
|
|
||||||
return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::CopyFrom(const TFNetworkModel &from) {
|
|
||||||
// @@protoc_insertion_point(class_specific_copy_from_start:tesseract.TFNetworkModel)
|
|
||||||
if (&from == this)
|
|
||||||
return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TFNetworkModel::IsInitialized() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFNetworkModel::Swap(TFNetworkModel *other) {
|
|
||||||
if (other == this)
|
|
||||||
return;
|
|
||||||
InternalSwap(other);
|
|
||||||
}
|
|
||||||
void TFNetworkModel::InternalSwap(TFNetworkModel *other) {
|
|
||||||
using std::swap;
|
|
||||||
spec_.Swap(&other->spec_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
image_input_.Swap(&other->image_input_,
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
image_widths_.Swap(&other->image_widths_,
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
image_heights_.Swap(&other->image_heights_,
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
output_layer_.Swap(&other->output_layer_,
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
swap(graph_, other->graph_);
|
|
||||||
swap(global_step_, other->global_step_);
|
|
||||||
swap(depth_, other->depth_);
|
|
||||||
swap(x_size_, other->x_size_);
|
|
||||||
swap(y_size_, other->y_size_);
|
|
||||||
swap(batch_size_, other->batch_size_);
|
|
||||||
swap(num_classes_, other->num_classes_);
|
|
||||||
swap(using_ctc_, other->using_ctc_);
|
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::Metadata TFNetworkModel::GetMetadata() const {
|
|
||||||
protobuf_tfnetwork_2eproto::protobuf_AssignDescriptorsOnce();
|
|
||||||
return ::protobuf_tfnetwork_2eproto::file_level_metadata[kIndexInFileMessages];
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
} // namespace tesseract
|
|
||||||
namespace google {
|
|
||||||
namespace protobuf {
|
|
||||||
template <>
|
|
||||||
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::tesseract::TFNetworkModel *
|
|
||||||
Arena::CreateMaybeMessage<::tesseract::TFNetworkModel>(Arena *arena) {
|
|
||||||
return Arena::CreateInternal<::tesseract::TFNetworkModel>(arena);
|
|
||||||
}
|
|
||||||
} // namespace protobuf
|
|
||||||
} // namespace google
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
@ -1,703 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: tfnetwork.proto
|
|
||||||
|
|
||||||
#ifndef PROTOBUF_INCLUDED_tfnetwork_2eproto
|
|
||||||
#define PROTOBUF_INCLUDED_tfnetwork_2eproto
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3006001
|
|
||||||
# error This file was generated by a newer version of protoc which is
|
|
||||||
# error incompatible with your Protocol Buffer headers. Please update
|
|
||||||
# error your headers.
|
|
||||||
#endif
|
|
||||||
#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
|
||||||
# error This file was generated by an older version of protoc which is
|
|
||||||
# error incompatible with your Protocol Buffer headers. Please
|
|
||||||
# error regenerate this file with a newer version of protoc.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <google/protobuf/arena.h>
|
|
||||||
#include <google/protobuf/arenastring.h>
|
|
||||||
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
|
||||||
#include <google/protobuf/generated_message_table_driven.h>
|
|
||||||
#include <google/protobuf/generated_message_util.h>
|
|
||||||
#include <google/protobuf/inlined_string_field.h>
|
|
||||||
#include <google/protobuf/io/coded_stream.h>
|
|
||||||
#include <google/protobuf/message.h>
|
|
||||||
#include <google/protobuf/metadata.h>
|
|
||||||
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
|
||||||
#include "tensorflow/core/framework/graph.pb.h"
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
#define PROTOBUF_INTERNAL_EXPORT_protobuf_tfnetwork_2eproto
|
|
||||||
|
|
||||||
namespace protobuf_tfnetwork_2eproto {
|
|
||||||
// Internal implementation detail -- do not use these members.
|
|
||||||
struct TableStruct {
|
|
||||||
static const ::google::protobuf::internal::ParseTableField entries[];
|
|
||||||
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
|
||||||
static const ::google::protobuf::internal::ParseTable schema[1];
|
|
||||||
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
|
||||||
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
|
||||||
static const ::google::protobuf::uint32 offsets[];
|
|
||||||
};
|
|
||||||
void AddDescriptors();
|
|
||||||
} // namespace protobuf_tfnetwork_2eproto
|
|
||||||
namespace tesseract {
|
|
||||||
class TFNetworkModel;
|
|
||||||
class TFNetworkModelDefaultTypeInternal;
|
|
||||||
extern TFNetworkModelDefaultTypeInternal _TFNetworkModel_default_instance_;
|
|
||||||
} // namespace tesseract
|
|
||||||
namespace google {
|
|
||||||
namespace protobuf {
|
|
||||||
template <>
|
|
||||||
::tesseract::TFNetworkModel *Arena::CreateMaybeMessage<::tesseract::TFNetworkModel>(Arena *);
|
|
||||||
} // namespace protobuf
|
|
||||||
} // namespace google
|
|
||||||
namespace tesseract {
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class TFNetworkModel
|
|
||||||
: public ::google::protobuf::
|
|
||||||
Message /* @@protoc_insertion_point(class_definition:tesseract.TFNetworkModel)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TFNetworkModel();
|
|
||||||
virtual ~TFNetworkModel();
|
|
||||||
|
|
||||||
TFNetworkModel(const TFNetworkModel &from);
|
|
||||||
|
|
||||||
inline TFNetworkModel &operator=(const TFNetworkModel &from) {
|
|
||||||
CopyFrom(from);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
TFNetworkModel(TFNetworkModel &&from) noexcept : TFNetworkModel() {
|
|
||||||
*this = ::std::move(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline TFNetworkModel &operator=(TFNetworkModel &&from) noexcept {
|
|
||||||
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
|
||||||
if (this != &from)
|
|
||||||
InternalSwap(&from);
|
|
||||||
} else {
|
|
||||||
CopyFrom(from);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
static const ::google::protobuf::Descriptor *descriptor();
|
|
||||||
static const TFNetworkModel &default_instance();
|
|
||||||
|
|
||||||
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
|
||||||
static inline const TFNetworkModel *internal_default_instance() {
|
|
||||||
return reinterpret_cast<const TFNetworkModel *>(&_TFNetworkModel_default_instance_);
|
|
||||||
}
|
|
||||||
static constexpr int kIndexInFileMessages = 0;
|
|
||||||
|
|
||||||
void Swap(TFNetworkModel *other);
|
|
||||||
friend void swap(TFNetworkModel &a, TFNetworkModel &b) {
|
|
||||||
a.Swap(&b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
|
||||||
|
|
||||||
inline TFNetworkModel *New() const final {
|
|
||||||
return CreateMaybeMessage<TFNetworkModel>(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
TFNetworkModel *New(::google::protobuf::Arena *arena) const final {
|
|
||||||
return CreateMaybeMessage<TFNetworkModel>(arena);
|
|
||||||
}
|
|
||||||
void CopyFrom(const ::google::protobuf::Message &from) final;
|
|
||||||
void MergeFrom(const ::google::protobuf::Message &from) final;
|
|
||||||
void CopyFrom(const TFNetworkModel &from);
|
|
||||||
void MergeFrom(const TFNetworkModel &from);
|
|
||||||
void Clear() final;
|
|
||||||
bool IsInitialized() const final;
|
|
||||||
|
|
||||||
size_t ByteSizeLong() const final;
|
|
||||||
bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream *input) final;
|
|
||||||
void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream *output) const final;
|
|
||||||
::google::protobuf::uint8 *InternalSerializeWithCachedSizesToArray(
|
|
||||||
bool deterministic, ::google::protobuf::uint8 *target) const final;
|
|
||||||
int GetCachedSize() const final {
|
|
||||||
return _cached_size_.Get();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SharedCtor();
|
|
||||||
void SharedDtor();
|
|
||||||
void SetCachedSize(int size) const final;
|
|
||||||
void InternalSwap(TFNetworkModel *other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
inline ::google::protobuf::Arena *GetArenaNoVirtual() const {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
inline void *MaybeArenaPtr() const {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
::google::protobuf::Metadata GetMetadata() const final;
|
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
|
||||||
|
|
||||||
// string spec = 3;
|
|
||||||
void clear_spec();
|
|
||||||
static const int kSpecFieldNumber = 3;
|
|
||||||
const ::std::string &spec() const;
|
|
||||||
void set_spec(const ::std::string &value);
|
|
||||||
#if LANG_CXX11
|
|
||||||
void set_spec(::std::string &&value);
|
|
||||||
#endif
|
|
||||||
void set_spec(const char *value);
|
|
||||||
void set_spec(const char *value, size_t size);
|
|
||||||
::std::string *mutable_spec();
|
|
||||||
::std::string *release_spec();
|
|
||||||
void set_allocated_spec(::std::string *spec);
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
void clear_image_input();
|
|
||||||
static const int kImageInputFieldNumber = 11;
|
|
||||||
const ::std::string &image_input() const;
|
|
||||||
void set_image_input(const ::std::string &value);
|
|
||||||
#if LANG_CXX11
|
|
||||||
void set_image_input(::std::string &&value);
|
|
||||||
#endif
|
|
||||||
void set_image_input(const char *value);
|
|
||||||
void set_image_input(const char *value, size_t size);
|
|
||||||
::std::string *mutable_image_input();
|
|
||||||
::std::string *release_image_input();
|
|
||||||
void set_allocated_image_input(::std::string *image_input);
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
void clear_image_widths();
|
|
||||||
static const int kImageWidthsFieldNumber = 12;
|
|
||||||
const ::std::string &image_widths() const;
|
|
||||||
void set_image_widths(const ::std::string &value);
|
|
||||||
#if LANG_CXX11
|
|
||||||
void set_image_widths(::std::string &&value);
|
|
||||||
#endif
|
|
||||||
void set_image_widths(const char *value);
|
|
||||||
void set_image_widths(const char *value, size_t size);
|
|
||||||
::std::string *mutable_image_widths();
|
|
||||||
::std::string *release_image_widths();
|
|
||||||
void set_allocated_image_widths(::std::string *image_widths);
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
void clear_image_heights();
|
|
||||||
static const int kImageHeightsFieldNumber = 13;
|
|
||||||
const ::std::string &image_heights() const;
|
|
||||||
void set_image_heights(const ::std::string &value);
|
|
||||||
#if LANG_CXX11
|
|
||||||
void set_image_heights(::std::string &&value);
|
|
||||||
#endif
|
|
||||||
void set_image_heights(const char *value);
|
|
||||||
void set_image_heights(const char *value, size_t size);
|
|
||||||
::std::string *mutable_image_heights();
|
|
||||||
::std::string *release_image_heights();
|
|
||||||
void set_allocated_image_heights(::std::string *image_heights);
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
void clear_output_layer();
|
|
||||||
static const int kOutputLayerFieldNumber = 14;
|
|
||||||
const ::std::string &output_layer() const;
|
|
||||||
void set_output_layer(const ::std::string &value);
|
|
||||||
#if LANG_CXX11
|
|
||||||
void set_output_layer(::std::string &&value);
|
|
||||||
#endif
|
|
||||||
void set_output_layer(const char *value);
|
|
||||||
void set_output_layer(const char *value, size_t size);
|
|
||||||
::std::string *mutable_output_layer();
|
|
||||||
::std::string *release_output_layer();
|
|
||||||
void set_allocated_output_layer(::std::string *output_layer);
|
|
||||||
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
bool has_graph() const;
|
|
||||||
void clear_graph();
|
|
||||||
static const int kGraphFieldNumber = 1;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const ::tensorflow::GraphDef &_internal_graph() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
const ::tensorflow::GraphDef &graph() const;
|
|
||||||
::tensorflow::GraphDef *release_graph();
|
|
||||||
::tensorflow::GraphDef *mutable_graph();
|
|
||||||
void set_allocated_graph(::tensorflow::GraphDef *graph);
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
void clear_global_step();
|
|
||||||
static const int kGlobalStepFieldNumber = 2;
|
|
||||||
::google::protobuf::int64 global_step() const;
|
|
||||||
void set_global_step(::google::protobuf::int64 value);
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
void clear_depth();
|
|
||||||
static const int kDepthFieldNumber = 4;
|
|
||||||
::google::protobuf::int32 depth() const;
|
|
||||||
void set_depth(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
void clear_x_size();
|
|
||||||
static const int kXSizeFieldNumber = 5;
|
|
||||||
::google::protobuf::int32 x_size() const;
|
|
||||||
void set_x_size(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
void clear_y_size();
|
|
||||||
static const int kYSizeFieldNumber = 6;
|
|
||||||
::google::protobuf::int32 y_size() const;
|
|
||||||
void set_y_size(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
void clear_batch_size();
|
|
||||||
static const int kBatchSizeFieldNumber = 8;
|
|
||||||
::google::protobuf::int32 batch_size() const;
|
|
||||||
void set_batch_size(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
void clear_num_classes();
|
|
||||||
static const int kNumClassesFieldNumber = 9;
|
|
||||||
::google::protobuf::int32 num_classes() const;
|
|
||||||
void set_num_classes(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
void clear_using_ctc();
|
|
||||||
static const int kUsingCtcFieldNumber = 10;
|
|
||||||
bool using_ctc() const;
|
|
||||||
void set_using_ctc(bool value);
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(class_scope:tesseract.TFNetworkModel)
|
|
||||||
private:
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
|
||||||
::google::protobuf::internal::ArenaStringPtr spec_;
|
|
||||||
::google::protobuf::internal::ArenaStringPtr image_input_;
|
|
||||||
::google::protobuf::internal::ArenaStringPtr image_widths_;
|
|
||||||
::google::protobuf::internal::ArenaStringPtr image_heights_;
|
|
||||||
::google::protobuf::internal::ArenaStringPtr output_layer_;
|
|
||||||
::tensorflow::GraphDef *graph_;
|
|
||||||
::google::protobuf::int64 global_step_;
|
|
||||||
::google::protobuf::int32 depth_;
|
|
||||||
::google::protobuf::int32 x_size_;
|
|
||||||
::google::protobuf::int32 y_size_;
|
|
||||||
::google::protobuf::int32 batch_size_;
|
|
||||||
::google::protobuf::int32 num_classes_;
|
|
||||||
bool using_ctc_;
|
|
||||||
mutable ::google::protobuf::internal::CachedSize _cached_size_;
|
|
||||||
friend struct ::protobuf_tfnetwork_2eproto::TableStruct;
|
|
||||||
};
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
|
||||||
#endif // __GNUC__
|
|
||||||
// TFNetworkModel
|
|
||||||
|
|
||||||
// .tensorflow.GraphDef graph = 1;
|
|
||||||
inline bool TFNetworkModel::has_graph() const {
|
|
||||||
return this != internal_default_instance() && graph_ != NULL;
|
|
||||||
}
|
|
||||||
inline const ::tensorflow::GraphDef &TFNetworkModel::_internal_graph() const {
|
|
||||||
return *graph_;
|
|
||||||
}
|
|
||||||
inline const ::tensorflow::GraphDef &TFNetworkModel::graph() const {
|
|
||||||
const ::tensorflow::GraphDef *p = graph_;
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.graph)
|
|
||||||
return p != NULL ? *p
|
|
||||||
: *reinterpret_cast<const ::tensorflow::GraphDef *>(
|
|
||||||
&::tensorflow::_GraphDef_default_instance_);
|
|
||||||
}
|
|
||||||
inline ::tensorflow::GraphDef *TFNetworkModel::release_graph() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.graph)
|
|
||||||
|
|
||||||
::tensorflow::GraphDef *temp = graph_;
|
|
||||||
graph_ = NULL;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
inline ::tensorflow::GraphDef *TFNetworkModel::mutable_graph() {
|
|
||||||
if (graph_ == NULL) {
|
|
||||||
auto *p = CreateMaybeMessage<::tensorflow::GraphDef>(GetArenaNoVirtual());
|
|
||||||
graph_ = p;
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.graph)
|
|
||||||
return graph_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_graph(::tensorflow::GraphDef *graph) {
|
|
||||||
::google::protobuf::Arena *message_arena = GetArenaNoVirtual();
|
|
||||||
if (message_arena == NULL) {
|
|
||||||
delete reinterpret_cast<::google::protobuf::MessageLite *>(graph_);
|
|
||||||
}
|
|
||||||
if (graph) {
|
|
||||||
::google::protobuf::Arena *submessage_arena =
|
|
||||||
reinterpret_cast<::google::protobuf::MessageLite *>(graph)->GetArena();
|
|
||||||
if (message_arena != submessage_arena) {
|
|
||||||
graph = ::google::protobuf::internal::GetOwnedMessage(message_arena, graph, submessage_arena);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
graph_ = graph;
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.graph)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64 global_step = 2;
|
|
||||||
inline void TFNetworkModel::clear_global_step() {
|
|
||||||
global_step_ = GOOGLE_LONGLONG(0);
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int64 TFNetworkModel::global_step() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.global_step)
|
|
||||||
return global_step_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_global_step(::google::protobuf::int64 value) {
|
|
||||||
global_step_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.global_step)
|
|
||||||
}
|
|
||||||
|
|
||||||
// string spec = 3;
|
|
||||||
inline void TFNetworkModel::clear_spec() {
|
|
||||||
spec_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline const ::std::string &TFNetworkModel::spec() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.spec)
|
|
||||||
return spec_.GetNoArena();
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_spec(const ::std::string &value) {
|
|
||||||
spec_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.spec)
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
inline void TFNetworkModel::set_spec(::std::string &&value) {
|
|
||||||
spec_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::move(value));
|
|
||||||
// @@protoc_insertion_point(field_set_rvalue:tesseract.TFNetworkModel.spec)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void TFNetworkModel::set_spec(const char *value) {
|
|
||||||
GOOGLE_DCHECK(value != NULL);
|
|
||||||
|
|
||||||
spec_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:tesseract.TFNetworkModel.spec)
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_spec(const char *value, size_t size) {
|
|
||||||
spec_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char *>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:tesseract.TFNetworkModel.spec)
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::mutable_spec() {
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.spec)
|
|
||||||
return spec_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::release_spec() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.spec)
|
|
||||||
|
|
||||||
return spec_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_spec(::std::string *spec) {
|
|
||||||
if (spec != NULL) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
spec_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), spec);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.spec)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 depth = 4;
|
|
||||||
inline void TFNetworkModel::clear_depth() {
|
|
||||||
depth_ = 0;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 TFNetworkModel::depth() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.depth)
|
|
||||||
return depth_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_depth(::google::protobuf::int32 value) {
|
|
||||||
depth_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.depth)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 x_size = 5;
|
|
||||||
inline void TFNetworkModel::clear_x_size() {
|
|
||||||
x_size_ = 0;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 TFNetworkModel::x_size() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.x_size)
|
|
||||||
return x_size_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_x_size(::google::protobuf::int32 value) {
|
|
||||||
x_size_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.x_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 y_size = 6;
|
|
||||||
inline void TFNetworkModel::clear_y_size() {
|
|
||||||
y_size_ = 0;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 TFNetworkModel::y_size() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.y_size)
|
|
||||||
return y_size_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_y_size(::google::protobuf::int32 value) {
|
|
||||||
y_size_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.y_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 batch_size = 8;
|
|
||||||
inline void TFNetworkModel::clear_batch_size() {
|
|
||||||
batch_size_ = 0;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 TFNetworkModel::batch_size() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.batch_size)
|
|
||||||
return batch_size_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_batch_size(::google::protobuf::int32 value) {
|
|
||||||
batch_size_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.batch_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32 num_classes = 9;
|
|
||||||
inline void TFNetworkModel::clear_num_classes() {
|
|
||||||
num_classes_ = 0;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 TFNetworkModel::num_classes() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.num_classes)
|
|
||||||
return num_classes_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_num_classes(::google::protobuf::int32 value) {
|
|
||||||
num_classes_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.num_classes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool using_ctc = 10;
|
|
||||||
inline void TFNetworkModel::clear_using_ctc() {
|
|
||||||
using_ctc_ = false;
|
|
||||||
}
|
|
||||||
inline bool TFNetworkModel::using_ctc() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.using_ctc)
|
|
||||||
return using_ctc_;
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_using_ctc(bool value) {
|
|
||||||
using_ctc_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.using_ctc)
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_input = 11;
|
|
||||||
inline void TFNetworkModel::clear_image_input() {
|
|
||||||
image_input_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline const ::std::string &TFNetworkModel::image_input() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.image_input)
|
|
||||||
return image_input_.GetNoArena();
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_input(const ::std::string &value) {
|
|
||||||
image_input_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.image_input)
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
inline void TFNetworkModel::set_image_input(::std::string &&value) {
|
|
||||||
image_input_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::move(value));
|
|
||||||
// @@protoc_insertion_point(field_set_rvalue:tesseract.TFNetworkModel.image_input)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void TFNetworkModel::set_image_input(const char *value) {
|
|
||||||
GOOGLE_DCHECK(value != NULL);
|
|
||||||
|
|
||||||
image_input_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:tesseract.TFNetworkModel.image_input)
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_input(const char *value, size_t size) {
|
|
||||||
image_input_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char *>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:tesseract.TFNetworkModel.image_input)
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::mutable_image_input() {
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.image_input)
|
|
||||||
return image_input_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::release_image_input() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.image_input)
|
|
||||||
|
|
||||||
return image_input_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_image_input(::std::string *image_input) {
|
|
||||||
if (image_input != NULL) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
image_input_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
image_input);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.image_input)
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_widths = 12;
|
|
||||||
inline void TFNetworkModel::clear_image_widths() {
|
|
||||||
image_widths_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline const ::std::string &TFNetworkModel::image_widths() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.image_widths)
|
|
||||||
return image_widths_.GetNoArena();
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_widths(const ::std::string &value) {
|
|
||||||
image_widths_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.image_widths)
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
inline void TFNetworkModel::set_image_widths(::std::string &&value) {
|
|
||||||
image_widths_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::move(value));
|
|
||||||
// @@protoc_insertion_point(field_set_rvalue:tesseract.TFNetworkModel.image_widths)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void TFNetworkModel::set_image_widths(const char *value) {
|
|
||||||
GOOGLE_DCHECK(value != NULL);
|
|
||||||
|
|
||||||
image_widths_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:tesseract.TFNetworkModel.image_widths)
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_widths(const char *value, size_t size) {
|
|
||||||
image_widths_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char *>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:tesseract.TFNetworkModel.image_widths)
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::mutable_image_widths() {
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.image_widths)
|
|
||||||
return image_widths_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::release_image_widths() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.image_widths)
|
|
||||||
|
|
||||||
return image_widths_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_image_widths(::std::string *image_widths) {
|
|
||||||
if (image_widths != NULL) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
image_widths_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
image_widths);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.image_widths)
|
|
||||||
}
|
|
||||||
|
|
||||||
// string image_heights = 13;
|
|
||||||
inline void TFNetworkModel::clear_image_heights() {
|
|
||||||
image_heights_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline const ::std::string &TFNetworkModel::image_heights() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.image_heights)
|
|
||||||
return image_heights_.GetNoArena();
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_heights(const ::std::string &value) {
|
|
||||||
image_heights_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.image_heights)
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
inline void TFNetworkModel::set_image_heights(::std::string &&value) {
|
|
||||||
image_heights_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::move(value));
|
|
||||||
// @@protoc_insertion_point(field_set_rvalue:tesseract.TFNetworkModel.image_heights)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void TFNetworkModel::set_image_heights(const char *value) {
|
|
||||||
GOOGLE_DCHECK(value != NULL);
|
|
||||||
|
|
||||||
image_heights_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:tesseract.TFNetworkModel.image_heights)
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_image_heights(const char *value, size_t size) {
|
|
||||||
image_heights_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char *>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:tesseract.TFNetworkModel.image_heights)
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::mutable_image_heights() {
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.image_heights)
|
|
||||||
return image_heights_.MutableNoArena(
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::release_image_heights() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.image_heights)
|
|
||||||
|
|
||||||
return image_heights_.ReleaseNoArena(
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_image_heights(::std::string *image_heights) {
|
|
||||||
if (image_heights != NULL) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
image_heights_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
image_heights);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.image_heights)
|
|
||||||
}
|
|
||||||
|
|
||||||
// string output_layer = 14;
|
|
||||||
inline void TFNetworkModel::clear_output_layer() {
|
|
||||||
output_layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline const ::std::string &TFNetworkModel::output_layer() const {
|
|
||||||
// @@protoc_insertion_point(field_get:tesseract.TFNetworkModel.output_layer)
|
|
||||||
return output_layer_.GetNoArena();
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_output_layer(const ::std::string &value) {
|
|
||||||
output_layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:tesseract.TFNetworkModel.output_layer)
|
|
||||||
}
|
|
||||||
#if LANG_CXX11
|
|
||||||
inline void TFNetworkModel::set_output_layer(::std::string &&value) {
|
|
||||||
output_layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::move(value));
|
|
||||||
// @@protoc_insertion_point(field_set_rvalue:tesseract.TFNetworkModel.output_layer)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void TFNetworkModel::set_output_layer(const char *value) {
|
|
||||||
GOOGLE_DCHECK(value != NULL);
|
|
||||||
|
|
||||||
output_layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:tesseract.TFNetworkModel.output_layer)
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_output_layer(const char *value, size_t size) {
|
|
||||||
output_layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char *>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:tesseract.TFNetworkModel.output_layer)
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::mutable_output_layer() {
|
|
||||||
// @@protoc_insertion_point(field_mutable:tesseract.TFNetworkModel.output_layer)
|
|
||||||
return output_layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline ::std::string *TFNetworkModel::release_output_layer() {
|
|
||||||
// @@protoc_insertion_point(field_release:tesseract.TFNetworkModel.output_layer)
|
|
||||||
|
|
||||||
return output_layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
inline void TFNetworkModel::set_allocated_output_layer(::std::string *output_layer) {
|
|
||||||
if (output_layer != NULL) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
output_layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
output_layer);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:tesseract.TFNetworkModel.output_layer)
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif // __GNUC__
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
|
|
||||||
} // namespace tesseract
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
|
|
||||||
#endif // PROTOBUF_INCLUDED_tfnetwork_2eproto
|
|
@ -1,74 +0,0 @@
|
|||||||
// Protocol description for Tesseract
|
|
||||||
|
|
||||||
// Compile this file with the Protocol Compiler protoc to generate
|
|
||||||
// the files tfnetwork.pb.cc and tfnetwork.pb.h.
|
|
||||||
|
|
||||||
// This requires the protocol descriptions for TensorFlow
|
|
||||||
// (included in the TensorFlow sources).
|
|
||||||
|
|
||||||
// With TensorFlow sources installed in /usr/src/tensorflow/tensorflow-1.10.1,
|
|
||||||
// this command was used on Debian to generate the files:
|
|
||||||
|
|
||||||
// protoc --cpp_out=$PWD --proto_path=/usr/src/tensorflow/tensorflow-1.10.1 \
|
|
||||||
// --proto_path=$PWD src/lstm/tfnetwork.proto
|
|
||||||
|
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package tesseract;
|
|
||||||
|
|
||||||
import "tensorflow/core/framework/graph.proto";
|
|
||||||
|
|
||||||
// This proto is the interface between a python TF graph builder/trainer and
|
|
||||||
// the C++ world. The writer of this proto must provide fields as documented
|
|
||||||
// by the comments below.
|
|
||||||
// The graph must have a placeholder for NetworkIO, Widths and Heights. The
|
|
||||||
// following python code creates the appropriate placeholders:
|
|
||||||
//
|
|
||||||
// input_layer = tf.placeholder(tf.float32,
|
|
||||||
// shape=[batch_size, xsize, ysize, depth_dim],
|
|
||||||
// name='NetworkIO')
|
|
||||||
// widths = tf.placeholder(tf.int32, shape=[batch_size], name='Widths')
|
|
||||||
// heights = tf.placeholder(tf.int32, shape=[batch_size], name='Heights')
|
|
||||||
// # Flip x and y to the TF convention.
|
|
||||||
// input_layer = tf.transpose(input_layer, [0, 2, 1, 3])
|
|
||||||
//
|
|
||||||
// The widths and heights will be set to indicate the post-scaling size of the
|
|
||||||
// input image(s).
|
|
||||||
// For now batch_size is ignored and set to 1.
|
|
||||||
// The graph should return a 2-dimensional float32 tensor called 'softmax' of
|
|
||||||
// shape [sequence_length, num_classes], where sequence_length is allowed to
|
|
||||||
// be variable, given by the tensor itself.
|
|
||||||
// TODO(rays) determine whether it is worth providing for batch_size >1 and if
|
|
||||||
// so, how.
|
|
||||||
message TFNetworkModel {
|
|
||||||
// The TF graph definition. Required.
|
|
||||||
tensorflow.GraphDef graph = 1;
|
|
||||||
// The training index. Required to be > 0.
|
|
||||||
int64 global_step = 2;
|
|
||||||
// The original network definition for reference. Optional
|
|
||||||
string spec = 3;
|
|
||||||
// Input tensor parameters.
|
|
||||||
// Values per pixel. Required to be 1 or 3. Inputs assumed to be float32.
|
|
||||||
int32 depth = 4;
|
|
||||||
// Image size. Required. Zero implies flexible sizes, fixed if non-zero.
|
|
||||||
// If x_size > 0, images will be cropped/padded to the given size, after
|
|
||||||
// any scaling required by the y_size.
|
|
||||||
// If y_size > 0, images will be scaled isotropically to the given height.
|
|
||||||
int32 x_size = 5;
|
|
||||||
int32 y_size = 6;
|
|
||||||
// Number of images in a batch. Optional.
|
|
||||||
int32 batch_size = 8;
|
|
||||||
// Output tensor parameters.
|
|
||||||
// Number of output classes. Required to match the depth of the softmax.
|
|
||||||
int32 num_classes = 9;
|
|
||||||
// True if this network needs CTC-like decoding, dropping duplicated labels.
|
|
||||||
// The decoder always drops the null character.
|
|
||||||
bool using_ctc = 10;
|
|
||||||
// Name of input image tensor.
|
|
||||||
string image_input = 11;
|
|
||||||
// Name of image height and width tensors.
|
|
||||||
string image_widths = 12;
|
|
||||||
string image_heights = 13;
|
|
||||||
// Name of output (softmax) tensor.
|
|
||||||
string output_layer = 14;
|
|
||||||
}
|
|
@ -36,9 +36,6 @@
|
|||||||
#include "networkbuilder.h"
|
#include "networkbuilder.h"
|
||||||
#include "ratngs.h"
|
#include "ratngs.h"
|
||||||
#include "recodebeam.h"
|
#include "recodebeam.h"
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
|
||||||
# include "tfnetwork.h"
|
|
||||||
#endif
|
|
||||||
#include "tprintf.h"
|
#include "tprintf.h"
|
||||||
|
|
||||||
namespace tesseract {
|
namespace tesseract {
|
||||||
@ -186,23 +183,6 @@ bool LSTMTrainer::InitNetwork(const char *network_spec, int append_index,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes a trainer from a serialized TFNetworkModel proto.
|
|
||||||
// Returns the global step of TensorFlow graph or 0 if failed.
|
|
||||||
#ifdef INCLUDE_TENSORFLOW
|
|
||||||
int LSTMTrainer::InitTensorFlowNetwork(const std::string &tf_proto) {
|
|
||||||
delete network_;
|
|
||||||
TFNetwork *tf_net = new TFNetwork("TensorFlow");
|
|
||||||
training_iteration_ = tf_net->InitFromProtoStr(tf_proto);
|
|
||||||
if (training_iteration_ == 0) {
|
|
||||||
tprintf("InitFromProtoStr failed!!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
network_ = tf_net;
|
|
||||||
ASSERT_HOST(recoder_.code_range() == tf_net->num_classes());
|
|
||||||
return training_iteration_;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Resets all the iteration counters for fine tuning or traininng a head,
|
// Resets all the iteration counters for fine tuning or traininng a head,
|
||||||
// where we want the error reporting to reset.
|
// where we want the error reporting to reset.
|
||||||
void LSTMTrainer::InitIterations() {
|
void LSTMTrainer::InitIterations() {
|
||||||
|
@ -119,10 +119,6 @@ public:
|
|||||||
bool InitNetwork(const char *network_spec, int append_index, int net_flags,
|
bool InitNetwork(const char *network_spec, int append_index, int net_flags,
|
||||||
float weight_range, float learning_rate, float momentum,
|
float weight_range, float learning_rate, float momentum,
|
||||||
float adam_beta);
|
float adam_beta);
|
||||||
// Initializes a trainer from a serialized TFNetworkModel proto.
|
|
||||||
// Returns the global step of TensorFlow graph or 0 if failed.
|
|
||||||
// Building a compatible TF graph: See tfnetwork.proto.
|
|
||||||
int InitTensorFlowNetwork(const std::string &tf_proto);
|
|
||||||
// Resets all the iteration counters for fine tuning or training a head,
|
// Resets all the iteration counters for fine tuning or training a head,
|
||||||
// where we want the error reporting to reset.
|
// where we want the error reporting to reset.
|
||||||
void InitIterations();
|
void InitIterations();
|
||||||
|
@ -8,6 +8,6 @@ Description: An OCR Engine that was developed at HP Labs (1985-1995) and Google
|
|||||||
URL: https://github.com/tesseract-ocr/tesseract
|
URL: https://github.com/tesseract-ocr/tesseract
|
||||||
Version: @tesseract_VERSION@
|
Version: @tesseract_VERSION@
|
||||||
Requires.private: lept
|
Requires.private: lept
|
||||||
Libs: -L${libdir} -l@tesseract_OUTPUT_NAME@ @libarchive_LIBS@ @libcurl_LIBS@ @TENSORFLOW_LIBS@
|
Libs: -L${libdir} -l@tesseract_OUTPUT_NAME@ @libarchive_LIBS@ @libcurl_LIBS@
|
||||||
Libs.private:
|
Libs.private:
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@ -11,6 +11,6 @@ Description: An OCR Engine that was developed at HP Labs (1985-1995) and Google
|
|||||||
URL: https://github.com/tesseract-ocr/tesseract
|
URL: https://github.com/tesseract-ocr/tesseract
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires.private: lept
|
Requires.private: lept
|
||||||
Libs: -L${libdir} -ltesseract @libarchive_LIBS@ @libcurl_LIBS@ @TENSORFLOW_LIBS@
|
Libs: -L${libdir} -ltesseract @libarchive_LIBS@ @libcurl_LIBS@
|
||||||
Libs.private: -lpthread
|
Libs.private: -lpthread
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
14
unittest/third_party/utf/utfdef.h
vendored
14
unittest/third_party/utf/utfdef.h
vendored
@ -1,14 +0,0 @@
|
|||||||
#define uchar _utfuchar
|
|
||||||
#define ushort _utfushort
|
|
||||||
#define uint _utfuint
|
|
||||||
#define ulong _utfulong
|
|
||||||
#define vlong _utfvlong
|
|
||||||
#define uvlong _utfuvlong
|
|
||||||
|
|
||||||
typedef unsigned char uchar;
|
|
||||||
typedef unsigned short ushort;
|
|
||||||
typedef unsigned int uint;
|
|
||||||
typedef unsigned long ulong;
|
|
||||||
|
|
||||||
#define nelem(x) (sizeof(x) / sizeof((x)[0]))
|
|
||||||
#define nil ((void *)0)
|
|
Loading…
Reference in New Issue
Block a user