question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I get the labels of the segment mask?

See original GitHub issue
from keras.preprocessing import image
from segmentation_models import Unet
import numpy as np
import imageio

model = Unet(backbone_name='resnet152',
             encoder_weights='imagenet', freeze_encoder=True)
model.compile('Adam', 'binary_crossentropy', ['binary_accuracy'])

img = image.load_img('seg_images/image1.png')
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)

mask = model.predict(x)
mask = mask.astype('uint8')
imageio.imwrite("result.png", mask[0])

First, the mask is all black. But assuming it works, how can I get the various labels for each segment?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
qubvelcommented, Apr 19, 2019

Hi @shamoons If I understand you correctly: Round mask - mask.round() 0 - is background 1 - is target class

0reactions
shamoonscommented, Apr 19, 2019

How would I load it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to retrieve the labels used in a segmentation mask in ...
As you can see from the code there are 21 possible labels and 2 were used in the mask, one for the motorbike...
Read more >
Semantic Segmentation with Masks Data Labeling Template
Template for performing semantic segmentation with brush masks with Label Studio for your machine learning and data science projects.
Read more >
Exporting cell segmentation as label mask - Image.sc Forum
I am trying to export the cells segmentation as a label mask where each cells will be exported using a different ID, id...
Read more >
Get label mask segmentation from detect.py? #9539 - GitHub
Question I training model yolov5s-seg. I run detect.py and use save-txt but output label bbox is not mask. How to get label mask?...
Read more >
How to create high-quality image segmentation masks quickly ...
Image segmentation is one of the most labor intensive annotation tasks because it requires pixel level accuracy. Labeling a single image can take...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found