INNER CODE UNIT · Python

d

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

    d = -b * bbox[1]
    mapping = np.array([[a, 0, c],
                        [0, b, d]]).astype(np.float32)
    img_patch = cv2.warpAffine(image, mapping, (output_sz, output_sz), borderMode=cv2.BORDER_CONSTANT, borderValue=(0, 0, 0))
    mask_patch = cv2.warpAffine(mask, mapping, (output_sz, output_sz), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
    img_patch = cv2.cvtColor(img_patch, cv2.COLOR_RGB2BGR)
    cv2.imwrite(f'./images/{imgname}_patch.jpg', img_patch)
    cv2.imwrite(f'./images/{imgname}_mask.png', mask_patch)
    img_patch[~(mask_patch > 0)] = [255, 255, 255]
    flag = cv2.imwrite(f'./images/{imgname}_masked.jpg', img_patch)

    # blip caption on image patch 
    raw_image = Image.open(f"./images/{imgname}_masked.jpg").convert("RGB")

    model, vis_processors, _ = load_model_and_preprocess(
        name="blip_caption", model_type="large_coco", is_eval=True, device=device
    )
    image = vis_processors["eval"](raw_image).unsqueeze(0).to(device)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…