1
0
Fork 0
mirror of synced 2024-06-13 08:24:30 +12:00

more flip

This commit is contained in:
nagadomi 2015-11-09 23:44:43 +09:00
parent 7ac7923345
commit eaeaef10b7
2 changed files with 22 additions and 6 deletions

View file

@ -77,10 +77,16 @@ function data_augmentation.shift_1px(src)
end
function data_augmentation.flip(src)
local flip = torch.random(1, 4)
local tr = torch.random(1, 2)
local src, conversion = iproc.byte2float(src)
local dest
src = src:contiguous()
if tr == 1 then
-- pass
elseif tr == 2 then
src = src:transpose(2, 3):contiguous()
end
if flip == 1 then
dest = image.hflip(src)
elseif flip == 2 then

View file

@ -206,13 +206,18 @@ function pairwise_transform.jpeg(src, style, level, size, offset, n, options)
end
function pairwise_transform.test_jpeg(src)
local options = {color_noise = true,
random_half = true,
overlay = true,
torch.setdefaulttensortype("torch.FloatTensor")
local options = {random_color_noise_rate = 0.5,
random_half_rate = 0.5,
random_overlay_rate = 0.5,
nr_rate = 1.0,
active_cropping_rate = 0.5,
active_cropping_tries = 10,
max_size = 256,
rgb = true
}
local image = require 'image'
local src = image.lena()
for i = 1, 9 do
local xy = pairwise_transform.jpeg(src,
"art",
@ -223,13 +228,18 @@ function pairwise_transform.test_jpeg(src)
end
end
function pairwise_transform.test_scale(src)
local options = {color_noise = true,
random_half = true,
overlay = true,
torch.setdefaulttensortype("torch.FloatTensor")
local options = {random_color_noise_rate = 0.5,
random_half_rate = 0.5,
random_overlay_rate = 0.5,
active_cropping_rate = 0.5,
active_cropping_tries = 10,
max_size = 256,
rgb = true
}
local image = require 'image'
local src = image.lena()
for i = 1, 10 do
local xy = pairwise_transform.scale(src, 2.0, 128, 7, 1, options)
image.display({image = xy[1][1], legend = "y:" .. (i * 10), min = 0, max = 1})