Hello Marcin,
Retraining process also requires 128x128 images as the input, am I right?
Yes.
So script called retrain.py resizes images to proper value 128x128, am I right?
Yes.
Is this function below responsible for that?
def add_jpeg_decoding(input_width, input_height, input_depth, input_mean,
input_std):
I believe so. The script actually comes from Google as part of the Tensorflow for Poets tutorial and I recommend you go through some of the guides there as well, if you wish to learn more about TensorFlow and Machine Learning in general.
you mean this part of code in label_image.cpp file?
int image_width = 128;
int image_height = 128;
int image_channels = 3;
uint8_t* in = read_bmp(daisy_bmp, daisy_bmp_len, &image_width, &image_height,
&image_channels, s);
Actually, these values are just initialization values and get changed to the actual width, height and number of channels of the supplied bmp in the read_bmp() function.
The code that takes care of the resizing is here:
TfLiteIntArray* dims = interpreter->tensor(input)->dims;
int wanted_height = dims->data[1];
int wanted_width = dims->data[2];
int wanted_channels = dims->data[3];
switch (interpreter->tensor(input)->type) {
case kTfLiteFloat32:
s->input_floating = true;
resize<float>(interpreter->typed_tensor<float>(input), in, image_height,
image_width, image_channels, wanted_height, wanted_width,
wanted_channels, s);
break;
case kTfLiteUInt8:
resize<uint8_t>(interpreter->typed_tensor<uint8_t>(input), in,
image_height, image_width, image_channels, wanted_height,
wanted_width, wanted_channels, s);
break;
default:
LOG(FATAL) << "cannot handle input type "
<< interpreter->tensor(input)->type << " yet";
exit(-1);
}
Where the wanted_height, wanted_width and wanted_channels get loaded from the model's metadata (it is generalized and automated here, so that if you decided to use a different model that requires a different format, you don't have to manually hard code the values). Afterwards, the image inside in and its actual and required dimensions get passed to the resize function, which takes care of preparing the input and storing it inside interpreter->typed_tensor<float>(input) or interpreter->typed_tensor<uint8_t>(input).