Skip to content

Commit 511bd3a

Browse files
authored
[example/image2image] raise error if strength is not in desired range (huggingface#238)
raise error if strength is not in desired range
1 parent 4674fdf commit 511bd3a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/inference/image_to_image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def __call__(
6464
else:
6565
raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}")
6666

67+
if strength < 0 or strength > 1:
68+
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
69+
6770
# set timesteps
6871
accepts_offset = "offset" in set(inspect.signature(self.scheduler.set_timesteps).parameters.keys())
6972
extra_set_kwargs = {}

0 commit comments

Comments
 (0)