1
0
Fork 0
mirror of synced 2024-05-21 05:12:21 +12:00

Add support for level 3 noise reduction on web

This commit is contained in:
nagadomi 2016-03-27 17:35:34 +09:00
parent 69ded0223a
commit ed9c8b7ea8
10 changed files with 63 additions and 3 deletions

View file

@ -106,6 +106,12 @@
Alto
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
Highest
</span>
</label>
</div>
<div class="option-hint">
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.

View file

@ -106,6 +106,12 @@
Haute
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
Highest
</span>
</label>
</div>
<div class="option-hint">
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é.

View file

@ -106,6 +106,12 @@
High
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
Highest
</span>
</label>
</div>
<div class="option-hint">
You need use noise reduction if image actually has noise or it may cause opposite effect.

View file

@ -106,6 +106,12 @@
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
最高
</span>
</label>
</div>
<div class="option-hint">
イズ除去は細部が消えることがあります。JPEGイズがある場合に使用します。

View file

@ -106,6 +106,12 @@
Alta
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
Highest
</span>
</label>
</div>
<div class="option-hint">
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.

View file

@ -106,6 +106,12 @@
Сильно
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
Highest
</span>
</label>
</div>
<div class="option-hint">
Устранение шума нужно использовать, если на картинке действительно есть шум, иначе это даст противоположный эффект.

22
web.lua
View file

@ -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

View file

@ -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

View file

@ -14,6 +14,7 @@ expect_jpeg: JPEGイズを想定
nr_none: なし
nr_medium:
nr_high:
nr_highest: 最高
nr_hint: "イズ除去は細部が消えることがあります。JPEGイズがある場合に使用します。"
upscaling: 拡大
up_none: なし

View file

@ -106,6 +106,12 @@
<%= t[:nr_high] %>
</span>
</label>
<label>
<input type="radio" name="noise" class="radio" value="3">
<span class="r-text">
<%= t[:nr_highest] %>
</span>
</label>
</div>
<div class="option-hint">
<%= t[:nr_hint] %>