-
Notifications
You must be signed in to change notification settings - Fork 33
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 would you segment everything in an image and output masks #5
Comments
Since EdgeSAM follows the same encoder-decoder architecture as SAM, the everything mode will infer the decoder 32x32=1024 times, which is very inefficient. So I don't recommend doing that. But if you really want to try it out, here is the script:
|
Let's say the encoder of the original SAM on a 2080 Ti takes 235 ms and that of the EdgeSAM takes 5 ms and the decoder of both models takes 1 ms. The total execution times in everything mode are So, if VRAM is not your bottleneck, I would recommend using the original SAM instead. |
Hello, sssegmentation also supported EdgeSAM now, you can write the following codes to achieve this goal after installing sssegmentation, import cv2
import torch
import numpy as np
import matplotlib.pyplot as plt
from ssseg.modules.models.segmentors.sam.visualization import showanns
from ssseg.modules.models.segmentors.edgesam import EdgeSAMAutomaticMaskGenerator
# read image
image = cv2.imread('images/dog.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# mask generator
mask_generator = EdgeSAMAutomaticMaskGenerator(use_default_edgesam=True, device='cuda')
# generate masks on an image
masks = mask_generator.generate(image)
# show all the masks overlayed on the image
plt.figure(figsize=(20, 20))
plt.imshow(image)
showanns(masks)
plt.axis('off')
plt.savefig('mask.png') |
I don't want to manually set points or boxes, I want to directly segment all the objects in the graph
The text was updated successfully, but these errors were encountered: