From 4edfb35ef7a33cac82f3cf64d1ca27d413b13590 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 19 Sep 2024 17:57:19 +0100 Subject: [PATCH] last patch to depth-estimation --- src/transformers/pipelines/depth_estimation.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/transformers/pipelines/depth_estimation.py b/src/transformers/pipelines/depth_estimation.py index 39a2ef1b48bf06..0cff085f93294a 100644 --- a/src/transformers/pipelines/depth_estimation.py +++ b/src/transformers/pipelines/depth_estimation.py @@ -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 @@ -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", @@ -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):