Explorar o código

Add support for level 3 noise reduction on web

nagadomi %!s(int64=9) %!d(string=hai) anos
pai
achega
ed9c8b7ea8

+ 6 - 0
assets/index.es.html

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

+ 6 - 0
assets/index.fr.html

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

+ 6 - 0
assets/index.html

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

+ 6 - 0
assets/index.ja.html

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

+ 6 - 0
assets/index.pt.html

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

+ 6 - 0
assets/index.ru.html

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

+ 19 - 3
web.lua

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

+ 1 - 0
webgen/locales/en.yml

@@ -14,6 +14,7 @@ expect_jpeg: expect JPEG artifact
 nr_none: None
 nr_none: None
 nr_medium: Medium
 nr_medium: Medium
 nr_high: High
 nr_high: High
+nr_highest: Highest
 nr_hint: "You need use noise reduction if image actually has noise or it may cause opposite effect."
 nr_hint: "You need use noise reduction if image actually has noise or it may cause opposite effect."
 upscaling: Upscaling
 upscaling: Upscaling
 up_none: None
 up_none: None

+ 1 - 0
webgen/locales/ja.yml

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

+ 6 - 0
webgen/templates/index.html.erb

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