Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong number of classes in visualize_segmentation #382

Open
gaetanmuck opened this issue Sep 8, 2022 · 0 comments
Open

Wrong number of classes in visualize_segmentation #382

gaetanmuck opened this issue Sep 8, 2022 · 0 comments

Comments

@gaetanmuck
Copy link

Hello there,
I think I have spotted a small mistake in the code.

TL;DR:

n_classes should be np.max(seg_arr) + 1 and not np.max(seg_arr)

How to see the bug:

Visualize an image without specifying the class number: Observe a color on the image that is not in the legend (black). It is 'normal' because in get_colored_segmentation_image, not found classes number are set to [0, 0, 0].
Once the class number is correctly set (does not use the default code) then it works as expected.

Where is it?

File: https://github.com/divamgupta/image-segmentation-keras/blob/master/keras_segmentation/predict.py
Function: visualize_segmentation
Line: 104
Found: n_classes = np.max(seg_arr)
Should: n_classes = np.max(seg_arr) + 1

Hope it will help
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant