0
$\begingroup$

I am working on a segmentation problem. My masks are tensors with a shape of (4767, 192, 192, 1) --> (num_img, height, width, number of channels). Each mask contains 13 different pixel values (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 255).

What preprocessing do I need to apply to this mask in order to train a UNET model to segment my images into these 13 classes?

I am using Keras. Thank you very much.

$\endgroup$

1 Answer 1

1
$\begingroup$

You can perform the following pre-processing steps to mask images.

  1. Convert your mask to one hot encoding as it converts class to binary as [0,0,0]for 0,[0,1,0] for 1, and [0,0,1] for 2, and so on...

one_hot_masks = tf.keras.utils.to_categorical(masks, num_classes)

  1. Resize the mask to match the models's input
  2. Normalize the mask

normalized_masks = resized_masks / 255.0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.