Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1475,6 +1475,7 @@ class LEditsPPPipelineStableDiffusionXL(
|
|
| 1475 |
|
| 1476 |
@torch.no_grad()
|
| 1477 |
# Modified from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.LEditsPPPipelineStableDiffusion.encode_image
|
|
|
|
| 1478 |
def encode_image(self, image, dtype=None, height=None, width=None, resize_mode="default", crops_coords=None):
|
| 1479 |
image = self.image_processor.preprocess(
|
| 1480 |
image=image, height=height, width=width, resize_mode=resize_mode, crops_coords=crops_coords
|
|
@@ -1722,6 +1723,7 @@ class LEditsPPPipelineStableDiffusionXL(
|
|
| 1722 |
|
| 1723 |
|
| 1724 |
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.rescale_noise_cfg
|
|
|
|
| 1725 |
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
|
| 1726 |
"""
|
| 1727 |
Rescale `noise_cfg` according to `guidance_rescale`. Based on findings of [Common Diffusion Noise Schedules and
|
|
@@ -1776,6 +1778,7 @@ def compute_noise_ddim(scheduler, prev_latents, latents, timestep, noise_pred, e
|
|
| 1776 |
|
| 1777 |
|
| 1778 |
# Copied from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.compute_noise_sde_dpm_pp_2nd
|
|
|
|
| 1779 |
def compute_noise_sde_dpm_pp_2nd(scheduler, prev_latents, latents, timestep, noise_pred, eta):
|
| 1780 |
def first_order_update(model_output, sample): # timestep, prev_timestep, sample):
|
| 1781 |
sigma_t, sigma_s = scheduler.sigmas[scheduler.step_index + 1], scheduler.sigmas[scheduler.step_index]
|
|
@@ -1861,6 +1864,7 @@ def compute_noise_sde_dpm_pp_2nd(scheduler, prev_latents, latents, timestep, noi
|
|
| 1861 |
|
| 1862 |
|
| 1863 |
# Copied from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.compute_noise
|
|
|
|
| 1864 |
def compute_noise(scheduler, *args):
|
| 1865 |
if isinstance(scheduler, DDIMScheduler):
|
| 1866 |
return compute_noise_ddim(scheduler, *args)
|
|
|
|
| 1475 |
|
| 1476 |
@torch.no_grad()
|
| 1477 |
# Modified from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.LEditsPPPipelineStableDiffusion.encode_image
|
| 1478 |
+
@spaces.GPU
|
| 1479 |
def encode_image(self, image, dtype=None, height=None, width=None, resize_mode="default", crops_coords=None):
|
| 1480 |
image = self.image_processor.preprocess(
|
| 1481 |
image=image, height=height, width=width, resize_mode=resize_mode, crops_coords=crops_coords
|
|
|
|
| 1723 |
|
| 1724 |
|
| 1725 |
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.rescale_noise_cfg
|
| 1726 |
+
@spaces.GPU
|
| 1727 |
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
|
| 1728 |
"""
|
| 1729 |
Rescale `noise_cfg` according to `guidance_rescale`. Based on findings of [Common Diffusion Noise Schedules and
|
|
|
|
| 1778 |
|
| 1779 |
|
| 1780 |
# Copied from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.compute_noise_sde_dpm_pp_2nd
|
| 1781 |
+
@spaces.GPU
|
| 1782 |
def compute_noise_sde_dpm_pp_2nd(scheduler, prev_latents, latents, timestep, noise_pred, eta):
|
| 1783 |
def first_order_update(model_output, sample): # timestep, prev_timestep, sample):
|
| 1784 |
sigma_t, sigma_s = scheduler.sigmas[scheduler.step_index + 1], scheduler.sigmas[scheduler.step_index]
|
|
|
|
| 1864 |
|
| 1865 |
|
| 1866 |
# Copied from diffusers.pipelines.ledits_pp.pipeline_leditspp_stable_diffusion.compute_noise
|
| 1867 |
+
@spaces.GPU
|
| 1868 |
def compute_noise(scheduler, *args):
|
| 1869 |
if isinstance(scheduler, DDIMScheduler):
|
| 1870 |
return compute_noise_ddim(scheduler, *args)
|