From e5c310f851e3fdbd3a95431da468e326df22ca38 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Fri, 23 Nov 2018 23:49:22 +0900 Subject: [PATCH] =?UTF-8?q?noise=5Fscale=E3=81=A8noise=E3=82=92=E4=B8=A1?= =?UTF-8?q?=E6=96=B9=E6=8C=81=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/models/cunet/info.json | 2 +- common/cNet.cpp | 2 ++ common/waifu2x.cpp | 6 +++--- common/waifu2x.h | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/models/cunet/info.json b/bin/models/cunet/info.json index 556a2d7..d95a76b 100644 --- a/bin/models/cunet/info.json +++ b/bin/models/cunet/info.json @@ -1,4 +1,4 @@ -{"name":"CUnet","arch_name":"upcunet","has_noise_scale":true,"channels":3, +{"name":"CUnet","arch_name":"upcunet","has_noise_scale":true,"has_noise_only":true, "channels":3, "scale_factor":2,"offset":36, "scale_factor_noise":1,"offset_noise":28 } \ No newline at end of file diff --git a/common/cNet.cpp b/common/cNet.cpp index 0141822..86d65b2 100644 --- a/common/cNet.cpp +++ b/common/cNet.cpp @@ -190,11 +190,13 @@ Waifu2x::eWaifu2xError cNet::GetInfo(const boost::filesystem::path & info_path, const auto name = d["name"].GetString(); const auto arch_name = d["arch_name"].GetString(); const bool has_noise_scale = d.HasMember("has_noise_scale") && d["has_noise_scale"].GetBool() ? true : false; + const bool has_noise_only = d.HasMember("has_noise_only") && d["has_noise_only"].GetBool() ? true : false; const int channels = d["channels"].GetInt(); info.name = name; info.arch_name = arch_name; info.has_noise_scale = has_noise_scale; + info.has_noise_only = has_noise_only; info.channels = channels; if (d.HasMember("offset")) diff --git a/common/waifu2x.cpp b/common/waifu2x.cpp index fcbff96..99d22fd 100644 --- a/common/waifu2x.cpp +++ b/common/waifu2x.cpp @@ -655,7 +655,7 @@ Waifu2x::eWaifu2xError Waifu2x::Init(const eWaifu2xModelType mode, const int noi if (ret != Waifu2x::eWaifu2xError_OK) return ret; - mHasNoiseScale = info.has_noise_scale; + mHasNoiseScaleOnly = info.has_noise_scale && !info.has_noise_only; mInputPlane = info.channels; if (mode == eWaifu2xModelTypeNoise || mode == eWaifu2xModelTypeNoiseScale || mode == eWaifu2xModelTypeAutoScale) @@ -665,7 +665,7 @@ Waifu2x::eWaifu2xError Waifu2x::Init(const eWaifu2xModelType mode, const int noi mNoiseNet.reset(new cNet); eWaifu2xModelType Mode = mode; - if (info.has_noise_scale) // ノイズ除去と拡大を同時に行う + if (mHasNoiseScaleOnly) // ノイズ除去と拡大を同時に行う { // ノイズ除去拡大ネットの構築はeWaifu2xModelTypeNoiseScaleを指定する必要がある Mode = eWaifu2xModelTypeNoiseScale; @@ -905,7 +905,7 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(const Factor factor, const int if (isReconstructNoise) { - if (!mHasNoiseScale) // ノイズ除去だけ + if (!mHasNoiseScaleOnly) // ノイズ除去だけ { cv::Mat im; cv::Size_ size; diff --git a/common/waifu2x.h b/common/waifu2x.h index 8b689d4..1749960 100644 --- a/common/waifu2x.h +++ b/common/waifu2x.h @@ -74,6 +74,7 @@ class Waifu2x std::string name; std::string arch_name; bool has_noise_scale; + bool has_noise_only; int channels; stParam noise; @@ -141,7 +142,7 @@ class Waifu2x int mInputPlane; // ネットへの入力チャンネル数 int mMaxNetOffset; // ネットに入力するとどれくらい削れるか - bool mHasNoiseScale; + bool mHasNoiseScaleOnly; float *mOutputBlock; size_t mOutputBlockSize;