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 probability values from the Detectron model #3

Open
bokelai1989 opened this issue Jul 13, 2021 · 3 comments
Open

How to get probability values from the Detectron model #3

bokelai1989 opened this issue Jul 13, 2021 · 3 comments

Comments

@bokelai1989
Copy link

bokelai1989 commented Jul 13, 2021

Hello Harsh,

First of all, I want to say thank you very much for sharing your work about this background removal! One of my current projects is quite related to it. I have read both your articles and your code repo and they are quite helpful to me! Thanks a lot! :)

I am using Detectron2 to do instance segmentation (human face + hair) on images and achieved 91% precision. My next step is to do background removal on those segmentations. I understand from your article that a trimap is needed, and you mentioned, " However, with a few tweaks, we can get the probability values from the Detectron model also.", I am wondering whether you can share those codes as well? I tried to track down the raw code of detectron2 and found it hard to get it out. Thanks a lot!!

I did look at your detectron_seg.py script, but I see the outputs (using out.pred_mask as below code shows) look like still just binary instead of pixel-level probability for the segmentation.

` def get_seg_output(self,image:np.array):
out = self.model(image)['instances']

    outputs = [(out.pred_masks[i],out.pred_classes[i]) for i in  range(len(out.pred_classes)) if out.pred_classes[i]==0]
    
    return outputs`
@harsh2912
Copy link
Owner

harsh2912 commented Jul 13, 2021 via email

@bokelai1989
Copy link
Author

Hello Harsh, thanks for your fast reply! I will try to track it down further and see then.

@harsh2912
Copy link
Owner

harsh2912 commented Jul 14, 2021 via email

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

2 participants