INNER CODE UNIT · Python

rec_from_image

Anything-of-anything/Anything-3D · AnyObject3D/src/main.py:17

def rec_from_image(imgname, point, keyword, random_seed):
    # input params
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    image = cv2.imread(f'images/{imgname}.jpg')
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    sam_checkpoint = "./checkpoint/sam_vit_h_4b8939.pth"
    sam = sam_model_registry['vit_h'](checkpoint=sam_checkpoint)
    sam.to(device=device)

    predictor = SamPredictor(sam)
    predictor.set_image(image)

    input_point = np.array([point])
    # (1020, 430, 1950, 900)
    # prompt_boxes = np.array([550, 820, 1060, 1450])
    input_label = np.array([1])
    masks, scores, logits = predictor.predict(
        point_coords=input_point,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…