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
b203de7c
Unverified
Commit
b203de7c
authored
May 10, 2023
by
Lysandre Debut
Committed by
GitHub
May 10, 2023
Browse files
Update Image segmentation description (#23261)
* Update Image segmentation description * prompt -> label
parent
4f05bbf1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
src/transformers/tools/image_segmentation.py
src/transformers/tools/image_segmentation.py
+5
-6
No files found.
src/transformers/tools/image_segmentation.py
View file @
b203de7c
...
@@ -28,10 +28,9 @@ if is_vision_available():
...
@@ -28,10 +28,9 @@ if is_vision_available():
class
ImageSegmentationTool
(
PipelineTool
):
class
ImageSegmentationTool
(
PipelineTool
):
description
=
(
description
=
(
"This is a tool that creates a segmentation mask identifiying elements inside an image according to a prompt. "
"This is a tool that creates a segmentation mask of an image according to a label. It cannot create an image."
"It takes two arguments named `image` which should be the original image, and `prompt` which should be a text "
"It takes two arguments named `image` which should be the original image, and `label` which should be a text "
"describing the elements what should be identified in the segmentation mask. The tool returns the mask as a "
"describing the elements what should be identified in the segmentation mask. The tool returns the mask."
"black-and-white image."
)
)
default_checkpoint
=
"CIDAS/clipseg-rd64-refined"
default_checkpoint
=
"CIDAS/clipseg-rd64-refined"
name
=
"image_segmenter"
name
=
"image_segmenter"
...
@@ -44,9 +43,9 @@ class ImageSegmentationTool(PipelineTool):
...
@@ -44,9 +43,9 @@ class ImageSegmentationTool(PipelineTool):
requires_backends
(
self
,
[
"vision"
])
requires_backends
(
self
,
[
"vision"
])
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
def
encode
(
self
,
image
:
"Image"
,
prompt
:
str
):
def
encode
(
self
,
image
:
"Image"
,
label
:
str
):
self
.
pre_processor
.
image_processor
.
size
=
{
"width"
:
image
.
size
[
0
],
"height"
:
image
.
size
[
1
]}
self
.
pre_processor
.
image_processor
.
size
=
{
"width"
:
image
.
size
[
0
],
"height"
:
image
.
size
[
1
]}
return
self
.
pre_processor
(
text
=
[
prompt
],
images
=
[
image
],
padding
=
True
,
return_tensors
=
"pt"
)
return
self
.
pre_processor
(
text
=
[
label
],
images
=
[
image
],
padding
=
True
,
return_tensors
=
"pt"
)
def
forward
(
self
,
inputs
):
def
forward
(
self
,
inputs
):
with
torch
.
no_grad
():
with
torch
.
no_grad
():
...
...
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