Skip to content

Commit

Permalink
Update Image segmentation description (#23261)
Browse files Browse the repository at this point in the history
* Update Image segmentation description

* prompt -> label
  • Loading branch information
LysandreJik authored and sgugger committed May 10, 2023
1 parent 7d415ba commit 9d5b0e5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/transformers/tools/image_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@

class ImageSegmentationTool(PipelineTool):
description = (
"This is a tool that creates a segmentation mask identifiying elements inside an image according to a prompt. "
"It takes two arguments named `image` which should be the original image, and `prompt` which should be a text "
"describing the elements what should be identified in the segmentation mask. The tool returns the mask as a "
"black-and-white image."
"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 `label` which should be a text "
"describing the elements what should be identified in the segmentation mask. The tool returns the mask."
)
default_checkpoint = "CIDAS/clipseg-rd64-refined"
name = "image_segmenter"
Expand All @@ -44,9 +43,9 @@ def __init__(self, *args, **kwargs):
requires_backends(self, ["vision"])
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]}
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):
with torch.no_grad():
Expand Down

0 comments on commit 9d5b0e5

Please sign in to comment.