Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: add missing @torch.no_grad() to predict, predict_batch, get_imag…#763

Open
Julianblock wants to merge 1 commit into
facebookresearch:mainfrom
Julianblock:fix/missing-no-grad-decorators
Open

fix: add missing @torch.no_grad() to predict, predict_batch, get_imag…#763
Julianblock wants to merge 1 commit into
facebookresearch:mainfrom
Julianblock:fix/missing-no-grad-decorators

Conversation

@Julianblock

Copy link
Copy Markdown

predict, predict_batch, and get_image_embedding in SAM2ImagePredictor
were missing the @torch.no_grad() decorator.

…e_embedding

predict, predict_batch, and get_image_embedding are public inference
methods but were missing the @torch.no_grad() decorator present on all
sibling methods (set_image, set_image_batch, _predict). This caused
unnecessary gradient tracking during the _prep_prompts tensor
operations in predict/predict_batch, and is inconsistent with the
rest of the inference API.
@meta-cla meta-cla Bot added the cla signed label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant