I have a code that uses tensor API. But I added to it a funcation call, that to my understanding, I can't have it in tensor (but not sure about that). In the below code, the call to:
image= io.imread(image_path , plugin='simpleitk')
but the reset is all tensor. Currently, run fail with unknow reason. is there a solution to either change the code (either the io.imread or the reset) to work with each other:
!pip install SimpleITK
# Image preprocessing utils
import skimage.io as io
@tf.function
def parse_images(image_path):
#--------------io.read is not tensor
image= io.imread(image_path , plugin='simpleitk')
#---------------
image = tf.image.convert_image_dtype(image, tf.float32)
image = tf.image.resize(image, size=[224, 224])
return image
to be called by this code:
import sys
# Create TensorFlow dataset
BATCH_SIZE = 64
train_ds = tf.data.Dataset.from_tensor_slices( my_train_images)
train_ds = (
train_ds
.map(parse_images, num_parallel_calls=tf.data.experimental.AUTOTUNE)
.shuffle(1024)
.batch(BATCH_SIZE, drop_remainder=True)
.prefetch(tf.data.experimental.AUTOTUNE)
)
