1

When you have variable sized input images and use the ImageDeserializer to resize the images, how are you supposed to deal with a mean file? Computing the mean file is easy when the input images are all the same size. Wouldn't it be better if the ImageDeserializer would be capable of compute the means?

OlavT
  • 2,496
  • 4
  • 31
  • 56

1 Answers1

0

The order in which image pre-processing steps are executed by default are:

  • Take a crop that has the desired image size
  • Subtract the mean

Hence, your mean file hence only has to contain a mean for the desired input size.

For computing the mean yourself, you will have to repeat these steps, at least to some degree. If you're on .NET, then you may want to have a look at this post where .NET image pre-processing is discussed.

I agree that it would be helpful if there was some tool to compute the mean file. I can understand though why the image deserializer does not do it automatically: You need to transform your training and test data via the same mean file. If you subtract mean from training data automatically, you'll have no way of repeating the same operation on the test data. Plus there is randomization that could make it messy in some cases, etc.

Community
  • 1
  • 1
Anton Schwaighofer
  • 3,119
  • 11
  • 24
  • Ok, that is exactly the problem. You may have 25.000 images of various sizes that is used both as training and test data. In the ImageDeserializer you will specify a resize to let's say 40x40x3 pixels. I would assume for the mean file to be correct, it would have to be created on the bases of the 40x40x3 size and not the originals, correct? It would be no problem to use the in the train /test process, since the same settings would be used for reading the train data and the test data. – OlavT Jan 13 '17 at 12:32
  • Correct, you will have to create the mean file from the 40x40x3 images. Applied to both training and test in the same way, no problem. But if you were to compute mean _internally_ in the deserializer when reading training data, as you had suggested, you're in trouble. – Anton Schwaighofer Jan 13 '17 at 14:00
  • Well, I don't think I would be in any trouble if the ImageDeserializer would compute the means automatically after reading them from the folder as it would apply exactly the same computation for train / test images. – OlavT Jan 13 '17 at 18:58