Skip to content

Hide / Remove bounding Box at Inference #2992

Answered by VGrondin
hacadtra asked this question in Q&A
Discussion options

You must be logged in to vote

You can use overlay_instances. Here is a code snippet:

# visualize
im = cv2.imread(d["file_name"])
# predictions
outputs_pred = predictor(im)   
v = Visualizer(img,
                metadata=metadata, 
                scale=1, 
                instance_mode =  ColorMode.BW     # remove color from image, better see segmentation mask  
)
dt_image = v.overlay_instances(
                boxes=None, 
                masks=outputs_pred["instances"].pred_masks.to("cpu"),  
)
        
cv2.imshow('predictions', dt_image[:, :, ::-1])
cv2.waitKey(0)

If your image colors are reversed, remove the [:, :, ::-1]

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@hacadtra
Comment options

Comment options

You must be logged in to vote
8 replies
@sushmasuresh28
Comment options

@VGrondin
Comment options

@sushmasuresh28
Comment options

@IAmOZRules
Comment options

@VGrondin
Comment options

Answer selected by hacadtra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants