2

I have training data already aligned to 224x224 in dimension. It would be wrong to resize to 256x256 and then random crop. Is there a way to skip this transformation and use the images as it is?

Shai
  • 111,146
  • 38
  • 238
  • 371
Darren
  • 51
  • 3
  • 2
    what prevents you to use the data as-is? At the end of the proposed transformation you would have data with same size and zoomed content. Right? – virolino Feb 26 '19 at 08:45
  • @virolino I don't want the image to be zoomed, since in this way only a part of it would be used after cropping. I want the net to use the original 224x224 image, not the cropped 224x224 out of zoomed one. So the question is, when input image is 224x224, will data transformation attempt to zoom and crop it, or just use it as it is? – Darren Feb 26 '19 at 13:02
  • if the algorithm works only on 256x256 images, then you have the alternative to do some padding of the image, to avoid zooming. You need to verify if it is enough to pad only on 2 sides (e.g. right and bottom), or you need to spread the padding on all four sides equally. – virolino Feb 26 '19 at 13:07
  • @virolino the size 256 is a set number in data preprocessing of caffe/resnet50, where any images are first scaled to 256 along the short side and then a random 224x224 crop is taken. This is a sort of data augmentation strategy, as discussed [here](https://stackoverflow.com/questions/42605461/caffe-data-augmentation-by-random-cropping?rq=1). Padding would solve the problem to some extent. – Darren Feb 26 '19 at 13:28

1 Answers1

0

Yes, you only need to edit accordingly the transformation params of the input data layer you are using.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • I haven't set crop_size in transformation params and the training works well. But it is still unclear whether the image is zoomed and cropped, or been used directly. – Darren Feb 26 '19 at 13:08
  • @Darren the net does not do anything you did not tell it to do. – Shai Feb 26 '19 at 13:33
  • That's exactly what I want. Thank you for your confirmation. – Darren Feb 26 '19 at 13:44
  • @Darren you can also verify this by looking at the run time log of caffe: when caffe constructs the net, you should see blobs' shapes -- there you can verify that the shape of the input blob is 224x224 despite removing the central crop param – Shai Feb 26 '19 at 13:46
  • I checked the shapes at beginning of the caffe net, when setting crop_size parameter or removing it. It's the same. I think it is the shape required by the net, regardness of how 224 is achieved. Setting the crop_size param would lead to zoom & crop, I guess. – Darren Feb 26 '19 at 14:24