Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -254,9 +254,13 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, re
|
|
254 |
return image
|
255 |
|
256 |
if Model == "SDXL 1.0":
|
|
|
|
|
|
|
|
|
257 |
torch.cuda.empty_cache()
|
258 |
torch.cuda.max_memory_allocated(device=device)
|
259 |
-
sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
260 |
sdxl.enable_xformers_memory_efficient_attention()
|
261 |
sdxl = sdxl.to(device)
|
262 |
torch.cuda.empty_cache()
|
@@ -264,7 +268,7 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, re
|
|
264 |
if refine == "Yes":
|
265 |
torch.cuda.max_memory_allocated(device=device)
|
266 |
torch.cuda.empty_cache()
|
267 |
-
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=
|
268 |
torch.cuda.empty_cache()
|
269 |
sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
270 |
sdxl.enable_xformers_memory_efficient_attention()
|
@@ -296,10 +300,9 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, re
|
|
296 |
return upscaled
|
297 |
else:
|
298 |
|
299 |
-
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=
|
300 |
torch.cuda.empty_cache()
|
301 |
-
|
302 |
-
|
303 |
return image
|
304 |
|
305 |
gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Anime', 'Disney', 'StoryBook', 'SemiReal', 'Animagine XL 3.0', 'SDXL 1.0'], value='PhotoReal', label='Choose Model'),
|
|
|
254 |
return image
|
255 |
|
256 |
if Model == "SDXL 1.0":
|
257 |
+
from diffusers import StableCascadeCombinedPipeline
|
258 |
+
|
259 |
+
sdxl = StableCascadeCombinedPipeline.from_pretrained("stabilityai/stable-cascade", variant="bf16", torch_dtype=torch.bfloat16)
|
260 |
+
|
261 |
torch.cuda.empty_cache()
|
262 |
torch.cuda.max_memory_allocated(device=device)
|
263 |
+
#sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
264 |
sdxl.enable_xformers_memory_efficient_attention()
|
265 |
sdxl = sdxl.to(device)
|
266 |
torch.cuda.empty_cache()
|
|
|
268 |
if refine == "Yes":
|
269 |
torch.cuda.max_memory_allocated(device=device)
|
270 |
torch.cuda.empty_cache()
|
271 |
+
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=10, prior_num_inference_steps=20, prior_guidance_scale=3.0, width=width, height=height, output_type="latent").images
|
272 |
torch.cuda.empty_cache()
|
273 |
sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
274 |
sdxl.enable_xformers_memory_efficient_attention()
|
|
|
300 |
return upscaled
|
301 |
else:
|
302 |
|
303 |
+
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=10, prior_num_inference_steps=20, guidance_scale=3).images[0]
|
304 |
torch.cuda.empty_cache()
|
305 |
+
|
|
|
306 |
return image
|
307 |
|
308 |
gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Anime', 'Disney', 'StoryBook', 'SemiReal', 'Animagine XL 3.0', 'SDXL 1.0'], value='PhotoReal', label='Choose Model'),
|