Skip to content
Advertisement

U-Net Semantic segmentation model fails when tested on new image

I have a U-Net model with pretrained weights from an Auto-encoder, The Auto-encoder was built an image dataset of 1400 images. I am trying to perform semantic segmentation with 1400 labelled images of a clinical dataset. The model performs well with an iou_score=0.97 on my test image dataset, but when I try to test it on a random image outside my dataset, I get a very bad segmentation result. I don’t understand the reason for it. Please review my code and suggest me where I was wrong.

Training on my dataset & labels :

JavaScript

Testing my model :

JavaScript

Prediction on test image

When I test the same model on a random clinical ulcer image, I get a very bad segmentation result. Code for testing the model on a random image

JavaScript

Testing on a new images Kindly suggest me if there is an error in my testing procedure.

Advertisement

Answer

Before training and validating you are normalizing data at this line –

JavaScript

So you must do the same while testing –

JavaScript
Advertisement