kadirnar / segment-anything-video

MetaSeg: Packaged version of the Segment Anything repository
Apache License 2.0
946 stars 67 forks source link

Can you save sections of the image that are masked after using SegAutoMaskPredictor() #83

Open ksd3 opened 1 year ago

ksd3 commented 1 year ago

I can't find this in the documentation. After running results = SegAutoMaskPredictor().image_predict( source="firststeve.png", model_type="vit_h", # vit_l, vit_h, vit_b points_per_side=4, points_per_batch=16, min_area=0, output_path="output.png", show=False, save=True, )

I can save the segmented image, but I can't pull out the individual segmented pieces. Does this package support doing something like this or do I have to use the original repository? I just want to know if something like this exists: image

kadirnar commented 1 year ago

Hi, do you want to save every segmented object?

ksd3 commented 1 year ago

Yes, I want to save every segmented object. I know this can be done (tediously) by inspecting each bbox variable (that is the result of SamAutomaticMaskGenerator from the original repository) and cropping the image based on the xywh format but I wondered if there was a way to do it faster using metaseg.

kadirnar commented 1 year ago

I will add this feature but I am busy right now. It may take some time to add. If you want to add, I can help.

ksd3 commented 1 year ago

I can try and add it. Which subroutine uses the results of SamAutomaticMaskGenerator? Presumably the method would just be a function that calls PIL.crop() based on the masks. That should be fairly easy to do.