Spaces:
Runtime error
Runtime error
increase speed (test)
Browse files
app.py
CHANGED
@@ -7,10 +7,8 @@ import numpy as np
|
|
7 |
import torch
|
8 |
from PIL import Image
|
9 |
from diffusers import DiffusionPipeline, StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL
|
10 |
-
from custom_pipeline import CosStableDiffusionXLInstructPix2PixPipeline
|
11 |
from huggingface_hub import hf_hub_download
|
12 |
from huggingface_hub import InferenceClient
|
13 |
-
from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler
|
14 |
|
15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
dtype = torch.float16
|
@@ -51,9 +49,7 @@ def set_timesteps_patched(self, num_inference_steps: int, device = None):
|
|
51 |
# Image Editor
|
52 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
53 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
54 |
-
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file(
|
55 |
-
edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16,
|
56 |
-
)
|
57 |
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
58 |
pipe_edit.to("cuda")
|
59 |
|
@@ -103,8 +99,8 @@ def king(type ,
|
|
103 |
prompt = instruction,
|
104 |
guidance_scale = guidance_scale,
|
105 |
num_inference_steps = steps,
|
106 |
-
width = width,
|
107 |
-
height = height,
|
108 |
generator = generator,
|
109 |
output_type="latent",
|
110 |
).images
|
@@ -113,6 +109,8 @@ def king(type ,
|
|
113 |
prompt=instruction,
|
114 |
guidance_scale=guidance_scale,
|
115 |
num_inference_steps=steps,
|
|
|
|
|
116 |
image=image,
|
117 |
generator=generator,
|
118 |
).images[0]
|
|
|
7 |
import torch
|
8 |
from PIL import Image
|
9 |
from diffusers import DiffusionPipeline, StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL
|
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from huggingface_hub import InferenceClient
|
|
|
12 |
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
dtype = torch.float16
|
|
|
49 |
# Image Editor
|
50 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
51 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
52 |
+
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file( edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16 )
|
|
|
|
|
53 |
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
54 |
pipe_edit.to("cuda")
|
55 |
|
|
|
99 |
prompt = instruction,
|
100 |
guidance_scale = guidance_scale,
|
101 |
num_inference_steps = steps,
|
102 |
+
width = (width/2),
|
103 |
+
height = (height/2),
|
104 |
generator = generator,
|
105 |
output_type="latent",
|
106 |
).images
|
|
|
109 |
prompt=instruction,
|
110 |
guidance_scale=guidance_scale,
|
111 |
num_inference_steps=steps,
|
112 |
+
width = width,
|
113 |
+
height = height,
|
114 |
image=image,
|
115 |
generator=generator,
|
116 |
).images[0]
|