more flip
This commit is contained in:
parent
7ac7923345
commit
eaeaef10b7
|
@ -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
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue