From ed9c8b7ea83b05b7cfae542a743aab04c82ef687 Mon Sep 17 00:00:00 2001 From: nagadomi Date: Sun, 27 Mar 2016 17:35:34 +0900 Subject: [PATCH] Add support for level 3 noise reduction on web --- assets/index.es.html | 6 ++++++ assets/index.fr.html | 6 ++++++ assets/index.html | 6 ++++++ assets/index.ja.html | 6 ++++++ assets/index.pt.html | 6 ++++++ assets/index.ru.html | 6 ++++++ web.lua | 22 +++++++++++++++++++--- webgen/locales/en.yml | 1 + webgen/locales/ja.yml | 1 + webgen/templates/index.html.erb | 6 ++++++ 10 files changed, 63 insertions(+), 3 deletions(-) diff --git a/assets/index.es.html b/assets/index.es.html index eb7e16f..53b84be 100644 --- a/assets/index.es.html +++ b/assets/index.es.html @@ -106,6 +106,12 @@ Alto +
Es necesario utilizar la reducción de ruido si la imagen dispone de artefactos de compresión; de lo contrario podría producir el efecto opuesto. diff --git a/assets/index.fr.html b/assets/index.fr.html index 39fb549..566c976 100644 --- a/assets/index.fr.html +++ b/assets/index.fr.html @@ -106,6 +106,12 @@ Haute +
Il est nécessaire d'utiliser la réduction du bruit si l'image possède du bruit. Autrement, cela risque de causer l'effet opposé. diff --git a/assets/index.html b/assets/index.html index cfa4771..472eb52 100644 --- a/assets/index.html +++ b/assets/index.html @@ -106,6 +106,12 @@ High +
You need use noise reduction if image actually has noise or it may cause opposite effect. diff --git a/assets/index.ja.html b/assets/index.ja.html index eaa819f..e3d0097 100644 --- a/assets/index.ja.html +++ b/assets/index.ja.html @@ -106,6 +106,12 @@ 高 +
ノイズ除去は細部が消えることがあります。JPEGノイズがある場合に使用します。 diff --git a/assets/index.pt.html b/assets/index.pt.html index f8ccaba..b01ee31 100644 --- a/assets/index.pt.html +++ b/assets/index.pt.html @@ -106,6 +106,12 @@ Alta +
Quando usando a escala 2x, Nós nunca recomendamos usar um nível alto de redução de ruído, quase sempre deixa a imagem pior, faz sentido apenas para casos raros quando a imagem tinha uma qualidade muito má desde o começo. diff --git a/assets/index.ru.html b/assets/index.ru.html index 38f49b0..1ccc5cb 100644 --- a/assets/index.ru.html +++ b/assets/index.ru.html @@ -106,6 +106,12 @@ Сильно +
Устранение шума нужно использовать, если на картинке действительно есть шум, иначе это даст противоположный эффект. diff --git a/web.lua b/web.lua index 1847230..eaf1480 100644 --- a/web.lua +++ b/web.lua @@ -38,12 +38,14 @@ if cudnn then end local ART_MODEL_DIR = path.join(ROOT, "models", "anime_style_art_rgb") 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_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_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_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 CACHE_DIR = path.join(ROOT, "cache") local MAX_NOISE_IMAGE = 2560 * 2560 @@ -151,9 +153,12 @@ local function convert(x, alpha, options) elseif options.method == "noise1" then x = reconstruct.image(art_noise1_model, x) cleanup_model(art_noise1_model) - else -- options.method == "noise2" + elseif options.method == "noise2" then x = reconstruct.image(art_noise2_model, x) cleanup_model(art_noise2_model) + elseif options.method == "noise3" then + x = reconstruct.image(art_noise3_model, x) + cleanup_model(art_noise3_model) end else -- photo if options.border then @@ -174,6 +179,9 @@ local function convert(x, alpha, options) elseif options.method == "noise2" then x = reconstruct.image(photo_noise2_model, x) cleanup_model(photo_noise2_model) + elseif options.method == "noise3" then + x = reconstruct.image(photo_noise3_model, x) + cleanup_model(photo_noise3_model) end end image_loader.save_png(cache_file, x) @@ -229,17 +237,25 @@ function APIHandler:post() alpha_prefix = alpha_prefix, border = border}) border = false elseif noise == 2 then - prefix = style .. "_noise1_" + prefix = style .. "_noise2_" x = convert(x, alpha, {method = "noise2", style = style, prefix = prefix .. hash, alpha_prefix = alpha_prefix, border = border}) 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 if scale == 1 or scale == 2 then if noise == 1 then prefix = style .. "_noise1_scale_" elseif noise == 2 then prefix = style .. "_noise2_scale_" + elseif noise == 3 then + prefix = style .. "_noise3_scale_" else prefix = style .. "_scale_" end diff --git a/webgen/locales/en.yml b/webgen/locales/en.yml index 76723fd..72bdd8a 100644 --- a/webgen/locales/en.yml +++ b/webgen/locales/en.yml @@ -14,6 +14,7 @@ expect_jpeg: expect JPEG artifact nr_none: None nr_medium: Medium nr_high: High +nr_highest: Highest nr_hint: "You need use noise reduction if image actually has noise or it may cause opposite effect." upscaling: Upscaling up_none: None diff --git a/webgen/locales/ja.yml b/webgen/locales/ja.yml index c6e3ee6..1a494e3 100644 --- a/webgen/locales/ja.yml +++ b/webgen/locales/ja.yml @@ -14,6 +14,7 @@ expect_jpeg: JPEGノイズを想定 nr_none: なし nr_medium: 中 nr_high: 高 +nr_highest: 最高 nr_hint: "ノイズ除去は細部が消えることがあります。JPEGノイズがある場合に使用します。" upscaling: 拡大 up_none: なし diff --git a/webgen/templates/index.html.erb b/webgen/templates/index.html.erb index 3cf479b..2c3c73e 100644 --- a/webgen/templates/index.html.erb +++ b/webgen/templates/index.html.erb @@ -106,6 +106,12 @@ <%= t[:nr_high] %> +
<%= t[:nr_hint] %>