|
@@ -45,18 +45,22 @@ local ART_MODEL_DIR = path.join(ROOT, "models", "upconv_7", "art")
|
|
|
local PHOTO_MODEL_DIR = path.join(ROOT, "models", "upconv_7", "photo")
|
|
|
local art_model = {
|
|
|
scale = w2nn.load_model(path.join(ART_MODEL_DIR, "scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
+ noise0_scale = w2nn.load_model(path.join(ART_MODEL_DIR, "noise0_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise1_scale = w2nn.load_model(path.join(ART_MODEL_DIR, "noise1_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise2_scale = w2nn.load_model(path.join(ART_MODEL_DIR, "noise2_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise3_scale = w2nn.load_model(path.join(ART_MODEL_DIR, "noise3_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
+ noise0 = w2nn.load_model(path.join(ART_MODEL_DIR, "noise0_model.t7"), opt.force_cudnn),
|
|
|
noise1 = w2nn.load_model(path.join(ART_MODEL_DIR, "noise1_model.t7"), opt.force_cudnn),
|
|
|
noise2 = w2nn.load_model(path.join(ART_MODEL_DIR, "noise2_model.t7"), opt.force_cudnn),
|
|
|
noise3 = w2nn.load_model(path.join(ART_MODEL_DIR, "noise3_model.t7"), opt.force_cudnn)
|
|
|
}
|
|
|
local photo_model = {
|
|
|
scale = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
+ noise0_scale = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise0_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise1_scale = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise1_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise2_scale = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise2_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
noise3_scale = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise3_scale2.0x_model.t7"), opt.force_cudnn),
|
|
|
+ noise0 = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise0_model.t7"), opt.force_cudnn),
|
|
|
noise1 = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise1_model.t7"), opt.force_cudnn),
|
|
|
noise2 = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise2_model.t7"), opt.force_cudnn),
|
|
|
noise3 = w2nn.load_model(path.join(PHOTO_MODEL_DIR, "noise3_model.t7"), opt.force_cudnn)
|
|
@@ -189,6 +193,7 @@ local function convert(x, meta, options)
|
|
|
x = alpha_util.make_border(x, alpha_orig, reconstruct.offset_size(model.scale))
|
|
|
end
|
|
|
if (options.method == "scale" or
|
|
|
+ options.method == "noise0_scale" or
|
|
|
options.method == "noise1_scale" or
|
|
|
options.method == "noise2_scale" or
|
|
|
options.method == "noise3_scale")
|
|
@@ -204,7 +209,8 @@ local function convert(x, meta, options)
|
|
|
end
|
|
|
end
|
|
|
cleanup_model(model[options.method])
|
|
|
- elseif (options.method == "noise1" or
|
|
|
+ elseif (options.method == "noise0" or
|
|
|
+ options.method == "noise1" or
|
|
|
options.method == "noise2" or
|
|
|
options.method == "noise3")
|
|
|
then
|
|
@@ -242,8 +248,8 @@ function APIHandler:post()
|
|
|
return
|
|
|
end
|
|
|
local x, meta, filename = get_image(self)
|
|
|
- local scale = tonumber(self:get_argument("scale", "0"))
|
|
|
- local noise = tonumber(self:get_argument("noise", "0"))
|
|
|
+ local scale = tonumber(self:get_argument("scale", "-1"))
|
|
|
+ local noise = tonumber(self:get_argument("noise", "-1"))
|
|
|
local tta_level = tonumber(self:get_argument("tta_level", "1"))
|
|
|
local style = self:get_argument("style", "art")
|
|
|
local download = (self:get_argument("download", "")):len()
|
|
@@ -259,14 +265,14 @@ function APIHandler:post()
|
|
|
end
|
|
|
if x and valid_size(x, scale, tta_level) then
|
|
|
local prefix = nil
|
|
|
- if (noise ~= 0 or scale ~= 0) then
|
|
|
+ if (noise >= 0 or scale > 0) then
|
|
|
local hash = md5.sumhexa(meta.blob)
|
|
|
local alpha_prefix = style .. "_" .. hash .. "_alpha"
|
|
|
local border = false
|
|
|
- if scale ~= 0 and meta.alpha then
|
|
|
+ if scale >= 0 and meta.alpha then
|
|
|
border = true
|
|
|
end
|
|
|
- if (scale == 1 or scale == 2) and (noise == 0) then
|
|
|
+ if (scale == 1 or scale == 2) and (noise < 0) then
|
|
|
prefix = style .. "_scale_tta_" .. tta_level .. "_"
|
|
|
x, meta = convert(x, meta, {method = "scale",
|
|
|
style = style,
|
|
@@ -277,7 +283,7 @@ function APIHandler:post()
|
|
|
if scale == 1 then
|
|
|
x = iproc.scale(x, x:size(3) * (1.6 / 2.0), x:size(2) * (1.6 / 2.0), "Sinc")
|
|
|
end
|
|
|
- elseif (scale == 1 or scale == 2) and (noise == 1 or noise == 2 or noise == 3) then
|
|
|
+ elseif (scale == 1 or scale == 2) and (noise == 0 or noise == 1 or noise == 2 or noise == 3) then
|
|
|
prefix = style .. string.format("_noise%d_scale_tta_", noise) .. tta_level .. "_"
|
|
|
x, meta = convert(x, meta, {method = string.format("noise%d_scale", noise),
|
|
|
style = style,
|
|
@@ -288,7 +294,7 @@ function APIHandler:post()
|
|
|
if scale == 1 then
|
|
|
x = iproc.scale(x, x:size(3) * (1.6 / 2.0), x:size(2) * (1.6 / 2.0), "Sinc")
|
|
|
end
|
|
|
- elseif (noise == 1 or noise == 2 or noise == 3) then
|
|
|
+ elseif (noise == 0 or noise == 1 or noise == 2 or noise == 3) then
|
|
|
prefix = style .. string.format("_noise%d_tta_", noise) .. tta_level .. "_"
|
|
|
x = convert(x, meta, {method = string.format("noise%d", noise),
|
|
|
style = style,
|