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

How to get the visualization results of only instance masks without the original image? #4488

Open
aihcyllop opened this issue Aug 18, 2022 · 9 comments

Comments

@aihcyllop
Copy link

How to get the visualization results of only instance masks without the original image?

When I used demo to save the images of inference, it usually shows the instance segmentation results on original images.

I want to ask how to get only instance segmentation results without original images.

Thanks!

@github-actions github-actions bot added the needs-more-info More info is needed to complete the issue label Aug 18, 2022
@github-actions
Copy link

You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template.
The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";

@frozen-mind
Copy link

like get such kind of image?
1660814920165
here is the original image with mask:
b1f0138f12ae9a1f4f76abe13074646

@aihcyllop
Copy link
Author

aihcyllop commented Aug 18, 2022

@frozen-mind
yes

@github-actions github-actions bot removed the needs-more-info More info is needed to complete the issue label Aug 18, 2022
@frozen-mind
Copy link

actually your answer is in the second tutorial vedio, here is the link
https://www.youtube.com/watch?v=eUSgtfK4ivk
starts from appoximately 17:00, the youtuber will show you how to get the mask of the image
have fun ^ ^

@aihcyllop
Copy link
Author

@frozen-mind
Thank you!!

@frozen-mind
Copy link

btw, did you solve the problem in #4487 ?

@aihcyllop
Copy link
Author

@frozen-mind
sorry, I didn't faced the problem of $4487

@frozen-mind
Copy link

frozen-mind commented Aug 18, 2022 via email

@owardlaw
Copy link

owardlaw commented Sep 18, 2022

You can loop through each canny like this and see each detection. I used something like this to manipulate the pixels of each detection.

# Load your image here and call predictor on it
frame = cv2.imread("test.png")
outputs = predictor(frame)
instances = outputs['instances']

# Referencing pred mask outputs
mask_array = instances.pred_masks.to("cpu").numpy()
mask_array = np.moveaxis(mask_array, 0, -1)
img = np.zeros_like(frame)
h = img.shape[0]
w = img.shape[1]
img_mask = np.zeros([h, w, 3], np.uint8)

# Looping through each detection
for i in range(instances):

    # Creat blank array matching image size and add single canny to array
    mask_array_instance = mask_array[:, :, i:(i+1)]
    applied_canny = np.where(mask_array_instance == True, 255, img)
    array_img = np.asarray(applied_canny)
    
    # Show Canny
    cv2.imshow('area', array_img)
    cv2.waitKey(0)

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

3 participants