Skip to content

Commit 88c5f09

Browse files
[Inference] Fix target size mapping for fal-ai's image-to-image (#3399)
* fix target size mapping for image-to-image fal-ai * docs * docstring
1 parent bd411a6 commit 88c5f09

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/huggingface_hub/inference/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def image_to_image(
12871287
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
12881288
Inference Endpoint. This parameter overrides the model defined at the instance level. Defaults to None.
12891289
target_size (`ImageToImageTargetSize`, *optional*):
1290-
The size in pixel of the output image.
1290+
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.
12911291
12921292
Returns:
12931293
`Image`: The translated image.

src/huggingface_hub/inference/_generated/_async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ async def image_to_image(
13321332
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
13331333
Inference Endpoint. This parameter overrides the model defined at the instance level. Defaults to None.
13341334
target_size (`ImageToImageTargetSize`, *optional*):
1335-
The size in pixel of the output image.
1335+
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.
13361336
13371337
Returns:
13381338
`Image`: The translated image.

src/huggingface_hub/inference/_generated/types/image_to_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ImageToImageParameters(BaseInferenceType):
3333
prompt: Optional[str] = None
3434
"""The text prompt to guide the image generation."""
3535
target_size: Optional[ImageToImageTargetSize] = None
36-
"""The size in pixel of the output image."""
36+
"""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."""
3737

3838

3939
@dataclass_with_extra

src/huggingface_hub/inference/_providers/fal_ai.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ def _prepare_payload_as_dict(
191191
self, inputs: Any, parameters: Dict, provider_mapping_info: InferenceProviderMapping
192192
) -> Optional[Dict]:
193193
image_url = _as_url(inputs, default_mime_type="image/jpeg")
194+
if "target_size" in parameters:
195+
parameters["image_size"] = parameters.pop("target_size")
194196
payload: Dict[str, Any] = {
195197
"image_url": image_url,
196198
**filter_none(parameters),

0 commit comments

Comments
 (0)