facebookresearch / facebookresearch/sam2

Loading embeddings to save time to re-analyze the image

Open
#293 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
19.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

For SAM1 I could do:

`
if exists:
logging.info(f"Embeddings already exist. Loading from: {embeddings_path}")
model.load_image_embedding(embeddings_path)
else:
logging.info(f"Embeddings do not exist. Saving to: {embeddings_path}")
model.set_image(input_data['image'])
model.save_image_embedding(embeddings_path)

input_box = input_data['box_coordinates']

masks, _, _ = model.predict(
point_coords=None,
point_labels=None,
box=input_box[None, :],
multimask_output=False,
)

`


When I tried the same approach with SAM2, the predict call fails with "Must set_image before calling predict" error.
However calling setImage takes a long time, so it looks like loading the embeddings to speed up processing is not working for me with SAM2.

I am curious if there's a simple solution to this problem!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.