diff --git a/src/ccstruct/polyblk.cpp b/src/ccstruct/polyblk.cpp index 67021c0c..9d152c6a 100644 --- a/src/ccstruct/polyblk.cpp +++ b/src/ccstruct/polyblk.cpp @@ -1,8 +1,6 @@ /********************************************************************** * File: polyblk.cpp (Formerly poly_block.c) * Description: Polygonal blocks - * Author: Sheelagh Lloyd? - * Created: * * (C) Copyright 1993, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,14 +43,14 @@ POLY_BLOCK::POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType t) { } // Initialize from box coordinates. -POLY_BLOCK::POLY_BLOCK(const TBOX& box, PolyBlockType t) { +POLY_BLOCK::POLY_BLOCK(const TBOX& tbox, PolyBlockType t) { vertices.clear(); ICOORDELT_IT v = &vertices; v.move_to_first(); - v.add_to_end(new ICOORDELT(box.left(), box.top())); - v.add_to_end(new ICOORDELT(box.left(), box.bottom())); - v.add_to_end(new ICOORDELT(box.right(), box.bottom())); - v.add_to_end(new ICOORDELT(box.right(), box.top())); + v.add_to_end(new ICOORDELT(tbox.left(), tbox.top())); + v.add_to_end(new ICOORDELT(tbox.left(), tbox.bottom())); + v.add_to_end(new ICOORDELT(tbox.right(), tbox.bottom())); + v.add_to_end(new ICOORDELT(tbox.right(), tbox.top())); compute_bb(); type = t; } diff --git a/src/ccstruct/polyblk.h b/src/ccstruct/polyblk.h index 08703722..62baa222 100644 --- a/src/ccstruct/polyblk.h +++ b/src/ccstruct/polyblk.h @@ -28,7 +28,7 @@ class DLLSYM POLY_BLOCK { public: POLY_BLOCK() = default; // Initialize from box coordinates. - POLY_BLOCK(const TBOX& box, PolyBlockType type); + POLY_BLOCK(const TBOX& tbox, PolyBlockType type); POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType type); ~POLY_BLOCK () = default; diff --git a/src/lstm/lstmrecognizer.cpp b/src/lstm/lstmrecognizer.cpp index c3ae7a40..060cf261 100644 --- a/src/lstm/lstmrecognizer.cpp +++ b/src/lstm/lstmrecognizer.cpp @@ -408,6 +408,7 @@ void LSTMRecognizer::DebugActivationRange(const NetworkIO& outputs, // Helper returns true if the null_char is the winner at t, and it beats the // null_threshold, or the next choice is space, in which case we will use the // null anyway. +#if 0 // TODO: unused, remove if still unused after 2020. static bool NullIsBest(const NetworkIO& output, float null_thr, int null_char, int t) { if (output.f(t)[null_char] >= null_thr) return true; @@ -415,6 +416,7 @@ static bool NullIsBest(const NetworkIO& output, float null_thr, return false; return output.f(t)[null_char] > output.f(t)[UNICHAR_SPACE]; } +#endif // Converts the network output to a sequence of labels. Outputs labels, scores // and start xcoords of each char, and each null_char_, with an additional diff --git a/src/lstm/network.cpp b/src/lstm/network.cpp index db0c7078..3dc28229 100644 --- a/src/lstm/network.cpp +++ b/src/lstm/network.cpp @@ -244,7 +244,6 @@ Network* Network::CreateFromFile(TFile* fp) { network = new TFNetwork(stub.name_); #else tprintf("TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n"); - return nullptr; #endif break; // All variants of FullyConnected. @@ -259,15 +258,16 @@ Network* Network::CreateFromFile(TFile* fp) { network = new FullyConnected(stub.name_, stub.ni_, stub.no_, stub.type_); break; default: - return nullptr; } - network->training_ = stub.training_; - network->needs_to_backprop_ = stub.needs_to_backprop_; - network->network_flags_ = stub.network_flags_; - network->num_weights_ = stub.num_weights_; - if (!network->DeSerialize(fp)) { - delete network; - return nullptr; + if (network) { + network->training_ = stub.training_; + network->needs_to_backprop_ = stub.needs_to_backprop_; + network->network_flags_ = stub.network_flags_; + network->num_weights_ = stub.num_weights_; + if (!network->DeSerialize(fp)) { + delete network; + network =‌ nullptr; + } } return network; } diff --git a/src/lstm/networkio.cpp b/src/lstm/networkio.cpp index 405977e9..88f3f409 100644 --- a/src/lstm/networkio.cpp +++ b/src/lstm/networkio.cpp @@ -50,10 +50,9 @@ void NetworkIO::Resize2d(bool int_mode, int width, int num_features) { // Resizes to a specific stride_map. void NetworkIO::ResizeToMap(bool int_mode, const StrideMap& stride_map, int num_features) { - // If this assert fails, it most likely got here through an uninitialized - // scratch element, ie call NetworkScratch::IO::Resizexxx() not - // NetworkIO::Resizexxx()!! - ASSERT_HOST(this != nullptr); + // If this method crashes with this == nullptr, + // it most likely got here through an uninitialized scratch element, + // ie call NetworkScratch::IO::Resizexxx() not NetworkIO::Resizexxx()!! stride_map_ = stride_map; int_mode_ = int_mode; if (int_mode_) {