1
0
Fork 0
mirror of synced 2024-06-22 04:40:15 +12:00

super typo fix

This commit is contained in:
nagadomi 2015-05-19 16:47:52 +09:00
parent 21391087b3
commit ffd52fdb2b
5 changed files with 18 additions and 18 deletions

View file

@ -1,7 +1,7 @@
require 'image'
local gm = require 'graphicsmagick'
local iproc = require './iproc'
local reconstract = require './reconstract'
local reconstruct = require './reconstruct'
local pairwise_transform = {}
function pairwise_transform.scale(src, scale, size, offset, options)
@ -55,7 +55,7 @@ function pairwise_transform.scale(src, scale, size, offset, options)
end
end
if options.denoise_model and (options.denoise_ratio or 0.5) > torch.uniform() then
x = reconstract(options.denoise_model, x:float():div(255), offset):mul(255):byte()
x = reconstruct(options.denoise_model, x:float():div(255), offset):mul(255):byte()
end
x = iproc.scale(x, y:size(3), y:size(2))
y = y:float():div(255)

View file

@ -1,7 +1,7 @@
require 'image'
local iproc = require './iproc'
local function reconstract_layer(model, x, block_size, offset)
local function reconstruct_layer(model, x, block_size, offset)
if x:dim() == 2 then
x = x:reshape(1, x:size(1), x:size(2))
end
@ -26,7 +26,7 @@ local function reconstract_layer(model, x, block_size, offset)
end
return new_x
end
local function reconstract(model, x, offset, block_size)
local function reconstruct(model, x, offset, block_size)
block_size = block_size or 128
local output_size = block_size - offset * 2
local h_blocks = math.floor(x:size(2) / output_size) +
@ -41,7 +41,7 @@ local function reconstract(model, x, offset, block_size)
local pad_h2 = (h - offset) - x:size(2)
local pad_w2 = (w - offset) - x:size(3)
local yuv = image.rgb2yuv(iproc.padding(x, pad_w1, pad_w2, pad_h1, pad_h2))
local y = reconstract_layer(model, yuv[1], block_size, offset)
local y = reconstruct_layer(model, yuv[1], block_size, offset)
y[torch.lt(y, 0)] = 0
y[torch.gt(y, 1)] = 1
yuv[1]:copy(y)
@ -55,4 +55,4 @@ local function reconstract(model, x, offset, block_size)
return output
end
return reconstract
return reconstruct

View file

@ -8,7 +8,7 @@ local settings = require './lib/settings'
local minibatch_adam = require './lib/minibatch_adam'
local iproc = require './lib/iproc'
local create_model = require './lib/srcnn'
local reconstract, reconstract_ch = require './lib/reconstract'
local reconstruct = require './lib/reconstruct'
local pairwise_transform = require './lib/pairwise_transform'
local image_loader = require './lib/image_loader'
@ -16,12 +16,12 @@ local function save_test_scale(model, rgb, file)
local input = iproc.scale(rgb,
rgb:size(3) * settings.scale,
rgb:size(2) * settings.scale)
local up = reconstract(model, input, settings.block_offset)
local up = reconstruct(model, input, settings.block_offset)
image.save(file, up)
end
local function save_test_jpeg(model, rgb, file)
local im, count = reconstract(model, rgb, settings.block_offset)
local im, count = reconstruct(model, rgb, settings.block_offset)
image.save(file, im)
end
local function split_data(x, test_size)

View file

@ -4,7 +4,7 @@ require 'pl'
require './lib/LeakyReLU'
local iproc = require './lib/iproc'
local reconstract = require './lib/reconstract'
local reconstruct = require './lib/reconstruct'
local image_loader = require './lib/image_loader'
local BLOCK_OFFSET = 7
@ -37,12 +37,12 @@ local function waifu2x()
local model = torch.load(path.join(opt.model_dir,
("noise%d_model.t7"):format(opt.noise_level)), "ascii")
model:evaluate()
new_x = reconstract(model, x, BLOCK_OFFSET)
new_x = reconstruct(model, x, BLOCK_OFFSET)
elseif opt.m == "scale" then
local model = torch.load(path.join(opt.model_dir, "scale2.0x_model.t7"), "ascii")
model:evaluate()
x = iproc.scale(x, x:size(3) * 2.0, x:size(2) * 2.0)
new_x = reconstract(model, x, BLOCK_OFFSET)
new_x = reconstruct(model, x, BLOCK_OFFSET)
elseif opt.m == "noise_scale" then
local noise_model = torch.load(path.join(opt.model_dir,
("noise%d_model.t7"):format(opt.noise_level)), "ascii")
@ -50,9 +50,9 @@ local function waifu2x()
noise_model:evaluate()
scale_model:evaluate()
x = reconstract(noise_model, x, BLOCK_OFFSET)
x = reconstruct(noise_model, x, BLOCK_OFFSET)
x = iproc.scale(x, x:size(3) * 2.0, x:size(2) * 2.0)
new_x = reconstract(scale_model, x, BLOCK_OFFSET)
new_x = reconstruct(scale_model, x, BLOCK_OFFSET)
else
error("undefined method:" .. opt.method)
end

View file

@ -16,7 +16,7 @@ package.path = package.path .. ";" .. path.join(ROOT, 'lib', '?.lua')
require 'LeakyReLU'
local iproc = require 'iproc'
local reconstract = require 'reconstract'
local reconstruct = require 'reconstruct'
local image_loader = require 'image_loader'
local noise1_model = torch.load(path.join(ROOT, "models", "noise1_model.t7"), "ascii")
@ -74,13 +74,13 @@ local function get_image(req)
end
local function apply_denoise1(x)
return reconstract(noise1_model, x, BLOCK_OFFSET)
return reconstruct(noise1_model, x, BLOCK_OFFSET)
end
local function apply_denoise2(x)
return reconstract(noise2_model, x, BLOCK_OFFSET)
return reconstruct(noise2_model, x, BLOCK_OFFSET)
end
local function apply_scale2x(x)
return reconstract(scale20_model,
return reconstruct(scale20_model,
iproc.scale(x, x:size(3) * 2.0, x:size(2) * 2.0),
BLOCK_OFFSET)
end