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 to print the segmentation mask value#

See original GitHub issue

Great packages! amazed! So, my question is that I’m going through your tutorial got the code but didn’t work for me. I want to print the Instance segmentation mask value ?? my output code is given below Another one is how to serve this through an API ??

import pixellib
from pixellib.instance import custom_segmentation
import cv2

instance_seg = custom_segmentation()
instance_seg.inferConfig(num_classes= 2, class_names= ["BG", "butterfly", "squirrel"])
instance_seg.load_model("/content/mask_rcnn_models/mask_rcnn_model.027-0.335725.h5")
segmask, output = instance_seg.segmentImage("/content/Nature/test/butterfly (10).jpg", show_bboxes= True, output_image_name="e_out.jpg")
cv2.imwrite("img.jpg", output)
print(segmask.get('rois'))
for item in segmask.items():
    print(item)

output mask is Flase not get the value. Let me know please

[[ 42  32 172 232]]
('rois', array([[ 42,  32, 172, 232]], dtype=int32))
('class_ids', array([1], dtype=int32))
('scores', array([0.98511064], dtype=float32))
('masks', array([[[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]],

       [[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]],

       [[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]],

       ...,

       [[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]],

       [[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]],

       [[False],
        [False],
        [False],
        ...,
        [False],
        [False],
        [False]]]))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
wisi-testpilotcommented, Sep 21, 2021

Dear ayoolaolafenwa

Thank you for the very nice program. I want to use the Instance segmentation mask values to count and meassure the objects, but with the recently introduced command mask_points_values=True I get an error message, see below.

Without mask_points_values=True it works, but I only get [False False False].

Alternatively, is it possible to generate an output without the original image overlay, like it is possible in the semantic segmentation? You may implement the command: overlay = False in the Instance Segmentation. Then I will investigate the areas with Opencv.

My program:

import cv2
import pixellib
from pixellib.instance import instance_segmentation

segment_image = instance_segmentation()
segment_image.load_model("mask_rcnn_coco.h5")
seg, output = segment_image.segmentImage("k.jpg", extract_segmented_objects=True, save_extracted_objects =True,
                                         show_bboxes=True, output_image_name= "a.jpg", mask_points_values=True)

print(seg['masks'])

Processed image saved successfully in your current working directory.
Traceback (most recent call last):
  File "C:\Users\User\Desktop\ki\in2.py", line 22, in <module>
    seg, output = segment_image.segmentImage("k.jpg", extract_segmented_objects=True, save_extracted_objects =True,
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pixellib\instance.py", line 284, in segmentImage
    for a in range(extract_mask.shape[2]):
IndexError: tuple index out of range

C:\Users\User\Desktop\ki>


1reaction
whoafridicommented, Dec 29, 2020

Amazing & thank you for great success in the upcoming time . Take care

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image Segmentation Python | Implementation of Mask R-CNN
An introduction to image segmentation. In this article learn about Mask R-CNN framework for image segmentation and implementation of mask ...
Read more >
How to Generate a Mask from Semantic Image Segmentation ...
To get the output mask I use the Tensorflow Tutorial for Image ... the hue of each RGB value and map yellowish things...
Read more >
Converting annotations to object segmentation mask images
An object segmentation mask image uses the multiple channels to encode both class and instance information. In this mask format we multiply the...
Read more >
How to Cut Out Object Segmentations from Detectron2
This video is a response to some questions we received regarding how to use the mask outputs of an instance segmentation neural net....
Read more >
Instance Segmentation MASK R-CNN | with Python and Opencv
source code and files: https://pysource.com/2021/05/18/instance- segmentation - mask -r-cnn-with-python-and-opencv/In this tutorial, ...
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