[example/image2image] raise error if strength is not in desired range (#238)

raise error if strength is not in desired range
This commit is contained in:
Suraj Patil 2022-08-23 19:52:52 +05:30 committed by GitHub
parent 4674fdf807
commit 511bd3aaf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -64,6 +64,9 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline):
else: else:
raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}") raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}")
if strength < 0 or strength > 1:
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
# set timesteps # set timesteps
accepts_offset = "offset" in set(inspect.signature(self.scheduler.set_timesteps).parameters.keys()) accepts_offset = "offset" in set(inspect.signature(self.scheduler.set_timesteps).parameters.keys())
extra_set_kwargs = {} extra_set_kwargs = {}