From ad8ff96224a1551dd3afc340b2f3c788766619b8 Mon Sep 17 00:00:00 2001 From: Younes Belkada <49240599+younesbelkada@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:23:13 +0100 Subject: [PATCH] [`Docs` / `SAM` ] Reflect correct changes to run inference without OOM (#27268) Update sam.md --- docs/source/en/model_doc/sam.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/en/model_doc/sam.md b/docs/source/en/model_doc/sam.md index fe0d24623f..d2a472957a 100644 --- a/docs/source/en/model_doc/sam.md +++ b/docs/source/en/model_doc/sam.md @@ -57,7 +57,8 @@ raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB") input_points = [[[450, 600]]] # 2D location of a window in the image inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to(device) -outputs = model(**inputs) +with torch.no_grad(): + outputs = model(**inputs) masks = processor.image_processor.post_process_masks( outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu() @@ -108,4 +109,4 @@ Resources: ## TFSamModel [[autodoc]] TFSamModel - - call \ No newline at end of file + - call