Created by Hang Zhang
HzProc is a fast data augmentation toolbox supporting affine transformation with GPU backend. (PyTorch version is also provide.) The name of "HzProc" means high speed image processing, where "Hz" (hertz) is the unit of frequency and "Proc" is abbreviation of processing. HZ is also the initial of the author.
It contains the functions within the following subcategories:
- Online
- Offline
This package relies on torch7 and cutorch. Please note the package also relies on a NVIDIA GPU compitable with CUDA 6.5 or higher version.
On Linux
luarocks install https://raw.githubusercontent.com/zhanghang1989/hzproc/master/hzproc-scm-1.rockspec
On OSX
CC=clang CXX=clang++ luarocks install https://raw.githubusercontent.com/zhanghang1989/hzproc/master/hzproc-scm-1.rockspec
Demo The demo script relies on qtlua and image package to load and display the images. The test script is also a good usage example. The documentations can be found in the link.
git clone https://github.com/zhanghang1989/hzproc
cd hzproc
qlua test/demo.lua
Fast Examples
- online example:
function RandomCrop(size, pad)
return function(input)
-- avoid unnecessary opterations
local w, h = input:size(3), input:size(2)
if w == size and h == size then
return input
end
local x1, y1 = torch.random(0, w + 2*pad - size),
torch.random(0, h + 2*pad - size)
local out = hzproc.Crop.Pad(input, x1, y1, size, size, pad)
assert(out:size(2) == size and out:size(3) == size, 'wrong crop size')
return out
end
end
- offline example:
function Resize(inw, inh, ow, oh)
-- generating the lookup map only once during init
local map = hzproc.Table.Resize(inw, inh, ow, oh)
return function(input)
-- avoid unnecessary opterations
local w, h = input:size(3), input:size(2)
if (w == ow and h == oh) then
return input
end
-- mapping
return hzproc.Remap.Bilinear(input, map)
end
end