facebookresearch / facebookresearch/sam2
Loading embeddings to save time to re-analyze the image
- 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
Assessment
This issue has not been assessed yet.