Spaces:
Build error
Build error
Commit
•
34fa983
1
Parent(s):
d94e0e1
Update app.py
Browse files
app.py
CHANGED
@@ -11,20 +11,6 @@ from PIL import Image
|
|
11 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
12 |
normal_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl.safetensors")
|
13 |
|
14 |
-
def set_timesteps_patched(self, num_inference_steps: int, device = None):
|
15 |
-
self.num_inference_steps = num_inference_steps
|
16 |
-
|
17 |
-
ramp = np.linspace(0, 1, self.num_inference_steps)
|
18 |
-
sigmas = torch.linspace(math.log(self.config.sigma_min), math.log(self.config.sigma_max), len(ramp)).exp().flip(0)
|
19 |
-
|
20 |
-
sigmas = (sigmas).to(dtype=torch.float32, device=device)
|
21 |
-
self.timesteps = self.precondition_noise(sigmas)
|
22 |
-
|
23 |
-
self.sigmas = torch.cat([sigmas, torch.zeros(1, device=sigmas.device)])
|
24 |
-
self._step_index = None
|
25 |
-
self._begin_index = None
|
26 |
-
self.sigmas = self.sigmas.to("cpu") # to avoid too much CPU/GPU communication
|
27 |
-
|
28 |
def resize_image(image, resolution):
|
29 |
original_width, original_height = image.size
|
30 |
|
@@ -38,18 +24,17 @@ def resize_image(image, resolution):
|
|
38 |
resized_img = image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
39 |
return resized_img
|
40 |
|
41 |
-
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
42 |
|
43 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
44 |
|
45 |
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file(
|
46 |
edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16,
|
47 |
)
|
48 |
-
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
49 |
pipe_edit.to("cuda")
|
50 |
|
51 |
pipe_normal = StableDiffusionXLPipeline.from_single_file(normal_file, torch_dtype=torch.float16, vae=vae)
|
52 |
-
pipe_normal.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
53 |
pipe_normal.to("cuda")
|
54 |
|
55 |
@spaces.GPU
|
|
|
11 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
12 |
normal_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl.safetensors")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
def resize_image(image, resolution):
|
15 |
original_width, original_height = image.size
|
16 |
|
|
|
24 |
resized_img = image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
25 |
return resized_img
|
26 |
|
|
|
27 |
|
28 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
29 |
|
30 |
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file(
|
31 |
edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16,
|
32 |
)
|
33 |
+
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction", sigma_schedule="exponential")
|
34 |
pipe_edit.to("cuda")
|
35 |
|
36 |
pipe_normal = StableDiffusionXLPipeline.from_single_file(normal_file, torch_dtype=torch.float16, vae=vae)
|
37 |
+
pipe_normal.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction", sigma_schedule="exponential"s)
|
38 |
pipe_normal.to("cuda")
|
39 |
|
40 |
@spaces.GPU
|