From a17ad89116a1e36ab514d106b46bb368a0dab941 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Thu, 25 Oct 2018 03:54:07 +0900 Subject: [PATCH] =?UTF-8?q?caffemodel=E3=81=A8prototxt=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=A6json=E3=81=A8proto?= =?UTF-8?q?txt.protobin=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E7=8A=B6=E6=B3=81=E3=81=A7=E3=82=82=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E5=90=90=E3=81=8B=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cNet.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/cNet.cpp b/common/cNet.cpp index 1e3ebac..dd46ad8 100644 --- a/common/cNet.cpp +++ b/common/cNet.cpp @@ -280,8 +280,20 @@ Waifu2x::eWaifu2xError cNet::ConstractNet(const Waifu2x::eWaifu2xModelType mode, const auto retModelBin = readProtoBinary(modelbin_path, ¶m_model); const auto retParamBin = readProtoBinary(caffemodel_path, ¶m_caffemodel); - if (retModelBin == Waifu2x::eWaifu2xError_OK && retParamBin == Waifu2x::eWaifu2xError_OK) + if ( retParamBin == Waifu2x::eWaifu2xError_OK && + (retModelBin == Waifu2x::eWaifu2xError_OK || retModelBin == Waifu2x::eWaifu2xError_FailedOpenModelFile)) { + if (retModelBin == Waifu2x::eWaifu2xError_FailedOpenModelFile) // protobinのみが読み込めなかったときはprototxtから読み込む(ついでにprotobinも書き込む) + { + ret = readProtoText(model_path, ¶m_model); + if (ret != Waifu2x::eWaifu2xError_OK) + return ret; + + ret = writeProtoBinary(param_model, modelbin_path); + if (ret != Waifu2x::eWaifu2xError_OK) + return ret; + } + ret = SetParameter(param_model, process); if (ret != Waifu2x::eWaifu2xError_OK) return ret;