SAM2 (Segment Anything Model 2) is Meta’s advanced image segmentation model. With InferX, you can run SAM2 on any device using the same API - from Jetson edge devices to powerful GPU servers.
from inferx.models.sam2 import sam2import cv2# Initialize the modelmodel = sam2()# Load an imageimage = cv2.imread("path/to/your/image.jpg")# Segment with point promptsresults = model.inference( image=image, point_prompts=[(100, 150)], # x, y coordinates point_labels=[1] # 1 for foreground, 0 for background)# Get the segmentation maskmask = results['masks'][0]