From 4b822560a1dfd5d63c985ecf9a3c0aae0a4feeee Mon Sep 17 00:00:00 2001 From: Nicholi Caron Date: Sun, 23 Jun 2024 15:27:21 -0400 Subject: [PATCH] Update mask_generation.md (#31543) Minor bug fixes -- rearrange import & add missing parentheses --- docs/source/en/tasks/mask_generation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/en/tasks/mask_generation.md b/docs/source/en/tasks/mask_generation.md index e16b014f37..82202f58bc 100644 --- a/docs/source/en/tasks/mask_generation.md +++ b/docs/source/en/tasks/mask_generation.md @@ -124,6 +124,7 @@ the processor. ```python from transformers import SamModel, SamProcessor +import torch device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') @@ -147,7 +148,6 @@ masks = processor.image_processor.post_process_masks(outputs.pred_masks.cpu(), i We can visualize the three masks in the `masks` output. ```python -import torch import matplotlib.pyplot as plt import numpy as np @@ -211,7 +211,7 @@ import matplotlib.patches as patches fig, ax = plt.subplots() ax.imshow(image) -rectangle = patches.Rectangle((2350, 1600, 500, 500, linewidth=2, edgecolor='r', facecolor='none') +rectangle = patches.Rectangle((2350, 1600), 500, 500, linewidth=2, edgecolor='r', facecolor='none') ax.add_patch(rectangle) ax.axis("off") plt.show()