Skip to content

Commit

Permalink
last patch to depth-estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketknight1 committed Sep 19, 2024
1 parent ceb990d commit 4edfb35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/transformers/pipelines/depth_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def __call__(self, inputs: Union[str, List[str], "Image.Image", List["Image.Imag
The pipeline accepts either a single image or a batch of images, which must then be passed as a string.
Images in a batch must all be in the same format: all as http links, all as local paths, or all as PIL
images.
parameters (`Dict`, *optional*):
A dictionary of argument names to parameter values, to control pipeline behaviour.
The only parameter available right now is `timeout`, which is the length of time, in seconds,
that the pipeline should wait before giving up on trying to download an image.
Return:
A dictionary or a list of dictionaries containing result. If the input is a single image, will return a
Expand All @@ -78,7 +82,6 @@ def __call__(self, inputs: Union[str, List[str], "Image.Image", List["Image.Imag
- **depth** (`PIL.Image`) -- The predicted depth by the model as a `PIL.Image`.
"""
# After deprecation of this is completed, remove the default `None` value for `images`
# TODO The JS spec accepts 'parameters' but this pipeline doesn't pass them anywhere - what should we do?
if "images" in kwargs:
warnings.warn(
"The `images` argument has been renamed to `inputs`. In version 5 of Transformers, `images` will no longer be accepted",
Expand All @@ -89,13 +92,15 @@ def __call__(self, inputs: Union[str, List[str], "Image.Image", List["Image.Imag
raise ValueError("Cannot call the depth-estimation pipeline without an inputs argument!")
return super().__call__(inputs, **kwargs)

def _sanitize_parameters(self, timeout=None, **kwargs):
def _sanitize_parameters(self, timeout=None, parameters=None, **kwargs):
preprocess_params = {}
if timeout is not None:
warnings.warn(
"The `timeout` argument is deprecated and will be removed in version 5 of Transformers", FutureWarning
)
preprocess_params["timeout"] = timeout
if isinstance(parameters, dict) and "timeout" in parameters:
preprocess_params["timeout"] = parameters["timeout"]
return preprocess_params, {}, {}

def preprocess(self, image, timeout=None):
Expand Down

0 comments on commit 4edfb35

Please sign in to comment.