Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
4b822560
Unverified
Commit
4b822560
authored
Jun 23, 2024
by
Nicholi Caron
Committed by
GitHub
Jun 23, 2024
Browse files
Update mask_generation.md (#31543)
Minor bug fixes -- rearrange import & add missing parentheses
parent
74a20740
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
docs/source/en/tasks/mask_generation.md
docs/source/en/tasks/mask_generation.md
+2
-2
No files found.
docs/source/en/tasks/mask_generation.md
View file @
4b822560
...
@@ -124,6 +124,7 @@ the processor.
...
@@ -124,6 +124,7 @@ the processor.
```
python
```
python
from
transformers
import
SamModel
,
SamProcessor
from
transformers
import
SamModel
,
SamProcessor
import
torch
device
=
torch
.
device
(
'cuda'
if
torch
.
cuda
.
is_available
()
else
'cpu'
)
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
...
@@ -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.
We can visualize the three masks in the
`masks`
output.
```
python
```
python
import
torch
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
...
@@ -211,7 +211,7 @@ import matplotlib.patches as patches
...
@@ -211,7 +211,7 @@ import matplotlib.patches as patches
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
ax
.
imshow
(
image
)
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
.
add_patch
(
rectangle
)
ax
.
axis
(
"off"
)
ax
.
axis
(
"off"
)
plt
.
show
()
plt
.
show
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment