From 5fe2bdc6f41ac3d26747e4bd244c7a1fa4913593 Mon Sep 17 00:00:00 2001 From: benjaminwan Date: Mon, 17 Oct 2022 16:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AscoreToTextLine?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=B4=A2=E5=BC=95=E8=B6=8A=E7=95=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AngleNet.cpp | 8 ++------ src/CrnnNet.cpp | 14 ++++++-------- src/DbNet.cpp | 8 ++------ 3 files changed, 10 insertions(+), 20 deletions(-) mode change 100755 => 100644 src/AngleNet.cpp mode change 100755 => 100644 src/CrnnNet.cpp mode change 100755 => 100644 src/DbNet.cpp diff --git a/src/AngleNet.cpp b/src/AngleNet.cpp old mode 100755 new mode 100644 index 54a08d4..05001ab --- a/src/AngleNet.cpp +++ b/src/AngleNet.cpp @@ -6,12 +6,8 @@ AngleNet::AngleNet() {} AngleNet::~AngleNet() { delete session; - for (auto name : inputNames) { - free(name); - } - for (auto name : outputNames) { - free(name); - } + inputNames.clear(); + outputNames.clear(); } void AngleNet::setNumThread(int numOfThread) { diff --git a/src/CrnnNet.cpp b/src/CrnnNet.cpp old mode 100755 new mode 100644 index 894cafc..873d042 --- a/src/CrnnNet.cpp +++ b/src/CrnnNet.cpp @@ -7,12 +7,8 @@ CrnnNet::CrnnNet() {} CrnnNet::~CrnnNet() { delete session; - for (auto name: inputNames) { - free(name); - } - for (auto name: outputNames) { - free(name); - } + inputNames.clear(); + outputNames.clear(); } void CrnnNet::setNumThread(int numOfThread) { @@ -76,8 +72,10 @@ TextLine CrnnNet::scoreToTextLine(const std::vector &outputData, int h, i float maxValue; for (int i = 0; i < h; i++) { - maxIndex = int(argmax(&outputData[i * w], &outputData[(i + 1) * w])); - maxValue = float(*std::max_element(&outputData[i * w], &outputData[(i + 1) * w])); + int start = i * w; + int stop = (i + 1) * w - 1; + maxIndex = int(argmax(&outputData[start], &outputData[stop])); + maxValue = float(*std::max_element(&outputData[start], &outputData[stop])); if (maxIndex > 0 && maxIndex < keySize && (!(i > 0 && maxIndex == lastIndex))) { scores.emplace_back(maxValue); diff --git a/src/DbNet.cpp b/src/DbNet.cpp old mode 100755 new mode 100644 index 8aa9af1..ef5ac11 --- a/src/DbNet.cpp +++ b/src/DbNet.cpp @@ -5,12 +5,8 @@ DbNet::DbNet() {} DbNet::~DbNet() { delete session; - for (auto name : inputNames) { - free(name); - } - for (auto name : outputNames) { - free(name); - } + inputNames.clear(); + outputNames.clear(); } void DbNet::setNumThread(int numOfThread) {