diff --git a/NOTICE b/NOTICE index 021a888..47dd50f 100644 --- a/NOTICE +++ b/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 + diff --git a/README.md b/README.md index ae9abc1..0d55eff 100644 --- a/README.md +++ b/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 diff --git a/appendix/waifu2x.nginx.conf b/appendix/waifu2x.nginx.conf index b9e0541..71786f0 100644 --- a/appendix/waifu2x.nginx.conf +++ b/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; } diff --git a/assets/index.ca.html b/assets/index.ca.html new file mode 100644 index 0000000..7b43f9d --- /dev/null +++ b/assets/index.ca.html @@ -0,0 +1,195 @@ + + + +
+ + + + + + + + + + + +Amplia la resolució d'il·lustracions d'estil anime utilitzant xarxes neuronals convolucionals profundes. I suporta fotos.
+ + +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.
diff --git a/assets/index.es.html b/assets/index.es.html index 5e33cd7..833d939 100644 --- a/assets/index.es.html +++ b/assets/index.es.html @@ -62,6 +62,14 @@ 한국어 + / + + Nederlands + + / + + Català +
Mejora la resolución de ilustraciones de tipo anime utilizando redes neuronales convolucionales. También es compatible con fotografías.
diff --git a/assets/index.fr.html b/assets/index.fr.html index 38eb97d..ee53dfe 100644 --- a/assets/index.fr.html +++ b/assets/index.fr.html @@ -62,6 +62,14 @@ 한국어 + / + + Nederlands + + / + + Català +
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.
diff --git a/assets/index.html b/assets/index.html index b4f2dd1..97c52eb 100644 --- a/assets/index.html +++ b/assets/index.html @@ -62,6 +62,14 @@ 한국어 + / + + Nederlands + + / + + Català +
Single-Image Super-Resolution for Anime-Style Art using Deep Convolutional Neural Networks. And it supports photo.
diff --git a/assets/index.ja.html b/assets/index.ja.html index 736a535..2a90683 100644 --- a/assets/index.ja.html +++ b/assets/index.ja.html @@ -62,6 +62,14 @@ 한국어 + / + + Nederlands + + / + + Català +
深層畳み込みニューラルネットワークによる二次元画像のための超解像システム。 写真にも対応。
diff --git a/assets/index.ko.html b/assets/index.ko.html index e319857..01922b0 100644 --- a/assets/index.ko.html +++ b/assets/index.ko.html @@ -62,11 +62,19 @@ 한국어 + / + + Nederlands + + / + + Català + -
컨볼루젼 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림 뿐만 아니라 사진에도 대응합니다.
+컨볼루션 신경망(CNN) 시스템을 통한 딥 러닝으로 2차원 이미지의 해상도를 개선합니다. 그림뿐만 아니라 사진도 지원합니다.
- 실제 데모 보기
+ 실제 예제 보기
|
@@ -83,7 +91,7 @@
Single-Image Super-Resolutie voor Anime-Style afbeeldingen met behulp van Deep Convolutional Neural Networks. Oh, en het ondersteunt foto's.
+
+ Toon volledige demonstratie
+
+ |
+
+ Ga naar GitHub
+
+ Single-Image Super-Resolution for Anime-Style Art using Deep Convolutional Neural Networks. And it supports photo.
diff --git a/assets/index.ru.html b/assets/index.ru.html
index fbaf4e6..f7c0729 100644
--- a/assets/index.ru.html
+++ b/assets/index.ru.html
@@ -62,6 +62,14 @@
한국어
+ /
+
+ Nederlands
+
+ /
+
+ Català
+
Waifu2x позволяет увеличивать в 2 раза рисованные изображения, например аниме или арт, а также устранять шум на изображении (преимущественно артефакты сжатия JPEG). Теперь также поддерживаются фотографии.
diff --git a/assets/index.tr.html b/assets/index.tr.html
index 2315d8e..9f5199f 100644
--- a/assets/index.tr.html
+++ b/assets/index.tr.html
@@ -62,6 +62,14 @@
한국어
+ /
+
+ Nederlands
+
+ /
+
+ Català
+
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.
diff --git a/assets/index.zh-CN.html b/assets/index.zh-CN.html
index c7fff74..ac7ad21 100644
--- a/assets/index.zh-CN.html
+++ b/assets/index.zh-CN.html
@@ -62,6 +62,14 @@
한국어
+ /
+
+ Nederlands
+
+ /
+
+ Català
+
本程序使用卷积神经网络对动漫风格的图片进行放大操作(支持照片)。
diff --git a/assets/index.zh-TW.html b/assets/index.zh-TW.html
index 8bef4e5..7698cc0 100644
--- a/assets/index.zh-TW.html
+++ b/assets/index.zh-TW.html
@@ -62,6 +62,14 @@
한국어
+ /
+
+ Nederlands
+
+ /
+
+ Català
+
使用深度卷積神經網路的二次元圖片超解析系統。同時支援照片處理。
diff --git a/lib/compression.lua b/lib/compression.lua
index 6593c82..a31e0ed 100644
--- a/lib/compression.lua
+++ b/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
diff --git a/lib/image_loader.lua b/lib/image_loader.lua
index 56a994f..2d956f7 100644
--- a/lib/image_loader.lua
+++ b/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
diff --git a/lib/sRGB2014.lua b/lib/sRGB2014.lua
new file mode 100644
index 0000000..b6094df
--- /dev/null
+++ b/lib/sRGB2014.lua
@@ -0,0 +1,2 @@
+-- sRGB2014.icc
+return "\000\000\011\208\000\000\000\000\002\000\000\000\109\110\116\114\082\071\066\032\088\089\090\032\007\223\000\002\000\015\000\000\000\000\000\000\097\099\115\112\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\246\214\000\001\000\000\000\000\211\045\000\000\000\000\061\014\178\222\174\147\151\190\155\103\038\206\140\010\067\206\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\100\101\115\099\000\000\001\068\000\000\000\099\098\088\089\090\000\000\001\168\000\000\000\020\098\084\082\067\000\000\001\188\000\000\008\012\103\084\082\067\000\000\001\188\000\000\008\012\114\084\082\067\000\000\001\188\000\000\008\012\100\109\100\100\000\000\009\200\000\000\000\136\103\088\089\090\000\000\010\080\000\000\000\020\108\117\109\105\000\000\010\100\000\000\000\020\109\101\097\115\000\000\010\120\000\000\000\036\098\107\112\116\000\000\010\156\000\000\000\020\114\088\089\090\000\000\010\176\000\000\000\020\116\101\099\104\000\000\010\196\000\000\000\012\118\117\101\100\000\000\010\208\000\000\000\135\119\116\112\116\000\000\011\088\000\000\000\020\099\112\114\116\000\000\011\108\000\000\000\055\099\104\097\100\000\000\011\164\000\000\000\044\100\101\115\099\000\000\000\000\000\000\000\009\115\082\071\066\050\048\049\052\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\088\089\090\032\000\000\000\000\000\000\036\160\000\000\015\132\000\000\182\207\099\117\114\118\000\000\000\000\000\000\004\000\000\000\000\005\000\010\000\015\000\020\000\025\000\030\000\035\000\040\000\045\000\050\000\055\000\059\000\064\000\069\000\074\000\079\000\084\000\089\000\094\000\099\000\104\000\109\000\114\000\119\000\124\000\129\000\134\000\139\000\144\000\149\000\154\000\159\000\164\000\169\000\174\000\178\000\183\000\188\000\193\000\198\000\203\000\208\000\213\000\219\000\224\000\229\000\235\000\240\000\246\000\251\001\001\001\007\001\013\001\019\001\025\001\031\001\037\001\043\001\050\001\056\001\062\001\069\001\076\001\082\001\089\001\096\001\103\001\110\001\117\001\124\001\131\001\139\001\146\001\154\001\161\001\169\001\177\001\185\001\193\001\201\001\209\001\217\001\225\001\233\001\242\001\250\002\003\002\012\002\020\002\029\002\038\002\047\002\056\002\065\002\075\002\084\002\093\002\103\002\113\002\122\002\132\002\142\002\152\002\162\002\172\002\182\002\193\002\203\002\213\002\224\002\235\002\245\003\000\003\011\003\022\003\033\003\045\003\056\003\067\003\079\003\090\003\102\003\114\003\126\003\138\003\150\003\162\003\174\003\186\003\199\003\211\003\224\003\236\003\249\004\006\004\019\004\032\004\045\004\059\004\072\004\085\004\099\004\113\004\126\004\140\004\154\004\168\004\182\004\196\004\211\004\225\004\240\004\254\005\013\005\028\005\043\005\058\005\073\005\088\005\103\005\119\005\134\005\150\005\166\005\181\005\197\005\213\005\229\005\246\006\006\006\022\006\039\006\055\006\072\006\089\006\106\006\123\006\140\006\157\006\175\006\192\006\209\006\227\006\245\007\007\007\025\007\043\007\061\007\079\007\097\007\116\007\134\007\153\007\172\007\191\007\210\007\229\007\248\008\011\008\031\008\050\008\070\008\090\008\110\008\130\008\150\008\170\008\190\008\210\008\231\008\251\009\016\009\037\009\058\009\079\009\100\009\121\009\143\009\164\009\186\009\207\009\229\009\251\010\017\010\039\010\061\010\084\010\106\010\129\010\152\010\174\010\197\010\220\010\243\011\011\011\034\011\057\011\081\011\105\011\128\011\152\011\176\011\200\011\225\011\249\012\018\012\042\012\067\012\092\012\117\012\142\012\167\012\192\012\217\012\243\013\013\013\038\013\064\013\090\013\116\013\142\013\169\013\195\013\222\013\248\014\019\014\046\014\073\014\100\014\127\014\155\014\182\014\210\014\238\015\009\015\037\015\065\015\094\015\122\015\150\015\179\015\207\015\236\016\009\016\038\016\067\016\097\016\126\016\155\016\185\016\215\016\245\017\019\017\049\017\079\017\109\017\140\017\170\017\201\017\232\018\007\018\038\018\069\018\100\018\132\018\163\018\195\018\227\019\003\019\035\019\067\019\099\019\131\019\164\019\197\019\229\020\006\020\039\020\073\020\106\020\139\020\173\020\206\020\240\021\018\021\052\021\086\021\120\021\155\021\189\021\224\022\003\022\038\022\073\022\108\022\143\022\178\022\214\022\250\023\029\023\065\023\101\023\137\023\174\023\210\023\247\024\027\024\064\024\101\024\138\024\175\024\213\024\250\025\032\025\069\025\107\025\145\025\183\025\221\026\004\026\042\026\081\026\119\026\158\026\197\026\236\027\020\027\059\027\099\027\138\027\178\027\218\028\002\028\042\028\082\028\123\028\163\028\204\028\245\029\030\029\071\029\112\029\153\029\195\029\236\030\022\030\064\030\106\030\148\030\190\030\233\031\019\031\062\031\105\031\148\031\191\031\234\032\021\032\065\032\108\032\152\032\196\032\240\033\028\033\072\033\117\033\161\033\206\033\251\034\039\034\085\034\130\034\175\034\221\035\010\035\056\035\102\035\148\035\194\035\240\036\031\036\077\036\124\036\171\036\218\037\009\037\056\037\104\037\151\037\199\037\247\038\039\038\087\038\135\038\183\038\232\039\024\039\073\039\122\039\171\039\220\040\013\040\063\040\113\040\162\040\212\041\006\041\056\041\107\041\157\041\208\042\002\042\053\042\104\042\155\042\207\043\002\043\054\043\105\043\157\043\209\044\005\044\057\044\110\044\162\044\215\045\012\045\065\045\118\045\171\045\225\046\022\046\076\046\130\046\183\046\238\047\036\047\090\047\145\047\199\047\254\048\053\048\108\048\164\048\219\049\018\049\074\049\130\049\186\049\242\050\042\050\099\050\155\050\212\051\013\051\070\051\127\051\184\051\241\052\043\052\101\052\158\052\216\053\019\053\077\053\135\053\194\053\253\054\055\054\114\054\174\054\233\055\036\055\096\055\156\055\215\056\020\056\080\056\140\056\200\057\005\057\066\057\127\057\188\057\249\058\054\058\116\058\178\058\239\059\045\059\107\059\170\059\232\060\039\060\101\060\164\060\227\061\034\061\097\061\161\061\224\062\032\062\096\062\160\062\224\063\033\063\097\063\162\063\226\064\035\064\100\064\166\064\231\065\041\065\106\065\172\065\238\066\048\066\114\066\181\066\247\067\058\067\125\067\192\068\003\068\071\068\138\068\206\069\018\069\085\069\154\069\222\070\034\070\103\070\171\070\240\071\053\071\123\071\192\072\005\072\075\072\145\072\215\073\029\073\099\073\169\073\240\074\055\074\125\074\196\075\012\075\083\075\154\075\226\076\042\076\114\076\186\077\002\077\074\077\147\077\220\078\037\078\110\078\183\079\000\079\073\079\147\079\221\080\039\080\113\080\187\081\006\081\080\081\155\081\230\082\049\082\124\082\199\083\019\083\095\083\170\083\246\084\066\084\143\084\219\085\040\085\117\085\194\086\015\086\092\086\169\086\247\087\068\087\146\087\224\088\047\088\125\088\203\089\026\089\105\089\184\090\007\090\086\090\166\090\245\091\069\091\149\091\229\092\053\092\134\092\214\093\039\093\120\093\201\094\026\094\108\094\189\095\015\095\097\095\179\096\005\096\087\096\170\096\252\097\079\097\162\097\245\098\073\098\156\098\240\099\067\099\151\099\235\100\064\100\148\100\233\101\061\101\146\101\231\102\061\102\146\102\232\103\061\103\147\103\233\104\063\104\150\104\236\105\067\105\154\105\241\106\072\106\159\106\247\107\079\107\167\107\255\108\087\108\175\109\008\109\096\109\185\110\018\110\107\110\196\111\030\111\120\111\209\112\043\112\134\112\224\113\058\113\149\113\240\114\075\114\166\115\001\115\093\115\184\116\020\116\112\116\204\117\040\117\133\117\225\118\062\118\155\118\248\119\086\119\179\120\017\120\110\120\204\121\042\121\137\121\231\122\070\122\165\123\004\123\099\123\194\124\033\124\129\124\225\125\065\125\161\126\001\126\098\126\194\127\035\127\132\127\229\128\071\128\168\129\010\129\107\129\205\130\048\130\146\130\244\131\087\131\186\132\029\132\128\132\227\133\071\133\171\134\014\134\114\134\215\135\059\135\159\136\004\136\105\136\206\137\051\137\153\137\254\138\100\138\202\139\048\139\150\139\252\140\099\140\202\141\049\141\152\141\255\142\102\142\206\143\054\143\158\144\006\144\110\144\214\145\063\145\168\146\017\146\122\146\227\147\077\147\182\148\032\148\138\148\244\149\095\149\201\150\052\150\159\151\010\151\117\151\224\152\076\152\184\153\036\153\144\153\252\154\104\154\213\155\066\155\175\156\028\156\137\156\247\157\100\157\210\158\064\158\174\159\029\159\139\159\250\160\105\160\216\161\071\161\182\162\038\162\150\163\006\163\118\163\230\164\086\164\199\165\056\165\169\166\026\166\139\166\253\167\110\167\224\168\082\168\196\169\055\169\169\170\028\170\143\171\002\171\117\171\233\172\092\172\208\173\068\173\184\174\045\174\161\175\022\175\139\176\000\176\117\176\234\177\096\177\214\178\075\178\194\179\056\179\174\180\037\180\156\181\019\181\138\182\001\182\121\182\240\183\104\183\224\184\089\184\209\185\074\185\194\186\059\186\181\187\046\187\167\188\033\188\155\189\021\189\143\190\010\190\132\190\255\191\122\191\245\192\112\192\236\193\103\193\227\194\095\194\219\195\088\195\212\196\081\196\206\197\075\197\200\198\070\198\195\199\065\199\191\200\061\200\188\201\058\201\185\202\056\202\183\203\054\203\182\204\053\204\181\205\053\205\181\206\054\206\182\207\055\207\184\208\057\208\186\209\060\209\190\210\063\210\193\211\068\211\198\212\073\212\203\213\078\213\209\214\085\214\216\215\092\215\224\216\100\216\232\217\108\217\241\218\118\218\251\219\128\220\005\220\138\221\016\221\150\222\028\222\162\223\041\223\175\224\054\224\189\225\068\225\204\226\083\226\219\227\099\227\235\228\115\228\252\229\132\230\013\230\150\231\031\231\169\232\050\232\188\233\070\233\208\234\091\234\229\235\112\235\251\236\134\237\017\237\156\238\040\238\180\239\064\239\204\240\088\240\229\241\114\241\255\242\140\243\025\243\167\244\052\244\194\245\080\245\222\246\109\246\251\247\138\248\025\248\168\249\056\249\199\250\087\250\231\251\119\252\007\252\152\253\041\253\186\254\075\254\220\255\109\255\255\100\101\115\099\000\000\000\000\000\000\000\046\073\069\067\032\054\049\057\054\054\045\050\045\049\032\068\101\102\097\117\108\116\032\082\071\066\032\067\111\108\111\117\114\032\083\112\097\099\101\032\045\032\115\082\071\066\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\088\089\090\032\000\000\000\000\000\000\098\153\000\000\183\133\000\000\024\218\088\089\090\032\000\000\000\000\000\000\000\000\000\080\000\000\000\000\000\000\109\101\097\115\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\088\089\090\032\000\000\000\000\000\000\000\158\000\000\000\164\000\000\000\135\088\089\090\032\000\000\000\000\000\000\111\162\000\000\056\245\000\000\003\144\115\105\103\032\000\000\000\000\067\082\084\032\100\101\115\099\000\000\000\000\000\000\000\045\082\101\102\101\114\101\110\099\101\032\086\105\101\119\105\110\103\032\067\111\110\100\105\116\105\111\110\032\105\110\032\073\069\067\032\054\049\057\054\054\045\050\045\049\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\088\089\090\032\000\000\000\000\000\000\246\214\000\001\000\000\000\000\211\045\116\101\120\116\000\000\000\000\067\111\112\121\114\105\103\104\116\032\073\110\116\101\114\110\097\116\105\111\110\097\108\032\067\111\108\111\114\032\067\111\110\115\111\114\116\105\117\109\044\032\050\048\049\053\000\000\115\102\051\050\000\000\000\000\000\001\012\068\000\000\005\223\255\255\243\038\000\000\007\148\000\000\253\143\255\255\251\161\255\255\253\162\000\000\003\219\000\000\192\117"
diff --git a/lib/settings.lua b/lib/settings.lua
index 35f271f..fd9956e 100644
--- a/lib/settings.lua
+++ b/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
diff --git a/tools/benchmark.lua b/tools/benchmark.lua
index 7e93ac6..2ad101d 100644
--- a/tools/benchmark.lua
+++ b/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)
diff --git a/web.lua b/web.lua
index e27c88a..1e58433 100644
--- a/web.lua
+++ b/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
-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
- 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)
+-- 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 path.exists(cache_file) then
- x = image_loader.load_float(cache_file)
+ 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 = meta.alpha
+ local alpha_orig = alpha
+ local cache = cache_get(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
diff --git a/webgen/locales/ca.yml b/webgen/locales/ca.yml
new file mode 100644
index 0000000..3ae770d
--- /dev/null
+++ b/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."
+
diff --git a/webgen/locales/ko.yml b/webgen/locales/ko.yml
index c8e6d06..46befcd 100644
--- a/webgen/locales/ko.yml
+++ b/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를 누르십시오. ‘이미지 저장’ 옵션은 작동하지 않습니다."
diff --git a/webgen/locales/nl.yml b/webgen/locales/nl.yml
new file mode 100644
index 0000000..d740242
--- /dev/null
+++ b/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."
+
diff --git a/webgen/templates/index.html.erb b/webgen/templates/index.html.erb
index 9c26526..7cbcc32 100644
--- a/webgen/templates/index.html.erb
+++ b/webgen/templates/index.html.erb
@@ -62,6 +62,14 @@
한국어
+ /
+
+ Nederlands
+
+ /
+
+ Català
+
<%= t[:description] %>
-
waifu2x
+