Skip to content

Commit

Permalink
remove return_tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
SangbumChoi committed Jul 16, 2024
1 parent c6dc445 commit 16ddefd
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,26 @@ def __call__(
Please refer to the docstring of the above two methods for more information.
"""
if images is None and text is None:
raise ValueError("You have to specify either images or text.")
raise ValueError("You must specify either text or images.")

output_kwargs = self._merge_kwargs(
GroundingDinoProcessorKwargs,
tokenizer_init_kwargs=self.tokenizer.init_kwargs,
**kwargs,
)

# BC for explicit return_tensors
if "return_tensors" in output_kwargs["common_kwargs"]:
return_tensors = output_kwargs["common_kwargs"].pop("return_tensors", None)

# Get only text
if images is not None:
encoding_image_processor = self.image_processor(
images, return_tensors=return_tensors, **output_kwargs["images_kwargs"]
images, **output_kwargs["common_kwargs"], **output_kwargs["images_kwargs"]
)
else:
encoding_image_processor = BatchFeature()

if text is not None:
text_encoding = self.tokenizer(
text=text,
return_tensors=return_tensors,
**output_kwargs["common_kwargs"],
**output_kwargs["text_kwargs"],
)
else:
Expand Down

0 comments on commit 16ddefd

Please sign in to comment.