I am trying to get mask from the SAM model named facebook/sam-vit-large. Despite trying many methods getting the error ValueError: Invalid image type. Expected either PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray, but got <class ‘NoneType’>. my code for getting mask was: def mask_to_rgb(mask):
bg_transparent = np.zeros(mask.shape + (4, ), dtype=np.uint8)
bg_transparent[mask == 1] = [0, 255, 0, 127]
inputs = processor(
image=image,
input_points=input_points,
return_tensors="pt"
)
assert "pixel_values" in inputs, "Processor did not return expected keys."
inputs = {k: v.to("cuda") for k, v in inputs. Items()}
outputs = model(**inputs)
masks = processor.image_processor.post_process_masks(
outputs.pred_masks.cpu(),
inputs[“original_sizes”].cpu(),
inputs[“reshaped_input_sizes”].cpu()
)
best_mask = masks[0][0][outputs.iou_scores.argmax()]
return ~best_mask.cpu().numpy() getting error while trying to execute the code
raw_image = Image.open(“car.png”).resize((512, 512))
These are the coordinates of two points on the car