From 4ed5228fa0865fe947d53449e87cb9d0b965e22b Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Mon, 1 May 2023 07:15:54 +0530 Subject: [PATCH 1/3] Update pipeline_if_superresolution.py Allow arbitrary aspect ratio in IFSuperResolutionPipeline by using the input image shape --- .../pipelines/deepfloyd_if/pipeline_if_superresolution.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py index a62a51b0972f..5ce131e57dc8 100644 --- a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +++ b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py @@ -806,8 +806,9 @@ def __call__( # 2. Define call parameters - height = self.unet.config.sample_size - width = self.unet.config.sample_size + height, width = image.shape[2:] + width *= 4 + height *= 4 device = self._execution_device From 37d6c0455b6c8b69c58f6216b2937632d97df3f3 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sun, 14 May 2023 03:15:52 +0530 Subject: [PATCH 2/3] IFSuperResolutionPipeline: allow the user to override the height and width through the arguments --- .../deepfloyd_if/pipeline_if_superresolution.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py index 71647872feb7..0aafbb52dae8 100644 --- a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +++ b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py @@ -695,6 +695,8 @@ def preprocess_image(self, image, num_images_per_prompt, device): def __call__( self, prompt: Union[str, List[str]] = None, + height: int = None, + width: int = None, image: Union[PIL.Image.Image, np.ndarray, torch.FloatTensor] = None, num_inference_steps: int = 50, timesteps: List[int] = None, @@ -720,6 +722,10 @@ def __call__( prompt (`str` or `List[str]`, *optional*): The prompt or prompts to guide the image generation. If not defined, one has to pass `prompt_embeds`. instead. + height (`int`, *optional*, defaults to the unet's config): + The height in pixels of the generated image. + width (`int`, *optional*, defaults to the unet's config): + The width in pixels of the generated image. image (`PIL.Image.Image`, `np.ndarray`, `torch.FloatTensor`): The image to be upscaled. num_inference_steps (`int`, *optional*, defaults to 50): @@ -805,10 +811,9 @@ def __call__( ) # 2. Define call parameters - - height, width = image.shape[2:] - width *= 4 - height *= 4 + + height = height or self.unet.config.sample_size + width = width or self.unet.config.sample_size device = self._execution_device From 1e6d5de6d60161dd685a8c54a3318934fb63cafe Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sun, 14 May 2023 03:23:10 +0530 Subject: [PATCH 3/3] update IFSuperResolutionPipeline width/height doc string to match StableDiffusionInpaintPipeline conventions --- .../pipelines/deepfloyd_if/pipeline_if_superresolution.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py index 0aafbb52dae8..2fe8e6a9d5d5 100644 --- a/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +++ b/src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py @@ -722,9 +722,9 @@ def __call__( prompt (`str` or `List[str]`, *optional*): The prompt or prompts to guide the image generation. If not defined, one has to pass `prompt_embeds`. instead. - height (`int`, *optional*, defaults to the unet's config): + height (`int`, *optional*, defaults to self.unet.config.sample_size): The height in pixels of the generated image. - width (`int`, *optional*, defaults to the unet's config): + width (`int`, *optional*, defaults to self.unet.config.sample_size): The width in pixels of the generated image. image (`PIL.Image.Image`, `np.ndarray`, `torch.FloatTensor`): The image to be upscaled. @@ -811,7 +811,7 @@ def __call__( ) # 2. Define call parameters - + height = height or self.unet.config.sample_size width = width or self.unet.config.sample_size