MobileSAM
MobileSAM copied to clipboard
It's too slow.
from mobile_sam import sam_model_registry, SamAutomaticMaskGenerator
import cv2
import time
start_time = time.time()
sam_checkpoint = "./mobile_sam.pt"
mobile_sam = sam_model_registry["vit_t"](checkpoint=sam_checkpoint)
mobile_sam.to(device="cuda")
mobile_sam.eval()
mask_generator = SamAutomaticMaskGenerator(mobile_sam)
image_bgr = cv2.imread("C:\\Users\\kanbe\\Pictures\\aa.jpg")
image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB)
masks = mask_generator.generate(image_rgb)
end_time = time.time()
print("{:.2f}s".format(end_time - start_time))
Image file size 54k (1024 x 683).
It took about 7 seconds with the GPU and 70 seconds with the CPU, is this a normal speed?
On my CPU, it will take over a minute to segment an image
Have you considered using ONNX model?
您是否考虑过使用 ONNX 模型?
能够分享一下相关的代码吗?
It takes 10minutes on my cpu for single image
It takes 10minutes on my cpu for single image
large image?
On my GPU, it take 1.6s to segment an image, img_path = "./notebooks/images/picture1.jpg"