Fix filter name for graphicsmagick
graphicsmagick package has bug in the definition of FilteTypes. I will send PR to fix that bug. This commit is related to it. You should upgrade graphicsmagick package. $ luarocks install graphicsmagick
This commit is contained in:
parent
e9187ecf1c
commit
abedec9d9b
|
@ -7,7 +7,7 @@ local pairwise_transform = {}
|
|||
|
||||
local function random_half(src, p)
|
||||
if torch.uniform() < p then
|
||||
local filter = ({"Box","Box","Blackman","SincFast","Jinc"})[torch.random(1, 5)]
|
||||
local filter = ({"Box","Box","Blackman","Sinc","Lanczos"})[torch.random(1, 5)]
|
||||
return iproc.scale(src, src:size(3) * 0.5, src:size(2) * 0.5, filter)
|
||||
else
|
||||
return src
|
||||
|
@ -79,8 +79,8 @@ function pairwise_transform.scale(src, scale, size, offset, n, options)
|
|||
--"Cartom", -- 0.013753536746706
|
||||
--"Hanning", -- 0.013761314529647
|
||||
--"Hermite", -- 0.013850225205266
|
||||
"SincFast", -- 0.014095824314306
|
||||
"Jinc", -- 0.014244299255442
|
||||
"Sinc", -- 0.014095824314306
|
||||
"Lanczos", -- 0.014244299255442
|
||||
}
|
||||
local unstable_region_offset = 8
|
||||
local downscale_filter = filters[torch.random(1, #filters)]
|
||||
|
|
|
@ -105,7 +105,7 @@ function reconstruct.image_y(model, x, offset, block_size)
|
|||
end
|
||||
function reconstruct.scale_y(model, scale, x, offset, block_size)
|
||||
block_size = block_size or 128
|
||||
local x_jinc = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, "Jinc")
|
||||
local x_lanczos = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, "Lanczos")
|
||||
x = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, "Box")
|
||||
|
||||
local output_size = block_size - offset * 2
|
||||
|
@ -121,14 +121,14 @@ function reconstruct.scale_y(model, scale, x, offset, block_size)
|
|||
local pad_h2 = (h - offset) - x:size(2)
|
||||
local pad_w2 = (w - offset) - x:size(3)
|
||||
local yuv_nn = image.rgb2yuv(iproc.padding(x, pad_w1, pad_w2, pad_h1, pad_h2))
|
||||
local yuv_jinc = image.rgb2yuv(iproc.padding(x_jinc, pad_w1, pad_w2, pad_h1, pad_h2))
|
||||
local yuv_lanczos = image.rgb2yuv(iproc.padding(x_lanczos, pad_w1, pad_w2, pad_h1, pad_h2))
|
||||
local y = reconstruct_y(model, yuv_nn[1], offset, block_size)
|
||||
y[torch.lt(y, 0)] = 0
|
||||
y[torch.gt(y, 1)] = 1
|
||||
yuv_jinc[1]:copy(y)
|
||||
local output = image.yuv2rgb(iproc.crop(yuv_jinc,
|
||||
yuv_lanczos[1]:copy(y)
|
||||
local output = image.yuv2rgb(iproc.crop(yuv_lanczos,
|
||||
pad_w1, pad_h1,
|
||||
yuv_jinc:size(3) - pad_w2, yuv_jinc:size(2) - pad_h2))
|
||||
yuv_lanczos:size(3) - pad_w2, yuv_lanczos:size(2) - pad_h2))
|
||||
output[torch.lt(output, 0)] = 0
|
||||
output[torch.gt(output, 1)] = 1
|
||||
collectgarbage()
|
||||
|
|
|
@ -17,7 +17,7 @@ cmd:option("-dir", "./data/test", 'test image directory')
|
|||
cmd:option("-model1_dir", "./models/anime_style_art_rgb", 'model1 directory')
|
||||
cmd:option("-model2_dir", "", 'model2 directory (optional)')
|
||||
cmd:option("-method", "scale", '(scale|noise)')
|
||||
cmd:option("-filter", "Box", "downscaling filter (Box|Jinc)")
|
||||
cmd:option("-filter", "Box", "downscaling filter (Box|Lanczos)")
|
||||
cmd:option("-color", "rgb", '(rgb|y)')
|
||||
cmd:option("-noise_level", 1, 'model noise level')
|
||||
cmd:option("-jpeg_quality", 75, 'jpeg quality')
|
||||
|
|
Loading…
Reference in a new issue