"...text-generation-inference.git" did not exist on "08f6fa0b5924d9bf680b915f678a176ca0f7ae19"
Unverified Commit 7d756813 authored by cmdr2's avatar cmdr2 Committed by GitHub
Browse files

Update the legacy inpainting SD pipeline, to allow calling it with only...

Update the legacy inpainting SD pipeline, to allow calling it with only prompt_embeds (instead of always requiring a prompt) (#2842)

Fix error 'required positional argument: prompt' when Legacy Inpaint is called only with prompt_embeds
parent 159a0bff
...@@ -521,7 +521,7 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline): ...@@ -521,7 +521,7 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
@torch.no_grad() @torch.no_grad()
def __call__( def __call__(
self, self,
prompt: Union[str, List[str]], prompt: Union[str, List[str]] = None,
image: Union[torch.FloatTensor, PIL.Image.Image] = None, image: Union[torch.FloatTensor, PIL.Image.Image] = None,
mask_image: Union[torch.FloatTensor, PIL.Image.Image] = None, mask_image: Union[torch.FloatTensor, PIL.Image.Image] = None,
strength: float = 0.8, strength: float = 0.8,
...@@ -611,10 +611,16 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline): ...@@ -611,10 +611,16 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
(nsfw) content, according to the `safety_checker`. (nsfw) content, according to the `safety_checker`.
""" """
# 1. Check inputs # 1. Check inputs
self.check_inputs(prompt, strength, callback_steps) self.check_inputs(prompt, strength, callback_steps, negative_prompt, prompt_embeds, negative_prompt_embeds)
# 2. Define call parameters # 2. Define call parameters
batch_size = 1 if isinstance(prompt, str) else len(prompt) if prompt is not None and isinstance(prompt, str):
batch_size = 1
elif prompt is not None and isinstance(prompt, list):
batch_size = len(prompt)
else:
batch_size = prompt_embeds.shape[0]
device = self._execution_device device = self._execution_device
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2) # here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1` # of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment