diff --git a/src/huggingface_hub/inference/_client.py b/src/huggingface_hub/inference/_client.py index 6b1b148383..781d9f2d96 100644 --- a/src/huggingface_hub/inference/_client.py +++ b/src/huggingface_hub/inference/_client.py @@ -1287,7 +1287,7 @@ def image_to_image( The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed Inference Endpoint. This parameter overrides the model defined at the instance level. Defaults to None. target_size (`ImageToImageTargetSize`, *optional*): - The size in pixel of the output image. + The size in pixel of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported. Returns: `Image`: The translated image. diff --git a/src/huggingface_hub/inference/_generated/_async_client.py b/src/huggingface_hub/inference/_generated/_async_client.py index 5a686603bc..0cb41512f9 100644 --- a/src/huggingface_hub/inference/_generated/_async_client.py +++ b/src/huggingface_hub/inference/_generated/_async_client.py @@ -1332,7 +1332,7 @@ async def image_to_image( The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed Inference Endpoint. This parameter overrides the model defined at the instance level. Defaults to None. target_size (`ImageToImageTargetSize`, *optional*): - The size in pixel of the output image. + The size in pixel of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported. Returns: `Image`: The translated image. diff --git a/src/huggingface_hub/inference/_generated/types/image_to_image.py b/src/huggingface_hub/inference/_generated/types/image_to_image.py index e99e719f8b..a4eff6d191 100644 --- a/src/huggingface_hub/inference/_generated/types/image_to_image.py +++ b/src/huggingface_hub/inference/_generated/types/image_to_image.py @@ -33,7 +33,7 @@ class ImageToImageParameters(BaseInferenceType): prompt: Optional[str] = None """The text prompt to guide the image generation.""" target_size: Optional[ImageToImageTargetSize] = None - """The size in pixel of the output image.""" + """The size in pixel of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported.""" @dataclass_with_extra diff --git a/src/huggingface_hub/inference/_providers/fal_ai.py b/src/huggingface_hub/inference/_providers/fal_ai.py index b39b33f616..bc2c41d04f 100644 --- a/src/huggingface_hub/inference/_providers/fal_ai.py +++ b/src/huggingface_hub/inference/_providers/fal_ai.py @@ -191,6 +191,8 @@ def _prepare_payload_as_dict( self, inputs: Any, parameters: Dict, provider_mapping_info: InferenceProviderMapping ) -> Optional[Dict]: image_url = _as_url(inputs, default_mime_type="image/jpeg") + if "target_size" in parameters: + parameters["image_size"] = parameters.pop("target_size") payload: Dict[str, Any] = { "image_url": image_url, **filter_none(parameters),