mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 13:42:48 +00:00
パラメータファイルがjsonしかない場合、バイナリに変換する機能が動いていなかったのを修正
This commit is contained in:
parent
7fb34eb6c8
commit
1c944e01ea
@ -242,10 +242,19 @@ static Waifu2x::eWaifu2xError readProtoText(const boost::filesystem::path &path,
|
||||
|
||||
static Waifu2x::eWaifu2xError readProtoBinary(const boost::filesystem::path &path, ::google::protobuf::Message* proto)
|
||||
{
|
||||
boost::iostreams::stream<boost::iostreams::file_descriptor_source> is(path, std::ios_base::in | std::ios_base::binary);
|
||||
boost::iostreams::stream<boost::iostreams::file_descriptor_source> is;
|
||||
|
||||
try
|
||||
{
|
||||
is.open(path, std::ios_base::in | std::ios_base::binary);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return Waifu2x::eWaifu2xError_FailedOpenModelFile;
|
||||
}
|
||||
|
||||
if (!is)
|
||||
return Waifu2x::eWaifu2xError_FailedParseModelFile;
|
||||
return Waifu2x::eWaifu2xError_FailedOpenModelFile;
|
||||
|
||||
std::vector<char> tmp;
|
||||
if (!readFile(is, tmp))
|
||||
@ -617,7 +626,12 @@ Waifu2x::eWaifu2xError Waifu2x::ConstractNet(boost::shared_ptr<caffe::Net<float>
|
||||
modelbin_path += ".protobin";
|
||||
|
||||
caffe::NetParameter param;
|
||||
if (readProtoBinary(modelbin_path, ¶m) == eWaifu2xError_OK)
|
||||
caffe::NetParameter param_caffemodel;
|
||||
|
||||
const auto retModelBin = readProtoBinary(caffemodel_path, ¶m);
|
||||
const auto retParamBin = readProtoBinary(modelbin_path, ¶m_caffemodel);
|
||||
|
||||
if (retModelBin == eWaifu2xError_OK && retParamBin == eWaifu2xError_OK)
|
||||
{
|
||||
Waifu2x::eWaifu2xError ret;
|
||||
|
||||
@ -625,11 +639,6 @@ Waifu2x::eWaifu2xError Waifu2x::ConstractNet(boost::shared_ptr<caffe::Net<float>
|
||||
if (ret != eWaifu2xError_OK)
|
||||
return ret;
|
||||
|
||||
caffe::NetParameter param_caffemodel;
|
||||
ret = readProtoBinary(caffemodel_path, ¶m_caffemodel);
|
||||
if (ret != eWaifu2xError_OK)
|
||||
return ret;
|
||||
|
||||
if (!caffe::UpgradeNetAsNeeded(caffemodel_path.string(), ¶m_caffemodel))
|
||||
return Waifu2x::eWaifu2xError_FailedParseModelFile;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user