val-iisc / sketch-parse

Code, demos and data for SketchParse (a neural network for sketch segmentation). Paper:

Home Page:https://arxiv.org/abs/1709.01295

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requesting for Augmentaion data tool

codaibk opened this issue · comments

Hi,
Could please update tool for Augmentation data in this project?
Thanks

Hi

You can find the tool related info here
https://github.com/val-iisc/sketch-parse/tree/master/valsketch

Ravi

Hi, Thanks for your reply. But i mean the tool to increase my training data (Augmentation for Data). I saw this sentence from your paper " To augment data available for training the segmentation model, we apply a series of rotations (±10,±20,±30degrees) and mirroring about the vertical axis". Therefore I want to apply it to augment my new data

It is quite simple -- here is some MATLAB code to accomplish the same. You can use the code as a guideline to write similar code in Python if you wish.

% Original -> 1
I = imread(src_img);

% Vertical Mirroring -> 1
I_mirrored = fliplr(I);

% Rotate -> 4
rot_arr = [30 20 10 -10 -20 -30];
pad_width = 70;
I_padded = padarray(I,[pad_width pad_width],255);
for i = 1:length(rot_arr)
I_rot = imrotate(I_padded,rot_arr(i), 'crop');
I_new = I_rot(pad_width+1:end-pad_width,pad_width+1:end-pad_width); % store I_new
end

The above code snipped can be used for data augmentation of sketches for classification. But if you are doing data augmentation of natural images for segmentation, you will have to do these additional changes

  • You will have to do the above mentioned changes to both the original image and its corresponding segmentation mask.
  • For rotation augmentation, you will also have to crop image(instead of padding) after rotation because rotation creates black artifacts.

Finally after this data augmentation, you will have to sketchify all the natural images. The sketchified image and the corresponding segmentation masks thus obtained can be directly used as input to train our model on additional data.

Hi, Thanks for your answer. It is very nice because of your clear explanation. I will try to apply it.
Have a nice day ^^