Skip to content

Commit 2d4f7f1

Browse files
authored
Raise ValueError if only one of height or width is provided (#119)
1 parent 9c5e3e5 commit 2d4f7f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/huggingface_inference_toolkit/diffusers_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@ def __call__(
6464
logger.warning("Sending num_images_per_prompt > 1 to pipeline is not supported. Using default value 1.")
6565

6666
if "target_size" in kwargs:
67-
kwargs["height"] = kwargs["target_size"].pop("height", None)
68-
kwargs["width"] = kwargs["target_size"].pop("width", None)
67+
kwargs["height"] = kwargs["target_size"].pop("height")
68+
kwargs["width"] = kwargs["target_size"].pop("width")
6969
kwargs.pop("target_size")
7070

71+
if kwargs.get("height") != kwargs.get("width"):
72+
raise ValueError(
73+
f"Provided `height={kwargs.get('height')}` and `width={kwargs.get('width')}`, but either both must have a value or both must be None (or not provided)."
74+
)
75+
7176
if "output_type" in kwargs and kwargs["output_type"] != "pil":
7277
kwargs.pop("output_type")
7378
logger.warning("The `output_type` cannot be modified, and PIL will be used by default instead.")

0 commit comments

Comments
 (0)