|
@@ -38,12 +38,14 @@ if cudnn then
|
|
end
|
|
end
|
|
local ART_MODEL_DIR = path.join(ROOT, "models", "anime_style_art_rgb")
|
|
local ART_MODEL_DIR = path.join(ROOT, "models", "anime_style_art_rgb")
|
|
local PHOTO_MODEL_DIR = path.join(ROOT, "models", "photo")
|
|
local PHOTO_MODEL_DIR = path.join(ROOT, "models", "photo")
|
|
|
|
+local art_scale2_model = torch.load(path.join(ART_MODEL_DIR, "scale2.0x_model.t7"), "ascii")
|
|
local art_noise1_model = torch.load(path.join(ART_MODEL_DIR, "noise1_model.t7"), "ascii")
|
|
local art_noise1_model = torch.load(path.join(ART_MODEL_DIR, "noise1_model.t7"), "ascii")
|
|
local art_noise2_model = torch.load(path.join(ART_MODEL_DIR, "noise2_model.t7"), "ascii")
|
|
local art_noise2_model = torch.load(path.join(ART_MODEL_DIR, "noise2_model.t7"), "ascii")
|
|
-local art_scale2_model = torch.load(path.join(ART_MODEL_DIR, "scale2.0x_model.t7"), "ascii")
|
|
|
|
|
|
+local art_noise3_model = torch.load(path.join(ART_MODEL_DIR, "noise3_model.t7"), "ascii")
|
|
local photo_scale2_model = torch.load(path.join(PHOTO_MODEL_DIR, "scale2.0x_model.t7"), "ascii")
|
|
local photo_scale2_model = torch.load(path.join(PHOTO_MODEL_DIR, "scale2.0x_model.t7"), "ascii")
|
|
local photo_noise1_model = torch.load(path.join(PHOTO_MODEL_DIR, "noise1_model.t7"), "ascii")
|
|
local photo_noise1_model = torch.load(path.join(PHOTO_MODEL_DIR, "noise1_model.t7"), "ascii")
|
|
local photo_noise2_model = torch.load(path.join(PHOTO_MODEL_DIR, "noise2_model.t7"), "ascii")
|
|
local photo_noise2_model = torch.load(path.join(PHOTO_MODEL_DIR, "noise2_model.t7"), "ascii")
|
|
|
|
+local photo_noise3_model = torch.load(path.join(PHOTO_MODEL_DIR, "noise3_model.t7"), "ascii")
|
|
local CLEANUP_MODEL = false -- if you are using the low memory GPU, you could use this flag.
|
|
local CLEANUP_MODEL = false -- if you are using the low memory GPU, you could use this flag.
|
|
local CACHE_DIR = path.join(ROOT, "cache")
|
|
local CACHE_DIR = path.join(ROOT, "cache")
|
|
local MAX_NOISE_IMAGE = 2560 * 2560
|
|
local MAX_NOISE_IMAGE = 2560 * 2560
|
|
@@ -151,9 +153,12 @@ local function convert(x, alpha, options)
|
|
elseif options.method == "noise1" then
|
|
elseif options.method == "noise1" then
|
|
x = reconstruct.image(art_noise1_model, x)
|
|
x = reconstruct.image(art_noise1_model, x)
|
|
cleanup_model(art_noise1_model)
|
|
cleanup_model(art_noise1_model)
|
|
- else -- options.method == "noise2"
|
|
|
|
|
|
+ elseif options.method == "noise2" then
|
|
x = reconstruct.image(art_noise2_model, x)
|
|
x = reconstruct.image(art_noise2_model, x)
|
|
cleanup_model(art_noise2_model)
|
|
cleanup_model(art_noise2_model)
|
|
|
|
+ elseif options.method == "noise3" then
|
|
|
|
+ x = reconstruct.image(art_noise3_model, x)
|
|
|
|
+ cleanup_model(art_noise3_model)
|
|
end
|
|
end
|
|
else -- photo
|
|
else -- photo
|
|
if options.border then
|
|
if options.border then
|
|
@@ -174,6 +179,9 @@ local function convert(x, alpha, options)
|
|
elseif options.method == "noise2" then
|
|
elseif options.method == "noise2" then
|
|
x = reconstruct.image(photo_noise2_model, x)
|
|
x = reconstruct.image(photo_noise2_model, x)
|
|
cleanup_model(photo_noise2_model)
|
|
cleanup_model(photo_noise2_model)
|
|
|
|
+ elseif options.method == "noise3" then
|
|
|
|
+ x = reconstruct.image(photo_noise3_model, x)
|
|
|
|
+ cleanup_model(photo_noise3_model)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
image_loader.save_png(cache_file, x)
|
|
image_loader.save_png(cache_file, x)
|
|
@@ -229,17 +237,25 @@ function APIHandler:post()
|
|
alpha_prefix = alpha_prefix, border = border})
|
|
alpha_prefix = alpha_prefix, border = border})
|
|
border = false
|
|
border = false
|
|
elseif noise == 2 then
|
|
elseif noise == 2 then
|
|
- prefix = style .. "_noise1_"
|
|
|
|
|
|
+ prefix = style .. "_noise2_"
|
|
x = convert(x, alpha, {method = "noise2", style = style,
|
|
x = convert(x, alpha, {method = "noise2", style = style,
|
|
prefix = prefix .. hash,
|
|
prefix = prefix .. hash,
|
|
alpha_prefix = alpha_prefix, border = border})
|
|
alpha_prefix = alpha_prefix, border = border})
|
|
border = false
|
|
border = false
|
|
|
|
+ elseif noise == 3 then
|
|
|
|
+ prefix = style .. "_noise3_"
|
|
|
|
+ x = convert(x, alpha, {method = "noise3", style = style,
|
|
|
|
+ prefix = prefix .. hash,
|
|
|
|
+ alpha_prefix = alpha_prefix, border = border})
|
|
|
|
+ border = false
|
|
end
|
|
end
|
|
if scale == 1 or scale == 2 then
|
|
if scale == 1 or scale == 2 then
|
|
if noise == 1 then
|
|
if noise == 1 then
|
|
prefix = style .. "_noise1_scale_"
|
|
prefix = style .. "_noise1_scale_"
|
|
elseif noise == 2 then
|
|
elseif noise == 2 then
|
|
prefix = style .. "_noise2_scale_"
|
|
prefix = style .. "_noise2_scale_"
|
|
|
|
+ elseif noise == 3 then
|
|
|
|
+ prefix = style .. "_noise3_scale_"
|
|
else
|
|
else
|
|
prefix = style .. "_scale_"
|
|
prefix = style .. "_scale_"
|
|
end
|
|
end
|