Skip to content
Advertisement

Image processing in Tensor flow TFX pipelines

I am trying to get a Tensorflow TFX pipeline up and running using the MNIST dataset.

JavaScript
JavaScript

Setup pipeline paths

JavaScript

Write the data to TF.record format and save in eval and train dirs. NOTE that the MNIST data starts as a numpy array 28×28 and is converted to a bytestring to enable it to be encoded as part of the Tf.record.

JavaScript

The next stage is to call the transform component which uses the preprocessing_fn. This function should process all the data so for example divide the image array by 255 is a standard feature process. But the image is still as a bytestring and I can’t for the life of me figure out how to turn it back into an array. The below is what I have tried.

JavaScript

I get the following error:

JavaScript

I know the label feature is working as I can call the below code and get a print as so….

JavaScript
JavaScript

IF I remove the lines:

JavaScript

I get printed

JavaScript

This shows what I am doing to the label feature is working but I really can’t figure how to transform the image bytes. Part of the issue is I’m not completely sure what the format is as it’s just a tensor which is pretty opaque. It seems given the label operation I’m operating on a column of data effectively but again, can’t figure the correct operation or syntax

Advertisement

Answer

For any future viewers this works

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement