I am trying to execute the Tensorflow \"object_detection_tutorial.py\" in jupyter notebook, with my trained neural network data but it throws a ValueError. The file mentioned ab
Tensorflow expected input which is formated in NHWC format, which means: (BATCH, HEIGHT, WIDTH, CHANNELS).
Step 1 - Add last dimension:
last_axis = -1
grscale_img_3dims = np.expand_dims(image, last_axis)
Step 2 - Repeat the last dimension 3 times:
dim_to_repeat = 2
repeats = 3
np.repeat(grscale_img_3dims, repeats, dim_to_repeat)
So your function should be:
def load_image_into_numpy_array(image):
# The function supports only grayscale images
assert len(image.shape) == 2, "Not a grayscale input image"
last_axis = -1
dim_to_repeat = 2
repeats = 3
grscale_img_3dims = np.expand_dims(image, last_axis)
training_image = np.repeat(grscale_img_3dims, repeats, dim_to_repeat).astype('uint8')
assert len(training_image.shape) == 3
assert training_image.shape[-1] == 3
return training_image