mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Fix compilation for Tensorflow code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
3c03d70e64
commit
2e349dbba5
@ -1117,6 +1117,7 @@ unittest_CPPFLAGS += -I$(top_srcdir)/src/wordrec
|
||||
unittest_CPPFLAGS += -I$(top_srcdir)/abseil
|
||||
if TENSORFLOW
|
||||
unittest_CPPFLAGS += -DINCLUDE_TENSORFLOW
|
||||
unittest_CPPFLAGS += -I$(top_srcdir)/unittest
|
||||
unittest_CPPFLAGS += -I/usr/include/tensorflow
|
||||
endif # TENSORFLOW
|
||||
|
||||
|
@ -44,19 +44,17 @@ bool TFNetwork::Serialize(TFile *fp) const {
|
||||
return false;
|
||||
std::string proto_str;
|
||||
model_proto_.SerializeToString(&proto_str);
|
||||
std::vector<char> data;
|
||||
data.resize_no_init(proto_str.size());
|
||||
// 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());
|
||||
if (!data.Serialize(fp))
|
||||
return false;
|
||||
return true;
|
||||
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 (!data.DeSerialize(fp))
|
||||
if (!fp->DeSerialize(data))
|
||||
return false;
|
||||
if (!model_proto_.ParseFromArray(&data[0], data.size())) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user