|
@@ -105,10 +105,11 @@ function reconstruct.image_y(model, x, offset, block_size)
|
|
|
|
|
|
return output
|
|
|
end
|
|
|
-function reconstruct.scale_y(model, scale, x, offset, block_size)
|
|
|
+function reconstruct.scale_y(model, scale, x, offset, block_size, upsampling_filter)
|
|
|
+ upsampling_filter = upsampling_filter or "Box"
|
|
|
block_size = block_size or 128
|
|
|
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")
|
|
|
+ x = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, upsampling_filter)
|
|
|
if x:size(2) * x:size(3) > 2048*2048 then
|
|
|
collectgarbage()
|
|
|
end
|
|
@@ -173,9 +174,10 @@ function reconstruct.image_rgb(model, x, offset, block_size)
|
|
|
|
|
|
return output
|
|
|
end
|
|
|
-function reconstruct.scale_rgb(model, scale, x, offset, block_size)
|
|
|
+function reconstruct.scale_rgb(model, scale, x, offset, block_size, upsampling_filter)
|
|
|
+ upsampling_filter = upsampling_filter or "Box"
|
|
|
block_size = block_size or 128
|
|
|
- x = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, "Box")
|
|
|
+ x = iproc.scale(x, x:size(3) * scale, x:size(2) * scale, upsampling_filter)
|
|
|
if x:size(2) * x:size(3) > 2048*2048 then
|
|
|
collectgarbage()
|
|
|
end
|
|
@@ -230,7 +232,7 @@ function reconstruct.image(model, x, block_size)
|
|
|
end
|
|
|
return x
|
|
|
end
|
|
|
-function reconstruct.scale(model, scale, x, block_size)
|
|
|
+function reconstruct.scale(model, scale, x, block_size, upsampling_filter)
|
|
|
local i2rgb = false
|
|
|
if x:size(1) == 1 then
|
|
|
local new_x = torch.Tensor(3, x:size(2), x:size(3))
|
|
@@ -242,10 +244,14 @@ function reconstruct.scale(model, scale, x, block_size)
|
|
|
end
|
|
|
if reconstruct.is_rgb(model) then
|
|
|
x = reconstruct.scale_rgb(model, scale, x,
|
|
|
- reconstruct.offset_size(model), block_size)
|
|
|
+ reconstruct.offset_size(model),
|
|
|
+ block_size,
|
|
|
+ upsampling_filter)
|
|
|
else
|
|
|
x = reconstruct.scale_y(model, scale, x,
|
|
|
- reconstruct.offset_size(model), block_size)
|
|
|
+ reconstruct.offset_size(model),
|
|
|
+ block_size,
|
|
|
+ upsampling_filter)
|
|
|
end
|
|
|
if i2rgb then
|
|
|
x = image.rgb2y(x)
|
|
@@ -297,16 +303,16 @@ function reconstruct.image_tta(model, x, block_size)
|
|
|
return tta(reconstruct.image_y, model, x, block_size)
|
|
|
end
|
|
|
end
|
|
|
-function reconstruct.scale_tta(model, scale, x, block_size)
|
|
|
+function reconstruct.scale_tta(model, scale, x, block_size, upsampling_filter)
|
|
|
if reconstruct.is_rgb(model) then
|
|
|
local f = function (model, x, offset, block_size)
|
|
|
- return reconstruct.scale_rgb(model, scale, x, offset, block_size)
|
|
|
+ return reconstruct.scale_rgb(model, scale, x, offset, block_size, upsampling_filter)
|
|
|
end
|
|
|
return tta(f, model, x, block_size)
|
|
|
|
|
|
else
|
|
|
local f = function (model, x, offset, block_size)
|
|
|
- return reconstruct.scale_y(model, scale, x, offset, block_size)
|
|
|
+ return reconstruct.scale_y(model, scale, x, offset, block_size, upsampling_filter)
|
|
|
end
|
|
|
return tta(f, model, x, block_size)
|
|
|
end
|