Closed hanjoonwon closed 9 months ago
multimask_output: bool = False can return one mask
multimask_output: bool = False can return one mask
thank you :) I was wondering where the multimask option is, it's not in amg.py or is it something you add in the executable script?
source code in SAM: from segment_anything import sam_model_registry, SamPredictor sam_checkpoint = "sam_vit_h_4b8939.pth" model_type = "vit_h" device = "cuda" sam = sam_model_registrymodel_type sam.to(device=device)
predictor = SamPredictor(sam) masks, scores, logits = predictor.predict( point_coords=input_point, point_labels=input_label, multimask_output=True, )
the best single mask can be chosen by picking the one with the highest score returned in scores. Based on my experience, if you want to use 'multimask_output=True' and get the mask you want, you should give more prompts , such as points or boxs
more info:https://github.com/facebookresearch/segment-anything/blob/main/notebooks/predictor_example.ipynb
thanks! Not directly applicable in the ubuntu anaconda environment, but should use notebooks.
it can use in anaconda, download the source code and weights, " import cv2 import numpy from segment_anything import SamPredictor, sam_model_registry
sam = sam_model_registry"vit_b" predictor = SamPredictor(sam)
image_data = cv2.imread( '...') predictor.set_image(image_data) input_point = numpy.array([[500, 375]]) input_label = numpy.array([1]) masks, scores, logits = predictor.predict( point_coords=input_point, point_labels=input_label, multimask_output=True, ) "
it can use in anaconda, download the source code and weights, " import cv2 import numpy from segment_anything import SamPredictor, sam_model_registry
sam = sam_model_registry"vit_h"
sam = sam_model_registry"vit_l"
sam = sam_model_registry"vit_b" predictor = SamPredictor(sam)
image_data = cv2.imread( '...') predictor.set_image(image_data) input_point = numpy.array([[500, 375]]) input_label = numpy.array([1]) masks, scores, logits = predictor.predict( point_coords=input_point, point_labels=input_label, multimask_output=True, ) "
thank you so much!
I ran it with my current images and it seems to be storing too many masks for one image and is inaccurate. I want a foreground mask image so I need one mask for each image, how do I modify the code? my image https://github.com/NVlabs/instant-ngp/tree/master/data/nerf/fox/images