nagadomi 7 سال پیش
والد
کامیت
4ec0b4530d

+ 2 - 0
NOTICE

@@ -1,2 +1,4 @@
 images/miku_*: CC BY-NC by piapro (http://piapro.net/en_for_creators.html)
 webgen/assets/bg.png: Generated by chibichara maker (http://tetrabo.com/chibichara/).
+lib/sRGB2014.lua: sRGB2014.icc from http://www.color.org/srgbprofiles.xalter
+

+ 1 - 1
README.md

@@ -39,7 +39,7 @@ git pull
 
 [Third-Party](https://github.com/nagadomi/waifu2x/wiki/Third-Party)
 
-If you are a windows user, I recommend you to use [waifu2x-caffe](https://github.com/lltcggie/waifu2x-caffe)(Just download from `releases` tab) or [waifu2x-conver-cpp](https://github.com/tanakamura/waifu2x-converter-cpp).
+If you are a windows user, I recommend you to use [waifu2x-caffe](https://github.com/lltcggie/waifu2x-caffe)(Just download from `releases` tab) or [waifu2x-conver-cpp](https://github.com/DeadSix27/waifu2x-converter-cpp).
 
 ## Dependencies
 

+ 2 - 0
appendix/waifu2x.nginx.conf

@@ -17,6 +17,8 @@ map $http_accept_language $lang {
   ~zh-TW zh-TW;
   ~zh zh-CN;
   ~ko ko;
+  ~nl nl;
+  ~ca ca;
   ~en en;
 }
 

+ 195 - 0
assets/index.ca.html

@@ -0,0 +1,195 @@
+<!DOCTYPE html> 
+<html lang="ca">
+  <!-- This file was automatically generated by webgen/gen.rb. Do not make changes to this file manually. -->
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta charset="utf-8">
+    <link rel="shortcut icon" href="favicon.ico"/>
+    <meta name="viewport" content="initial-scale=1.0,width=device-width">
+    <link href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css" rel="stylesheet" type="text/css">
+    <link href="style.css" rel="stylesheet" type="text/css">
+    <link href="mobile.css" rel="stylesheet" type="text/css" media="screen and (max-width: 768px) and (min-width: 0px)">
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.1/URI.min.js"></script>
+    <script type="text/javascript" src="ui.js"></script>
+    <title>waifu2x</title>
+  </head>
+  <body>
+    <div class="all-page">
+      <h1 class="main-title">waifu2x</h1>
+      <div class="choose-lang">
+	<a href="index.html">
+	  English
+	</a>
+	/
+	<a href="index.ja.html">
+	  日本語
+	</a>
+	/
+	<a href="index.ru.html">
+	  Русский
+	</a>
+	/
+	<a href="index.pt.html">
+	  Português
+	</a>
+	/
+	<a href="index.es.html">
+	  Español
+	</a>
+	/
+	<a href="index.fr.html">
+	  Français
+	</a>
+	/
+	<a href="index.de.html">
+	  Deutsch
+	</a>
+	/
+	<a href="index.tr.html">
+	  Türkçe
+	</a>
+	/
+	<a href="index.zh-CN.html">
+	  简体中文
+	</a>
+	/
+	<a href="index.zh-TW.html">
+	  繁體中文
+	</a>
+	/
+	<a href="index.ko.html">
+	  한국어
+	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
+      </div>
+      <p>Amplia la resolució d'il·lustracions d'estil anime utilitzant xarxes neuronals convolucionals profundes. I suporta fotos.</p>
+      <p class="margin1 link-box">
+	<a href="https://raw.githubusercontent.com/nagadomi/waifu2x/master/images/slide.png" class="blue-link" target="_blank">
+	  Mostra'n una demostració
+	</a>
+	| 
+	<a href="https://github.com/nagadomi/waifu2x" class="blue-link" target="_blank">
+	  Vés al GitHub
+	</a>
+      </p>
+      <form action="/api" method="POST" enctype="multipart/form-data" target="_blank">
+	<div class="option-box first">
+	  <div class="option-left">Escolliu una imatge:</div>
+	  <div class="option-right">
+	    <input type="text" id="url" name="url" placeholder="Escriviu una URL">
+	    <div class="option-right-small">
+	      O escolliu un fitxer: 
+	      <input type="file" id="file" name="file"></div>
+	  </div>
+	  <div class="option-hint file_limits">
+	    Límits: Mida: 5MB, Reducció de soroll: 3000x3000px, Sobreescalat: 1500x1500px.
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Estil:
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="style" class="radio" value="art" checked>
+	      <span class="r-text">
+		Il·lustració
+	      </span>
+	    </label>
+	    <label><input type="radio" name="style" class="radio" value="photo">
+	      <span class="r-text">
+		Foto
+	      </span>
+	    </label>
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Reducció de soroll:
+	    <div class="option-left-small">
+	      (espera artefactes JPEG)
+	    </div>
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="noise" class="radio" value="-1">
+	      <span class="r-text">
+		Cap
+	      </span>
+	    </label>
+	    <label><input type="radio" name="noise" class="radio" value="0" checked>
+	      <span class="r-text">
+		Baixa
+	      </span>
+	    </label>
+	    <label><input type="radio" name="noise" class="radio" value="1" checked>
+	      <span class="r-text">
+		Mitjana
+	      </span>
+	    </label>
+	    <label>
+	      <input type="radio" name="noise" class="radio" value="2">
+	      <span class="r-text">
+		Alta
+	      </span>
+	    </label>
+	    <label>
+	      <input type="radio" name="noise" class="radio" value="3">
+	      <span class="r-text">
+		Molt alta
+	      </span>
+	    </label>
+	  </div>
+	  <div class="option-hint">
+	    Utilitzeu la reducció de soroll si la imatge té soroll, si no, podeu aconseguir l'efecte contrari.
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Sobreescalat:
+	    <div class="option-left-small"></div>
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="scale" class="radio" value="-1" checked>
+	      <span class="r-text">
+		Cap
+	      </span>
+	    </label>
+	    <label><input type="radio" name="scale" class="radio" value="1">
+	      <span class="r-text">
+		1.6x
+	      </span>
+	    </label>
+	    <label><input type="radio" name="scale" class="radio" value="2">
+	      <span class="r-text">
+		2x
+	      </span>
+	    </label>
+	  </div>
+	</div>
+	
+	
+	  <input type="submit" class="button" value="Converteix">
+	
+	<input type="submit" name="download" value="Descarrega" class="button">
+	<div class="bottom-hint">
+	  <ul>
+	    
+	      <li>Si utilitzeu el Firefox, premeu la tecla Control+S per desar la imatge. L'opció "Desa la imatge" no funciona.</li>
+	    
+	  </ul>
+	</div>
+      </form>
+    </div>
+    <div class="bottom-info address">
+      <a href="https://github.com/nagadomi/waifu2x" class="gray-link" target="_blank">waifu2x</a>
+    </div>
+  </body>
+</html>

+ 8 - 0
assets/index.de.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Einzelbild Super-Auflösungs Konvertierung für Bilder im Anime Stil mithilfe eines künstlichen neuronalen Netzwerk. Zusätzlich dazu unterstützt es auch Fotos.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.es.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Mejora la resolución de ilustraciones de tipo anime utilizando redes neuronales convolucionales. También es compatible con fotografías.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.fr.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Outil permettant la mise à l'échelle de n'importe quelle image de style "anime", par le biais de réseaux de neurones convolutionnels. Fonctionne également sur les photos.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Single-Image Super-Resolution for Anime-Style Art using Deep Convolutional Neural Networks. And it supports photo.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.ja.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>深層畳み込みニューラルネットワークによる二次元画像のための超解像システム。 写真にも対応。</p>
       <p class="margin1 link-box">

+ 17 - 9
assets/index.ko.html

@@ -62,11 +62,19 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
-      <p>컨볼루젼 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림 뿐만 아니라 사진에도 대응합니다.</p>
+      <p>컨볼루 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림뿐만 아니라 사진도 지원합니다.</p>
       <p class="margin1 link-box">
 	<a href="https://raw.githubusercontent.com/nagadomi/waifu2x/master/images/slide.png" class="blue-link" target="_blank">
-	  실제 데모 보기
+	  실제 예제 보기
 	</a>
 	| 
 	<a href="https://github.com/nagadomi/waifu2x" class="blue-link" target="_blank">
@@ -83,7 +91,7 @@
 	      <input type="file" id="file" name="file"></div>
 	  </div>
 	  <div class="option-hint file_limits">
-	    제한: 크기: 5MB, 노이즈 감소: 3000x3000px, 업스케일링: 1500x1500px.
+	    제한: 크기: 5MB, 노이즈 감소: 3000x3000px, 확대: 1500x1500px.
 	  </div>
 	</div>
 	<div class="option-box">
@@ -107,7 +115,7 @@
 	  <div class="option-left">
 	    노이즈 감소:
 	    <div class="option-left-small">
-	      (JPEG 아티팩트 제외)
+	      (JPEG 이미지에 권장)
 	    </div>
 	  </div>
 	  <div class="option-right">
@@ -118,7 +126,7 @@
 	    </label>
 	    <label><input type="radio" name="noise" class="radio" value="0" checked>
 	      <span class="r-text">
-		Low
+		낮음
 	      </span>
 	    </label>
 	    <label><input type="radio" name="noise" class="radio" value="1" checked>
@@ -135,17 +143,17 @@
 	    <label>
 	      <input type="radio" name="noise" class="radio" value="3">
 	      <span class="r-text">
-		최
+		최
 	      </span>
 	    </label>
 	  </div>
 	  <div class="option-hint">
-	    실제로 노이즈가 있는 이미지에만 사용해야 하며, 그렇지 않을 경우 사진의 세세한 부분이 뭉개질 수 있습니다.
+	    실제로 노이즈가 있는 이미지에만 사용해야 하며, 그렇지 않을 경우 세세한 부분이 뭉개질 수 있습니다.
 	  </div>
 	</div>
 	<div class="option-box">
 	  <div class="option-left">
-	    업스케일링:
+	    확대:
 	    <div class="option-left-small"></div>
 	  </div>
 	  <div class="option-right">
@@ -174,7 +182,7 @@
 	<div class="bottom-hint">
 	  <ul>
 	    
-	      <li>FireFox에서 이미지를 저장하려면 Ctrl+S를 누르세요. 오른쪽 클릭 > "이미지 저장"을 이용하면 정상적으로 동작하지 않습니다.</li>
+	      <li>Firefox에서 이미지를 저장하려면 Ctrl+S를 누르십시오. ‘이미지 저장’ 옵션은 작동하지 않습니다.</li>
 	    
 	  </ul>
 	</div>

+ 195 - 0
assets/index.nl.html

@@ -0,0 +1,195 @@
+<!DOCTYPE html> 
+<html lang="nl">
+  <!-- This file was automatically generated by webgen/gen.rb. Do not make changes to this file manually. -->
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta charset="utf-8">
+    <link rel="shortcut icon" href="favicon.ico"/>
+    <meta name="viewport" content="initial-scale=1.0,width=device-width">
+    <link href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css" rel="stylesheet" type="text/css">
+    <link href="style.css" rel="stylesheet" type="text/css">
+    <link href="mobile.css" rel="stylesheet" type="text/css" media="screen and (max-width: 768px) and (min-width: 0px)">
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.1/URI.min.js"></script>
+    <script type="text/javascript" src="ui.js"></script>
+    <title>waifu2x</title>
+  </head>
+  <body>
+    <div class="all-page">
+      <h1 class="main-title">waifu2x</h1>
+      <div class="choose-lang">
+	<a href="index.html">
+	  English
+	</a>
+	/
+	<a href="index.ja.html">
+	  日本語
+	</a>
+	/
+	<a href="index.ru.html">
+	  Русский
+	</a>
+	/
+	<a href="index.pt.html">
+	  Português
+	</a>
+	/
+	<a href="index.es.html">
+	  Español
+	</a>
+	/
+	<a href="index.fr.html">
+	  Français
+	</a>
+	/
+	<a href="index.de.html">
+	  Deutsch
+	</a>
+	/
+	<a href="index.tr.html">
+	  Türkçe
+	</a>
+	/
+	<a href="index.zh-CN.html">
+	  简体中文
+	</a>
+	/
+	<a href="index.zh-TW.html">
+	  繁體中文
+	</a>
+	/
+	<a href="index.ko.html">
+	  한국어
+	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
+      </div>
+      <p>Single-Image Super-Resolutie voor Anime-Style afbeeldingen met behulp van Deep Convolutional Neural Networks. Oh, en het ondersteunt foto's.</p>
+      <p class="margin1 link-box">
+	<a href="https://raw.githubusercontent.com/nagadomi/waifu2x/master/images/slide.png" class="blue-link" target="_blank">
+	  Toon volledige demonstratie
+	</a>
+	| 
+	<a href="https://github.com/nagadomi/waifu2x" class="blue-link" target="_blank">
+	  Ga naar GitHub
+	</a>
+      </p>
+      <form action="/api" method="POST" enctype="multipart/form-data" target="_blank">
+	<div class="option-box first">
+	  <div class="option-left">Afbeelding selecteren:</div>
+	  <div class="option-right">
+	    <input type="text" id="url" name="url" placeholder="Typ je URL">
+	    <div class="option-right-small">
+	      Of selecteer een bestand: 
+	      <input type="file" id="file" name="file"></div>
+	  </div>
+	  <div class="option-hint file_limits">
+	    Limieten: Grootte: 5MB, Ruis vermindering: 3000x3000px, Vergroting: 1500x1500px.
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Stijl:
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="style" class="radio" value="art" checked>
+	      <span class="r-text">
+		Artwork
+	      </span>
+	    </label>
+	    <label><input type="radio" name="style" class="radio" value="photo">
+	      <span class="r-text">
+		Foto
+	      </span>
+	    </label>
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Ruis vermindering:
+	    <div class="option-left-small">
+	      (verwacht JPEG artifact)
+	    </div>
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="noise" class="radio" value="-1">
+	      <span class="r-text">
+		Geen
+	      </span>
+	    </label>
+	    <label><input type="radio" name="noise" class="radio" value="0" checked>
+	      <span class="r-text">
+		Laag
+	      </span>
+	    </label>
+	    <label><input type="radio" name="noise" class="radio" value="1" checked>
+	      <span class="r-text">
+		Gemiddeld
+	      </span>
+	    </label>
+	    <label>
+	      <input type="radio" name="noise" class="radio" value="2">
+	      <span class="r-text">
+		Hoog
+	      </span>
+	    </label>
+	    <label>
+	      <input type="radio" name="noise" class="radio" value="3">
+	      <span class="r-text">
+		Hoogste
+	      </span>
+	    </label>
+	  </div>
+	  <div class="option-hint">
+	    Gebruik ruisvermindering alleen als de afbeelding ook daadwerkelijk ruis bevat, anders zal het effect omgekeerd zijn.
+	  </div>
+	</div>
+	<div class="option-box">
+	  <div class="option-left">
+	    Vergroting:
+	    <div class="option-left-small"></div>
+	  </div>
+	  <div class="option-right">
+	    <label><input type="radio" name="scale" class="radio" value="-1" checked>
+	      <span class="r-text">
+		Geen
+	      </span>
+	    </label>
+	    <label><input type="radio" name="scale" class="radio" value="1">
+	      <span class="r-text">
+		1.6x
+	      </span>
+	    </label>
+	    <label><input type="radio" name="scale" class="radio" value="2">
+	      <span class="r-text">
+		2x
+	      </span>
+	    </label>
+	  </div>
+	</div>
+	
+	
+	  <input type="submit" class="button" value="Converteer">
+	
+	<input type="submit" name="download" value="Download" class="button">
+	<div class="bottom-hint">
+	  <ul>
+	    
+	      <li>Als je gebruik maakt van FireFox, gebruik dan CTRL + S om een afbeelding op te slaan. De "Save Image" "Afbeelding Opslaan" optie werkt niet.</li>
+	    
+	  </ul>
+	</div>
+      </form>
+    </div>
+    <div class="bottom-info address">
+      <a href="https://github.com/nagadomi/waifu2x" class="gray-link" target="_blank">waifu2x</a>
+    </div>
+  </body>
+</html>

+ 8 - 0
assets/index.pt.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Single-Image Super-Resolution for Anime-Style Art using Deep Convolutional Neural Networks. And it supports photo.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.ru.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Waifu2x позволяет увеличивать в 2 раза рисованные изображения, например аниме или арт, а также устранять шум на изображении (преимущественно артефакты сжатия JPEG). Теперь также поддерживаются фотографии.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.tr.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>Derin Sarmalı Sinirsel Ağ ile çalışan anime stili çalışmalar için süper çözünürlük yükselticidir. Normal fotoğrafları da destekler.</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.zh-CN.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>本程序使用卷积神经网络对动漫风格的图片进行放大操作(支持照片)。</p>
       <p class="margin1 link-box">

+ 8 - 0
assets/index.zh-TW.html

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p>使用深度卷積神經網路的二次元圖片超解析系統。同時支援照片處理。</p>
       <p class="margin1 link-box">

+ 2 - 2
lib/compression.lua

@@ -1,5 +1,5 @@
 -- snapply compression for ByteTensor
-require 'snappy'
+local snappy = require 'snappy'
 
 local compression = {}
 compression.compress = function (bt)
@@ -9,7 +9,7 @@ end
 compression.decompress = function(data)
    local size = data[1]
    local dec = snappy.decompress(data[2]:string())
-   local bt = torch.ByteTensor(unpack(torch.totable(size)))
+   local bt = torch.ByteTensor(table.unpack(torch.totable(size)))
    bt:storage():string(dec)
    return bt
 end

+ 14 - 4
lib/image_loader.lua

@@ -1,10 +1,10 @@
 local gm = require 'graphicsmagick'
 local ffi = require 'ffi'
 local iproc = require 'iproc'
+local sRGB2014 = require 'sRGB2014'
 require 'pl'
 
 local image_loader = {}
-
 local clip_eps8 = (1.0 / 255.0) * 0.5 - (1.0e-7 * (1.0 / 255.0) * 0.5)
 local clip_eps16 = (1.0 / 65535.0) * 0.5 - (1.0e-7 * (1.0 / 65535.0) * 0.5)
 local background_color = 0.5
@@ -51,6 +51,10 @@ function image_loader.encode_png(rgb, options)
    if options.gamma then
       im:gamma(options.gamma)
    end
+   if options.icm and im.profile then
+      im:profile("icm", sRGB2014)
+      im:profile("icm", options.icm)
+   end
    return im:depth(options.depth):format("PNG"):toString()
 end
 function image_loader.save_png(filename, rgb, options)
@@ -70,7 +74,13 @@ function image_loader.decode_float(blob)
       local gamma_lcd = 0.454545
       
       im:fromBlob(blob, #blob)
-      
+      if im.profile then
+	 meta.icm = im:profile("icm")
+	 if meta.icm then
+	    im:profile("icm", sRGB2014)
+	    im:removeProfile()
+	 end
+      end
       if im:colorspace() == "CMYK" then
 	 im:colorspace("RGB")
       end
@@ -125,7 +135,7 @@ function image_loader.load_float(file)
    if not fp then
       error(file .. ": failed to load image")
    end
-   local buff = fp:read("*a")
+   local buff = fp:read("*all")
    fp:close()
    return image_loader.decode_float(buff)
 end
@@ -134,7 +144,7 @@ function image_loader.load_byte(file)
    if not fp then
       error(file .. ": failed to load image")
    end
-   local buff = fp:read("*a")
+   local buff = fp:read("*all")
    fp:close()
    return image_loader.decode_byte(buff)
 end

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 0
lib/sRGB2014.lua


+ 4 - 0
lib/settings.lua

@@ -169,5 +169,9 @@ settings.images = string.format("%s/images.t7", settings.data_dir)
 settings.image_list = string.format("%s/image_list.txt", settings.data_dir)
 
 cutorch.setDevice(opt.gpu)
+-- patch for lua52
+if not math.log10 then
+   math.log10 = function(x) return math.log(x, 10) end
+end
 
 return settings

+ 5 - 0
tools/benchmark.lua

@@ -82,6 +82,11 @@ if opt.output_dir:len() > 0 then
    dir.makepath(opt.output_dir)
 end
 
+-- patch for lua52
+if not math.log10 then
+   math.log10 = function(x) return math.log(x, 10) end
+end
+
 local function rgb2y_matlab(x)
    local y = torch.Tensor(1, x:size(2), x:size(3)):zero()
    x = iproc.byte2float(x)

+ 78 - 17
web.lua

@@ -12,6 +12,7 @@ local iproc = require 'iproc'
 local reconstruct = require 'reconstruct'
 local image_loader = require 'image_loader'
 local alpha_util = require 'alpha_util'
+local compression = require 'compression'
 local gm = require 'graphicsmagick'
 
 -- Note:  turbo and xlua has different implementation of string:split().
@@ -34,6 +35,7 @@ cmd:option("-curl_request_timeout", 60, "request_timeout for curl")
 cmd:option("-curl_connect_timeout", 60, "connect_timeout for curl")
 cmd:option("-curl_max_redirects", 2, "max_redirects for curl")
 cmd:option("-max_body_size", 5 * 1024 * 1024, "maximum allowed size for uploaded files")
+cmd:option("-cache_max", 200, "number of cached images on RAM")
 
 local opt = cmd:parse(arg)
 cutorch.setDevice(opt.gpu)
@@ -75,6 +77,7 @@ local CLEANUP_MODEL = false -- if you are using the low memory GPU, you could us
 local CACHE_DIR = path.join(ROOT, "cache")
 local MAX_NOISE_IMAGE = opt.max_pixels
 local MAX_SCALE_IMAGE = (math.sqrt(opt.max_pixels) / 2)^2
+local PNG_DEPTH = 8
 local CURL_OPTIONS = {
    request_timeout = opt.curl_request_timeout,
    connect_timeout = opt.curl_connect_timeout,
@@ -167,26 +170,73 @@ local function cleanup_model(model)
       model:clearState() -- release GPU memory
    end
 end
+
+-- cache
+local g_cache = {}
+local function cache_count()
+   local count = 0
+   for _ in pairs(g_cache) do
+      count = count + 1
+   end
+   return count
+end
+local function cache_remove_old()
+   local old_time = nil
+   local old_key = nil
+   for k, v in pairs(g_cache) do
+      if old_time == nil or old_time > v.updated_at then
+	 old_key = k
+	 old_time = v.updated_at
+      end
+   end
+   if old_key then
+      g_cache[old_key] = nil
+   end
+end
+local function cache_compress(raw_image)
+   if raw_image then
+      compressed_image = compression.compress(iproc.float2byte(raw_image))
+      return compressed_image
+   else
+      return nil
+   end
+end
+local function cache_decompress(compressed_image)
+   if compressed_image then
+      local raw_image = compression.decompress(compressed_image)
+      return iproc.byte2float(raw_image)
+   else
+      return nil
+   end
+end
+local function cache_get(filename)
+   local cache = g_cache[filename]
+   if cache then
+      return {image = cache_decompress(cache.image),
+	      alpha = cache_decompress(cache.alpha)}
+   else
+      return nil
+   end
+end
+local function cache_put(filename, image, alpha)
+   g_cache[filename] = {image = cache_compress(image),
+			alpha = cache_compress(alpha),
+			updated_at = os.time()};
+   local count = cache_count(g_cache)
+   if count > opt.cache_max then
+      cache_remove_old()
+   end
+end
 local function convert(x, meta, options)
    local cache_file = path.join(CACHE_DIR, options.prefix .. ".png")
-   local alpha_cache_file = path.join(CACHE_DIR, options.alpha_prefix .. ".png")
    local alpha = meta.alpha
    local alpha_orig = alpha
+   local cache = cache_get(cache_file)
 
-   if path.exists(alpha_cache_file) then
-      alpha = image_loader.load_float(alpha_cache_file)
-      if alpha:dim() == 2 then
-	 alpha = alpha:reshape(1, alpha:size(1), alpha:size(2))
-      end
-      if alpha:size(1) == 3 then
-	 alpha = image.rgb2y(alpha)
-      end
-   end
-   if path.exists(cache_file) then
-      x = image_loader.load_float(cache_file)
+   if cache then
       meta = tablex.copy(meta)
-      meta.alpha = alpha
-      return x, meta
+      meta.alpha = cache.alpha
+      return cache.image, meta
    else
       local model = nil
       if options.style == "art" then
@@ -209,7 +259,6 @@ local function convert(x, meta, options)
 	    if not (alpha:size(2) == x:size(2) and alpha:size(3) == x:size(3)) then
 	       alpha = reconstruct.scale(model.scale, 2.0, alpha,
 					 opt.crop_size, opt.batch_size)
-	       image_loader.save_png(alpha_cache_file, alpha)
 	       cleanup_model(model.scale)
 	    end
 	 end
@@ -223,7 +272,7 @@ local function convert(x, meta, options)
 				   x, opt.crop_size, opt.batch_size)
 	 cleanup_model(model[options.method])
       end
-      image_loader.save_png(cache_file, x)
+      cache_put(cache_file, x, alpha)
       meta = tablex.copy(meta)
       meta.alpha = alpha
       return x, meta
@@ -259,6 +308,12 @@ function APIHandler:post()
    local style = self:get_argument("style", "art")
    local download = (self:get_argument("download", "")):len()
 
+   if client_disconnected(self) then
+      self:set_status(400)
+      self:write("client disconnected")
+      return
+   end
+
    if tta_level == 0 then
       tta_level = auto_tta_level(x, scale)
    end
@@ -321,7 +376,7 @@ function APIHandler:post()
 	 name = uuid() .. ".png"
       end
       local blob = image_loader.encode_png(alpha_util.composite(x, meta.alpha),
-					   tablex.update({depth = 8, inplace = true}, meta))
+					   tablex.update({depth = PNG_DEPTH, inplace = true}, meta))
 
       self:set_header("Content-Length", string.format("%d", #blob))
       if download > 0 then
@@ -354,6 +409,8 @@ local index_tr = file.read(path.join(ROOT, "assets", "index.tr.html"))
 local index_zh_cn = file.read(path.join(ROOT, "assets", "index.zh-CN.html"))
 local index_zh_tw = file.read(path.join(ROOT, "assets", "index.zh-TW.html"))
 local index_ko = file.read(path.join(ROOT, "assets", "index.ko.html"))
+local index_nl = file.read(path.join(ROOT, "assets", "index.nl.html"))
+local index_ca = file.read(path.join(ROOT, "assets", "index.ca.html"))
 local index_en = file.read(path.join(ROOT, "assets", "index.html"))
 function FormHandler:get()
    local lang = self.request.headers:get("Accept-Language")
@@ -382,6 +439,10 @@ function FormHandler:get()
 	 self:write(index_zh_tw)
       elseif langs[1] == "ko" then
 	 self:write(index_ko)
+      elseif langs[1] == "nl" then
+	 self:write(index_nl)
+      elseif langs[1] == "ca" or langs[1] == "ca-ES" or langs[1] == "ca-FR" or langs[1] == "ca-IT" or langs[1] == "ca-AD" then
+	 self:write(index_ca)
       else
 	 self:write(index_en)
       end

+ 30 - 0
webgen/locales/ca.yml

@@ -0,0 +1,30 @@
+---
+description: Amplia la resolució d'il·lustracions d'estil anime utilitzant xarxes neuronals convolucionals profundes. I suporta fotos.
+show_demonstration: Mostra'n una demostració
+go_to_github: Vés al GitHub
+image_choosing: Escolliu una imatge
+type_url: Escriviu una URL
+choose_file: O escolliu un fitxer
+file_limits: "Límits: Mida: 5MB, Reducció de soroll: 3000x3000px, Sobreescalat: 1500x1500px."
+style: Estil
+artwork: Il·lustració
+photo: Foto
+noise_reduction: Reducció de soroll
+expect_jpeg: espera artefactes JPEG
+nr_none: Cap
+nr_low: Baixa
+nr_medium: Mitjana
+nr_high: Alta
+nr_highest: Molt alta
+nr_hint: "Utilitzeu la reducció de soroll si la imatge té soroll, si no, podeu aconseguir l'efecte contrari."
+upscaling: Sobreescalat
+up_none: Cap
+tta: TTA
+tta_best_effort: "n-pass auto"
+tta_rule: "Mostra la regla de `n-pass auto`."
+tta_hint: "El TTA estabilitza la qualitat però limita la mida de la imatge d'origen."
+button_convert: Converteix
+button_download: Descarrega
+hints:
+  - "Si utilitzeu el Firefox, premeu la tecla Control+S per desar la imatge. L'opció \"Desa la imatge\" no funciona."
+  

+ 9 - 8
webgen/locales/ko.yml

@@ -1,24 +1,25 @@
 ---
-description: 컨볼루 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림 뿐만 아니라 사진에도 대응합니다.
-show_demonstration: 실제 데모 보기
+description: 컨볼루 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림뿐만 아니라 사진도 지원합니다.
+show_demonstration: 실제 예제 보기
 go_to_github: GitHub에서 보기
 image_choosing: 이미지 선택
 type_url: URL 입력
 choose_file: 또는 파일 업로드
-file_limits: "제한: 크기: 5MB, 노이즈 감소: 3000x3000px, 업스케일링: 1500x1500px."
+file_limits: "제한: 크기: 5MB, 노이즈 감소: 3000x3000px, 확대: 1500x1500px."
 style: 스타일
 artwork: 그림
 photo: 사진
 noise_reduction: 노이즈 감소
-expect_jpeg: JPEG 아티팩트 제외
+expect_jpeg: JPEG 이미지에 권장
 nr_none: 없음
+nr_low: 낮음
 nr_medium: 중간
 nr_high: 높음
-nr_highest: 최
-nr_hint: "실제로 노이즈가 있는 이미지에만 사용해야 하며, 그렇지 않을 경우 사진의 세세한 부분이 뭉개질 수 있습니다."
-upscaling: 업스케일링
+nr_highest: 최
+nr_hint: "실제로 노이즈가 있는 이미지에만 사용해야 하며, 그렇지 않을 경우 세세한 부분이 뭉개질 수 있습니다."
+upscaling: 확대
 up_none: 없음
 button_convert: 변환
 button_download: 다운로드
 hints:
-  - "FireFox에서 이미지를 저장하려면 Ctrl+S를 누르세요. 오른쪽 클릭 > \"이미지 저장\"을 이용하면 정상적으로 동작하지 않습니다."
+  - "Firefox에서 이미지를 저장하려면 Ctrl+S를 누르십시오. ‘이미지 저장’ 옵션은 작동하지 않습니다."

+ 30 - 0
webgen/locales/nl.yml

@@ -0,0 +1,30 @@
+---
+description: Single-Image Super-Resolutie voor Anime-Style afbeeldingen met behulp van Deep Convolutional Neural Networks. Oh, en het ondersteunt foto's.
+show_demonstration: Toon volledige demonstratie
+go_to_github: Ga naar GitHub
+image_choosing: Afbeelding selecteren
+type_url: Typ je URL
+choose_file: Of selecteer een bestand
+file_limits: "Limieten: Grootte: 5MB, Ruis vermindering: 3000x3000px, Vergroting: 1500x1500px."
+style: Stijl
+artwork: Artwork
+photo: Foto
+noise_reduction: Ruis vermindering
+expect_jpeg: verwacht JPEG artifact
+nr_none: Geen
+nr_low: Laag
+nr_medium: Gemiddeld
+nr_high: Hoog
+nr_highest: Hoogste
+nr_hint: "Gebruik ruisvermindering alleen als de afbeelding ook daadwerkelijk ruis bevat, anders zal het effect omgekeerd zijn."
+upscaling: Vergroting
+up_none: Geen
+tta: TTA
+tta_best_effort: "n-pass auto"
+tta_rule: "Vertoon de `n-pass auto` optie."
+tta_hint: "TTA verzekerd een betere kwaliteit, maar het limiteerd de grootte van de afbeelding."
+button_convert: Converteer
+button_download: Download
+hints:
+  - "Als je gebruik maakt van FireFox, gebruik dan CTRL + S om een afbeelding op te slaan. De \"Save Image\" \"Afbeelding Opslaan\" optie werkt niet."
+  

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

@@ -62,6 +62,14 @@
 	<a href="index.ko.html">
 	  한국어
 	</a>
+	/
+	<a href="index.nl.html">
+	  Nederlands
+	</a>
+	/
+	<a href="index.ca.html">
+	  Català
+	</a>
       </div>
       <p><%= t[:description] %></p>
       <p class="margin1 link-box">

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است