|
@@ -1,4 +1,5 @@
|
|
|
local pairwise_utils = require 'pairwise_transform_utils'
|
|
|
+local data_augmentation = require 'data_augmentation'
|
|
|
local iproc = require 'iproc'
|
|
|
local gm = {}
|
|
|
gm.Image = require 'graphicsmagick.Image'
|
|
@@ -21,12 +22,15 @@ function pairwise_transform.user(x, y, size, offset, n, options)
|
|
|
if options.active_cropping_rate > 0 then
|
|
|
lowres_y = pairwise_utils.low_resolution(y)
|
|
|
end
|
|
|
- if options.pairwise_flip then
|
|
|
+ if options.pairwise_flip and n == 1 then
|
|
|
+ xs[1], ys[1] = data_augmentation.pairwise_flip(xs[1], ys[1])
|
|
|
+ elseif options.pairwise_flip then
|
|
|
xs, ys, ls = pairwise_utils.flip_augmentation(x, y, lowres_y)
|
|
|
end
|
|
|
assert(#xs == #ys)
|
|
|
+ local perm = torch.randperm(#xs)
|
|
|
for i = 1, n do
|
|
|
- local t = (i % #xs) + 1
|
|
|
+ local t = perm[(i % #xs) + 1]
|
|
|
local xc, yc = pairwise_utils.active_cropping(xs[t], ys[t], ls[t], size, scale_y,
|
|
|
options.active_cropping_rate,
|
|
|
options.active_cropping_tries)
|