RGB版モデル、写真用モデルが動くようにした

This commit is contained in:
lltcggie 2015-06-24 01:07:27 +09:00
parent 4a72466f3e
commit 213c95e1b8
51 changed files with 1157 additions and 218 deletions

View File

@ -253,20 +253,98 @@ Waifu2x::eWaifu2xError Waifu2x::CreateZoomColorImage(const cv::Mat &float_image,
return eWaifu2xError_OK;
}
// 学習したパラメータをファイルから読み込む
Waifu2x::eWaifu2xError Waifu2x::LoadParameter(boost::shared_ptr<caffe::Net<float>> net, const std::string &param_path)
// モデルファイルからネットワークを構築
// processでcudnnが指定されなかった場合はcuDNNが呼び出されないように変更する
Waifu2x::eWaifu2xError Waifu2x::ConstractNet(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &param_path, const std::string &process)
{
const std::string caffemodel_path = param_path + ".caffemodel";
const std::string modelbin_path = model_path + ".protobin";
FILE *fp = fopen(caffemodel_path.c_str(), "rb");
const bool isModelExist = fp != nullptr;
if (fp) fclose(fp);
fp = fopen(modelbin_path.c_str(), "rb");
const bool isModelBinExist = fp != nullptr;
if (fp) fclose(fp);
caffe::NetParameter param;
if (isModelExist && caffe::ReadProtoFromBinaryFile(caffemodel_path, &param))
net->CopyTrainedLayersFrom(param);
if (isModelExist && isModelBinExist && caffe::ReadProtoFromBinaryFile(modelbin_path, &param))
{
const auto ret = SetParameter(param);
if (ret != eWaifu2xError_OK)
return ret;
net = boost::shared_ptr<caffe::Net<float>>(new caffe::Net<float>(param));
net->CopyTrainedLayersFrom(caffemodel_path);
input_plane = param.input_dim(1);
}
else
{
const auto ret = LoadParameterFromJson(net, model_path, param_path);
if (ret != eWaifu2xError_OK)
return ret;
}
return eWaifu2xError_OK;
}
Waifu2x::eWaifu2xError Waifu2x::SetParameter(caffe::NetParameter &param) const
{
param.mutable_state()->set_phase(caffe::TEST);
{
auto mid = param.mutable_input_dim();
if (mid->size() != 4)
return eWaifu2xError_FailedParseModelFile;
*mid->Mutable(0) = batch_size;
*mid->Mutable(2) = input_block_size;
*mid->Mutable(3) = input_block_size;
}
for (int i = 0; i < param.layer_size(); i++)
{
caffe::LayerParameter *layer_param = param.mutable_layer(i);
const std::string& type = layer_param->type();
if (type == "Convolution")
{
if (process == "cudnn")
layer_param->mutable_convolution_param()->set_engine(caffe::ConvolutionParameter_Engine_CUDNN);
else
layer_param->mutable_convolution_param()->set_engine(caffe::ConvolutionParameter_Engine_CAFFE);
}
else if (type == "ReLU")
{
if (process == "cudnn")
layer_param->mutable_relu_param()->set_engine(caffe::ReLUParameter_Engine_CUDNN);
else
layer_param->mutable_relu_param()->set_engine(caffe::ReLUParameter_Engine_CAFFE);
}
}
return eWaifu2xError_OK;
}
Waifu2x::eWaifu2xError Waifu2x::LoadParameterFromJson(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &param_path)
{
const std::string caffemodel_path = param_path + ".caffemodel";
const std::string modelbin_path = model_path + ".protobin";
caffe::NetParameter param;
if (!caffe::ReadProtoFromTextFile(model_path, &param))
return eWaifu2xError_FailedOpenModelFile;
caffe::WriteProtoToBinaryFile(param, modelbin_path);
const auto ret = SetParameter(param);
if (ret != eWaifu2xError_OK)
return ret;
net = boost::shared_ptr<caffe::Net<float>>(new caffe::Net<float>(param));
rapidjson::Document d;
std::vector<char> jsonBuf;
@ -294,6 +372,30 @@ Waifu2x::eWaifu2xError Waifu2x::LoadParameter(boost::shared_ptr<caffe::Net<float
return eWaifu2xError_FailedParseModelFile;
}
if (d.Size() != 7)
return eWaifu2xError_FailedParseModelFile;
int inputPlane = 0;
int outputPlane = 0;
try
{
inputPlane = d[0]["nInputPlane"].GetInt();
outputPlane = d[d.Size() - 1]["nOutputPlane"].GetInt();
}
catch (...)
{
return eWaifu2xError_FailedParseModelFile;
}
if (inputPlane == 0 || outputPlane == 0)
return eWaifu2xError_FailedParseModelFile;
if (inputPlane != outputPlane)
return eWaifu2xError_FailedParseModelFile;
//if (param.layer_size() < 17)
// return eWaifu2xError_FailedParseModelFile;
std::vector<boost::shared_ptr<caffe::Layer<float>>> list;
auto &v = net->layers();
for (auto &l : v)
@ -382,50 +484,8 @@ Waifu2x::eWaifu2xError Waifu2x::LoadParameter(boost::shared_ptr<caffe::Net<float
{
return eWaifu2xError_FailedConstructModel;
}
}
return eWaifu2xError_OK;
}
// モデルファイルからネットワークを構築
// processでcudnnが指定されなかった場合はcuDNNが呼び出されないように変更する
Waifu2x::eWaifu2xError Waifu2x::ConstractNet(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &process)
{
caffe::NetParameter param;
if (!caffe::ReadProtoFromTextFile(model_path, &param))
return eWaifu2xError_FailedOpenModelFile;
param.mutable_state()->set_phase(caffe::TEST);
for (int i = 0; i < param.layer_size(); i++)
{
caffe::LayerParameter *layer_param = param.mutable_layer(i);
const std::string& type = layer_param->type();
if (type == "Convolution")
{
if (process == "cudnn")
layer_param->mutable_convolution_param()->set_engine(caffe::ConvolutionParameter_Engine_CUDNN);
else
layer_param->mutable_convolution_param()->set_engine(caffe::ConvolutionParameter_Engine_CAFFE);
}
else if (type == "ReLU")
{
if (process == "cudnn")
layer_param->mutable_relu_param()->set_engine(caffe::ReLUParameter_Engine_CUDNN);
else
layer_param->mutable_relu_param()->set_engine(caffe::ReLUParameter_Engine_CAFFE);
}
else if (type == "MemoryData")
{
if (layer_param->mutable_memory_data_param()->width() == original_width_height && layer_param->mutable_memory_data_param()->height() == original_width_height)
{
layer_param->mutable_memory_data_param()->set_width(input_block_size);
layer_param->mutable_memory_data_param()->set_height(input_block_size);
}
}
}
net = boost::shared_ptr<caffe::Net<float>>(new caffe::Net<float>(param));
input_plane = inputPlane;
return eWaifu2xError_OK;
}
@ -440,7 +500,7 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
assert(Width % output_size == 0);
assert(Height % output_size == 0);
assert(im.channels() == 1);
assert(im.channels() == 1 || im.channels() == 3);
cv::Mat outim(im.rows, im.cols, im.type());
@ -449,25 +509,21 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
try
{
const auto input_layer =
boost::dynamic_pointer_cast<caffe::MemoryDataLayer<float>>(
net->layer_by_name("image_input_layer"));
assert(input_layer);
auto input_blobs = net->input_blobs();
auto input_blob = net->input_blobs()[0];
const auto conv7_layer =
boost::dynamic_pointer_cast<caffe::ConvolutionLayer<float>>(
net->layer_by_name("conv7_layer"));
assert(conv7_layer);
input_blob->Reshape(batch_size, input_plane, input_block_size, input_block_size);
input_layer->set_batch_size(batch_size);
assert(im.channels() == input_plane);
assert(input_blob->shape(1) == input_plane);
const int WidthNum = Width / output_size;
const int HeightNum = Height / output_size;
const int BlockNum = WidthNum * HeightNum;
const int input_block_plane_size = input_block_size * input_block_size;
const int output_block_plane_size = output_block_size * output_block_size;
const int input_block_plane_size = input_block_size * input_block_size * input_plane;
const int output_block_plane_size = output_block_size * output_block_size * input_plane;
const int output_padding = inner_padding + outer_padding - layer_num;
@ -477,7 +533,7 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
const int processNum = (BlockNum - num) >= batch_size ? batch_size : BlockNum - num;
if (processNum < batch_size)
input_layer->set_batch_size(processNum);
input_blob->Reshape(processNum, input_plane, input_block_size, input_block_size);
for (int n = 0; n < processNum; n++)
{
@ -546,6 +602,8 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
const auto Line = someborderimg.step1();
if (someborderimg.channels() == 1)
{
if (input_block_size == Line)
memcpy(fptr, uptr, input_block_size * input_block_size * sizeof(float));
else
@ -554,11 +612,43 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
memcpy(fptr + i * input_block_size, uptr + i * Line, input_block_size * sizeof(float));
}
}
else
{
const auto LinePixel = someborderimg.step1() / someborderimg.channels();
const auto Channel = someborderimg.channels();
const auto Width = someborderimg.size().width;
const auto Height = someborderimg.size().height;
for (int i = 0; i < Height; i++)
{
for (int j = 0; j < LinePixel; j++)
{
for (int ch = 0; ch < Channel; ch++)
fptr[(ch * Height + i) * Width + j] = uptr[(i * LinePixel + j) * Channel + ch];
}
}
/*
{
cv::Mat im(someborderimg.size(), CV_32F, fptr, Width * sizeof(float));
cv::Mat write_iamge;
im.convertTo(write_iamge, CV_8U, 255.0);
im.release();
if (!cv::imwrite("test_in.png", write_iamge))
return eWaifu2xError_FailedOpenOutputFile;
}
*/
}
}
}
}
assert(input_blob->count() == input_block_plane_size * processNum);
// ネットワークに画像を入力
input_layer->Reset(input_block, dummy_data, input_block_plane_size * processNum);
input_blob->set_cpu_data(input_block);
// 計算
auto out = net->ForwardPrefilled(nullptr);
@ -586,10 +676,40 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructImage(boost::shared_ptr<caffe::Net<fl
const float *fptr = output_block + (output_block_plane_size * n);
// 結果を入力画像にコピー(後に処理する部分とここで上書きする部分は被らないから、入力画像を上書きしても大丈夫)
// 結果を出力画像にコピー
if (outim.channels() == 1)
{
for (int i = 0; i < crop_size; i++)
memcpy(imptr + (h + i) * Line + w, fptr + (i + output_padding) * output_block_size + output_padding, crop_size * sizeof(float));
}
else
{
const auto LinePixel = outim.step1() / outim.channels();
const auto Channel = outim.channels();
for (int i = 0; i < crop_size; i++)
{
for (int j = 0; j < crop_size; j++)
{
for (int ch = 0; ch < Channel; ch++)
imptr[((h + i) * LinePixel + (w + j)) * Channel + ch] = fptr[(ch * output_block_size + i + output_padding) * output_block_size + j + output_padding];
}
}
/*
{
cv::Mat im(someborderimg.size(), CV_32F, fptr, Width * sizeof(float));
cv::Mat write_iamge;
im.convertTo(write_iamge, CV_8U, 255.0);
im.release();
if (!cv::imwrite("test_in.png", write_iamge))
return eWaifu2xError_FailedOpenOutputFile;
}
*/
}
}
}
}
catch (...)
@ -689,11 +809,7 @@ Waifu2x::eWaifu2xError Waifu2x::init(int argc, char** argv, const std::string &M
const std::string model_path = (mode_dir_path / "srcnn.prototxt").string();
const std::string param_path = (mode_dir_path / ("noise" + std::to_string(noise_level) + "_model.json")).string();
ret = ConstractNet(net_noise, model_path, process);
if (ret != eWaifu2xError_OK)
return ret;
ret = LoadParameter(net_noise, param_path);
ret = ConstractNet(net_noise, model_path, param_path, process);
if (ret != eWaifu2xError_OK)
return ret;
}
@ -703,17 +819,13 @@ Waifu2x::eWaifu2xError Waifu2x::init(int argc, char** argv, const std::string &M
const std::string model_path = (mode_dir_path / "srcnn.prototxt").string();
const std::string param_path = (mode_dir_path / "scale2.0x_model.json").string();
ret = ConstractNet(net_scale, model_path, process);
if (ret != eWaifu2xError_OK)
return ret;
ret = LoadParameter(net_scale, param_path);
ret = ConstractNet(net_scale, model_path, param_path, process);
if (ret != eWaifu2xError_OK)
return ret;
}
const int input_block_plane_size = input_block_size * input_block_size;
const int output_block_plane_size = output_block_size * output_block_size;
const int input_block_plane_size = input_block_size * input_block_size * input_plane;
const int output_block_plane_size = output_block_size * output_block_size * input_plane;
if (isCuda)
{
@ -776,8 +888,22 @@ Waifu2x::eWaifu2xError Waifu2x::waifu2x(const std::string &input_file, const std
return ret;
cv::Mat im;
if (input_plane == 1)
CreateBrightnessImage(float_image, im);
else
{
std::vector<cv::Mat> planes;
cv::split(float_image, planes);
if (float_image.channels() == 4)
planes.resize(3);
// BGRからRGBにする
std::swap(planes[0], planes[2]);
cv::merge(planes, im);
}
cv::Size_<int> image_size = im.size();
const boost::filesystem::path ip(input_file);
@ -825,21 +951,14 @@ Waifu2x::eWaifu2xError Waifu2x::waifu2x(const std::string &input_file, const std
if (cancel_func && cancel_func())
return eWaifu2xError_Cancel;
cv::Mat process_image;
if (input_plane == 1)
{
// 再構築した輝度画像とCreateZoomColorImage()で作成した色情報をマージして通常の画像に変換し、書き込む
std::vector<cv::Mat> color_planes;
CreateZoomColorImage(float_image, image_size, color_planes);
cv::Mat alpha;
if (float_image.channels() == 4)
{
std::vector<cv::Mat> planes;
cv::split(float_image, planes);
alpha = planes[3];
cv::resize(alpha, alpha, image_size, 0.0, 0.0, cv::INTER_CUBIC);
}
float_image.release();
color_planes[0] = im;
@ -849,9 +968,29 @@ Waifu2x::eWaifu2xError Waifu2x::waifu2x(const std::string &input_file, const std
cv::merge(color_planes, converted_image);
color_planes.clear();
cv::Mat process_image;
cv::cvtColor(converted_image, process_image, ConvertInverseMode);
converted_image.release();
}
else
{
std::vector<cv::Mat> planes;
cv::split(im, planes);
// RGBからBGRに直す
std::swap(planes[0], planes[2]);
cv::merge(planes, process_image);
}
cv::Mat alpha;
if (float_image.channels() == 4)
{
std::vector<cv::Mat> planes;
cv::split(float_image, planes);
alpha = planes[3];
cv::resize(alpha, alpha, image_size, 0.0, 0.0, cv::INTER_CUBIC);
}
// アルファチャンネルがあったら、アルファを付加してカラーからアルファの影響を抜く
if (!alpha.empty())

View File

@ -13,6 +13,7 @@ namespace caffe
{
template <typename Dtype>
class Net;
class NetParameter;
};
class Waifu2x
@ -78,6 +79,8 @@ private:
int output_block_size;
int input_plane;
bool isCuda;
boost::shared_ptr<caffe::Net<float>> net_noise;
@ -93,8 +96,9 @@ private:
eWaifu2xError PaddingImage(const cv::Mat &input, cv::Mat &output);
eWaifu2xError Zoom2xAndPaddingImage(const cv::Mat &input, cv::Mat &output, cv::Size_<int> &zoom_size);
eWaifu2xError CreateZoomColorImage(const cv::Mat &float_image, const cv::Size_<int> &zoom_size, std::vector<cv::Mat> &cubic_planes);
eWaifu2xError LoadParameter(boost::shared_ptr<caffe::Net<float>> net, const std::string &param_path);
eWaifu2xError ConstractNet(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &process);
eWaifu2xError ConstractNet(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &param_path, const std::string &process);
eWaifu2xError LoadParameterFromJson(boost::shared_ptr<caffe::Net<float>> &net, const std::string &model_path, const std::string &param_path);
eWaifu2xError SetParameter(caffe::NetParameter &param) const;
eWaifu2xError ReconstructImage(boost::shared_ptr<caffe::Net<float>> net, cv::Mat &im);
public:

Binary file not shown.

View File

@ -105,6 +105,7 @@ private:
std::string mode;
int noise_level;
double scale_ratio;
std::string model_dir;
std::string process;
std::string outputExt;
std::string inputFileExt;
@ -190,6 +191,13 @@ private:
}
}
if (SendMessage(GetDlgItem(dh, IDC_RADIO_MODEL_RGB), BM_GETCHECK, 0, 0))
model_dir = "models/anime_style_art_rgb";
else if (SendMessage(GetDlgItem(dh, IDC_RADIO_MODEL_Y), BM_GETCHECK, 0, 0))
model_dir = "models/anime_style_art";
else
model_dir = "models/ukbench";
{
char buf[AR_PATH_MAX] = "";
GetWindowTextA(GetDlgItem(dh, IDC_EDIT_OUT_EXT), buf, _countof(buf));
@ -423,7 +431,7 @@ private:
Waifu2x::eWaifu2xError ret;
Waifu2x w;
ret = w.init(__argc, __argv, mode, noise_level, scale_ratio, "models", process, crop_size, batch_size);
ret = w.init(__argc, __argv, mode, noise_level, scale_ratio, model_dir, process, crop_size, batch_size);
if(ret != Waifu2x::eWaifu2xError_OK)
SendMessage(dh, WM_ON_WAIFU2X_ERROR, (WPARAM)&ret, 0);
else
@ -538,7 +546,7 @@ private:
}
public:
DialogEvent() : dh(nullptr), mode("noise_scale"), noise_level(1), scale_ratio(2.0), process("gpu"), outputExt("png"), inputFileExt("png:jpg:jpeg:tif:tiff:bmp"),
DialogEvent() : dh(nullptr), mode("noise_scale"), noise_level(1), scale_ratio(2.0), model_dir("models/anime_style_art_rgb"), process("gpu"), outputExt("png"), inputFileExt("png:jpg:jpeg:tif:tiff:bmp"),
crop_size(128), batch_size(1), isLastError(false)
{
}
@ -705,6 +713,7 @@ public:
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODE_NOISE_SCALE), BM_SETCHECK, BST_CHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIONOISE_LEVEL1), BM_SETCHECK, BST_CHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODE_GPU), BM_SETCHECK, BST_CHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODEL_RGB), BM_SETCHECK, BST_CHECKED, 0);
EnableWindow(GetDlgItem(dh, IDC_BUTTON_CANCEL), FALSE);
@ -738,6 +747,37 @@ public:
ReplaceAddString();
}
void ModelRadioButtomScaleAndNoise(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
{
const BOOL flag = TRUE;
EnableWindow(GetDlgItem(dh, IDC_RADIONOISE_LEVEL1), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIONOISE_LEVEL2), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_NOISE), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_SCALE), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_NOISE_SCALE), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_AUTO_SCALE), flag);
}
void ModelRadioButtomScaleOnly(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
{
const BOOL flag = FALSE;
EnableWindow(GetDlgItem(dh, IDC_RADIONOISE_LEVEL1), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIONOISE_LEVEL2), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_NOISE), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_SCALE), TRUE);
EnableWindow(GetDlgItem(dh, IDC_RADIO_MODE_NOISE_SCALE), flag);
EnableWindow(GetDlgItem(dh, IDC_RADIO_AUTO_SCALE), flag);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODE_NOISE), BM_SETCHECK, BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODE_SCALE), BM_SETCHECK, BST_CHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_MODE_NOISE_SCALE), BM_SETCHECK, BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hWnd, IDC_RADIO_AUTO_SCALE), BM_SETCHECK, BST_UNCHECKED, 0);
ReplaceAddString();
}
void CheckCUDNN(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
{
const auto flag = Waifu2x::can_use_CUDA();
@ -901,6 +941,10 @@ int WINAPI WinMain(HINSTANCE hInstance,
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_CPU);
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::RadioButtom, &cDialogEvent), NULL, IDC_RADIO_MODE_GPU);
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::ModelRadioButtomScaleAndNoise, &cDialogEvent), NULL, IDC_RADIO_MODEL_RGB);
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::ModelRadioButtomScaleAndNoise, &cDialogEvent), NULL, IDC_RADIO_MODEL_Y);
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::ModelRadioButtomScaleOnly, &cDialogEvent), NULL, IDC_RADIO_MODEL_PHOTO);
cDialog.SetCommandCallBack(SetClassFunc(DialogEvent::CheckCUDNN, &cDialogEvent), NULL, IDC_BUTTON_CHECK_CUDNN);
// ダイアログのイベントで実行する関数の登録

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,9 @@
name: "srcnn"
layer {
name: "image_input_layer"
type: "MemoryData"
top: "input"
top: "dummy_label1"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
}
input: "input"
input_dim: 1
input_dim: 1
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
@ -20,6 +13,7 @@ layer {
num_output: 32
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -44,6 +38,7 @@ layer {
num_output: 32
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -68,6 +63,7 @@ layer {
num_output: 64
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -92,6 +88,7 @@ layer {
num_output: 64
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -116,6 +113,7 @@ layer {
num_output: 128
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -140,6 +138,7 @@ layer {
num_output: 128
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -164,6 +163,7 @@ layer {
num_output: 1
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,186 @@
name: "srcnn"
input: "input"
input_dim: 1
input_dim: 3
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
bottom: "input"
top: "conv1"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv1_relu_layer"
type: "ReLU"
bottom: "conv1"
top: "conv1"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv2_layer"
type: "Convolution"
bottom: "conv1"
top: "conv2"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv2_relu_layer"
type: "ReLU"
bottom: "conv2"
top: "conv2"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv3_layer"
type: "Convolution"
bottom: "conv2"
top: "conv3"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv3_relu_layer"
type: "ReLU"
bottom: "conv3"
top: "conv3"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv4_layer"
type: "Convolution"
bottom: "conv3"
top: "conv4"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv4_relu_layer"
type: "ReLU"
bottom: "conv4"
top: "conv4"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv5_layer"
type: "Convolution"
bottom: "conv4"
top: "conv5"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv5_relu_layer"
type: "ReLU"
bottom: "conv5"
top: "conv5"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv6_layer"
type: "Convolution"
bottom: "conv5"
top: "conv6"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv6_relu_layer"
type: "ReLU"
bottom: "conv6"
top: "conv6"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv7_layer"
type: "Convolution"
bottom: "conv6"
top: "conv7"
convolution_param {
num_output: 3
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "target"
type: "MemoryData"
top: "target"
top: "dummy_label2"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
include: { phase: TRAIN }
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "conv7"
bottom: "target"
top: "loss"
include: { phase: TRAIN }
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,186 @@
name: "srcnn"
input: "input"
input_dim: 1
input_dim: 3
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
bottom: "input"
top: "conv1"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv1_relu_layer"
type: "ReLU"
bottom: "conv1"
top: "conv1"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv2_layer"
type: "Convolution"
bottom: "conv1"
top: "conv2"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv2_relu_layer"
type: "ReLU"
bottom: "conv2"
top: "conv2"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv3_layer"
type: "Convolution"
bottom: "conv2"
top: "conv3"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv3_relu_layer"
type: "ReLU"
bottom: "conv3"
top: "conv3"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv4_layer"
type: "Convolution"
bottom: "conv3"
top: "conv4"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv4_relu_layer"
type: "ReLU"
bottom: "conv4"
top: "conv4"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv5_layer"
type: "Convolution"
bottom: "conv4"
top: "conv5"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv5_relu_layer"
type: "ReLU"
bottom: "conv5"
top: "conv5"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv6_layer"
type: "Convolution"
bottom: "conv5"
top: "conv6"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv6_relu_layer"
type: "ReLU"
bottom: "conv6"
top: "conv6"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv7_layer"
type: "Convolution"
bottom: "conv6"
top: "conv7"
convolution_param {
num_output: 3
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "target"
type: "MemoryData"
top: "target"
top: "dummy_label2"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
include: { phase: TRAIN }
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "conv7"
bottom: "target"
top: "loss"
include: { phase: TRAIN }
}

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,9 @@
name: "srcnn"
layer {
name: "image_input_layer"
type: "MemoryData"
top: "input"
top: "dummy_label1"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
}
input: "input"
input_dim: 1
input_dim: 1
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
@ -20,6 +13,7 @@ layer {
num_output: 32
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -44,6 +38,7 @@ layer {
num_output: 32
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -68,6 +63,7 @@ layer {
num_output: 64
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -92,6 +88,7 @@ layer {
num_output: 64
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -116,6 +113,7 @@ layer {
num_output: 128
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -140,6 +138,7 @@ layer {
num_output: 128
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01
@ -164,6 +163,7 @@ layer {
num_output: 1
kernel_size: 3
stride: 1
group: 1
weight_filler {
type: "gaussian"
std: 0.01

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,186 @@
name: "srcnn"
input: "input"
input_dim: 1
input_dim: 3
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
bottom: "input"
top: "conv1"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv1_relu_layer"
type: "ReLU"
bottom: "conv1"
top: "conv1"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv2_layer"
type: "Convolution"
bottom: "conv1"
top: "conv2"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv2_relu_layer"
type: "ReLU"
bottom: "conv2"
top: "conv2"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv3_layer"
type: "Convolution"
bottom: "conv2"
top: "conv3"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv3_relu_layer"
type: "ReLU"
bottom: "conv3"
top: "conv3"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv4_layer"
type: "Convolution"
bottom: "conv3"
top: "conv4"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv4_relu_layer"
type: "ReLU"
bottom: "conv4"
top: "conv4"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv5_layer"
type: "Convolution"
bottom: "conv4"
top: "conv5"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv5_relu_layer"
type: "ReLU"
bottom: "conv5"
top: "conv5"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv6_layer"
type: "Convolution"
bottom: "conv5"
top: "conv6"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv6_relu_layer"
type: "ReLU"
bottom: "conv6"
top: "conv6"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv7_layer"
type: "Convolution"
bottom: "conv6"
top: "conv7"
convolution_param {
num_output: 3
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "target"
type: "MemoryData"
top: "target"
top: "dummy_label2"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
include: { phase: TRAIN }
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "conv7"
bottom: "target"
top: "loss"
include: { phase: TRAIN }
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,186 @@
name: "srcnn"
input: "input"
input_dim: 1
input_dim: 3
input_dim: 142
input_dim: 142
layer {
name: "conv1_layer"
type: "Convolution"
bottom: "input"
top: "conv1"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv1_relu_layer"
type: "ReLU"
bottom: "conv1"
top: "conv1"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv2_layer"
type: "Convolution"
bottom: "conv1"
top: "conv2"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv2_relu_layer"
type: "ReLU"
bottom: "conv2"
top: "conv2"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv3_layer"
type: "Convolution"
bottom: "conv2"
top: "conv3"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv3_relu_layer"
type: "ReLU"
bottom: "conv3"
top: "conv3"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv4_layer"
type: "Convolution"
bottom: "conv3"
top: "conv4"
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv4_relu_layer"
type: "ReLU"
bottom: "conv4"
top: "conv4"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv5_layer"
type: "Convolution"
bottom: "conv4"
top: "conv5"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv5_relu_layer"
type: "ReLU"
bottom: "conv5"
top: "conv5"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv6_layer"
type: "Convolution"
bottom: "conv5"
top: "conv6"
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "conv6_relu_layer"
type: "ReLU"
bottom: "conv6"
top: "conv6"
relu_param {
negative_slope: 0.1
}
}
layer {
name: "conv7_layer"
type: "Convolution"
bottom: "conv6"
top: "conv7"
convolution_param {
num_output: 3
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
}
}
layer {
name: "target"
type: "MemoryData"
top: "target"
top: "dummy_label2"
memory_data_param {
batch_size: 1
channels: 1
height: 142
width: 142
}
include: { phase: TRAIN }
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "conv7"
bottom: "target"
top: "loss"
include: { phase: TRAIN }
}

Binary file not shown.