2

While performing semantic-segmentation task by following this tutorial ,
I noticed that the final predicted output from the model is not 0 and 1,
it consists of decimal values from 0.0000xxxx to 1.0.

Since the model took in the label of 0 and 1 only,
what is the meaning of the the decimal values range in the output?
(The possibility of the pixels belonging to a certain class?)

test_img = cv2.imread('data/membrane1/test/0.png', cv2.IMREAD_COLOR)    
test_img = cv2.resize(test_img, (SIZE_Y, SIZE_X))
test_img = cv2.cvtColor(test_img, cv2.COLOR_RGB2BGR)
test_img = np.expand_dims(test_img, axis=0)
prediction = model.predict(test_img)
plt.imshow(prediction_image, cmap='gray')

Sample Output Image
enter image description here

Sample Output/Predicted Value
enter image description here

Youtube tutorial - 177 - Semantic segmentation made easy (using segmentation models library)
Github Original Source Code

jona
  • 592
  • 1
  • 4
  • 16

2 Answers2

0

I have found about this from the same youtube tutorial in a different video (19.20 ~ 20.04).

The values in the prediction indeed reflecting the probability of a pixel to it's corresponding class.

In this case, it is referring the probability of the current pixel to be the membrane.

jona
  • 592
  • 1
  • 4
  • 16
0

Not sure what type of model are you using, but most likely, the final layer of the model is a dense layer with a sigmoid function as activation_function. This will give you values between 0 and 1. You need to find a threshold and see which one gives better results . For example, all values given by the prediction that are less than 0.5, turn them to 0. Values given by the prediction >= 0.5, turn them to 1. However, this threshold needs to be tuned to see which gives better results. It is recommended that you find this threshold with data that hasnt been used for training at all.