Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -20,8 +20,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
20 |
|
21 |
if Model == "PhotoReal":
|
22 |
pipe = DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1")
|
23 |
-
pipe = pipe.to(device)
|
24 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
25 |
torch.cuda.empty_cache()
|
26 |
if upscale == "Yes":
|
27 |
int_image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
@@ -35,8 +35,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
35 |
|
36 |
if Model == "Anime":
|
37 |
anime = DiffusionPipeline.from_pretrained("circulus/canvers-anime-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-anime-v3.8.1")
|
38 |
-
anime = anime.to(device)
|
39 |
anime.enable_xformers_memory_efficient_attention()
|
|
|
40 |
torch.cuda.empty_cache()
|
41 |
if upscale == "Yes":
|
42 |
int_image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
@@ -50,8 +50,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
50 |
|
51 |
if Model == "Disney":
|
52 |
disney = DiffusionPipeline.from_pretrained("circulus/canvers-disney-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-disney-v3.8.1")
|
53 |
-
disney = disney.to(device)
|
54 |
disney.enable_xformers_memory_efficient_attention()
|
|
|
55 |
torch.cuda.empty_cache()
|
56 |
if upscale == "Yes":
|
57 |
int_image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
@@ -65,8 +65,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
65 |
|
66 |
if Model == "StoryBook":
|
67 |
story = DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1")
|
68 |
-
story = story.to(device)
|
69 |
story.enable_xformers_memory_efficient_attention()
|
|
|
70 |
torch.cuda.empty_cache()
|
71 |
if upscale == "Yes":
|
72 |
int_image = story(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
@@ -80,8 +80,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
80 |
|
81 |
if Model == "SemiReal":
|
82 |
semi = DiffusionPipeline.from_pretrained("circulus/canvers-semi-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-semi-v3.8.1")
|
83 |
-
semi = semi.to(device)
|
84 |
semi.enable_xformers_memory_efficient_attention()
|
|
|
85 |
torch.cuda.empty_cache()
|
86 |
if upscale == "Yes":
|
87 |
image = semi(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
@@ -95,8 +95,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
95 |
|
96 |
if Model == "Animagine XL 3.0":
|
97 |
animagine = DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.0", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.0")
|
98 |
-
animagine = animagine.to(device)
|
99 |
animagine.enable_xformers_memory_efficient_attention()
|
|
|
100 |
torch.cuda.empty_cache()
|
101 |
if upscale == "Yes":
|
102 |
int_image = animagine(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
@@ -111,11 +111,12 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
|
|
111 |
if Model == "SDXL 1.0":
|
112 |
torch.cuda.max_memory_allocated(device=device)
|
113 |
sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
114 |
-
sdxl = sdxl.to(device)
|
115 |
sdxl.enable_xformers_memory_efficient_attention()
|
|
|
116 |
torch.cuda.empty_cache()
|
117 |
|
118 |
if upscale == "Yes":
|
|
|
119 |
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
120 |
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")
|
121 |
sdxl.enable_xformers_memory_efficient_attention()
|
|
|
20 |
|
21 |
if Model == "PhotoReal":
|
22 |
pipe = DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-real-v3.8.1")
|
|
|
23 |
pipe.enable_xformers_memory_efficient_attention()
|
24 |
+
pipe = pipe.to(device)
|
25 |
torch.cuda.empty_cache()
|
26 |
if upscale == "Yes":
|
27 |
int_image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
|
|
35 |
|
36 |
if Model == "Anime":
|
37 |
anime = DiffusionPipeline.from_pretrained("circulus/canvers-anime-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-anime-v3.8.1")
|
|
|
38 |
anime.enable_xformers_memory_efficient_attention()
|
39 |
+
anime = anime.to(device)
|
40 |
torch.cuda.empty_cache()
|
41 |
if upscale == "Yes":
|
42 |
int_image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
|
|
50 |
|
51 |
if Model == "Disney":
|
52 |
disney = DiffusionPipeline.from_pretrained("circulus/canvers-disney-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-disney-v3.8.1")
|
|
|
53 |
disney.enable_xformers_memory_efficient_attention()
|
54 |
+
disney = disney.to(device)
|
55 |
torch.cuda.empty_cache()
|
56 |
if upscale == "Yes":
|
57 |
int_image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
|
|
65 |
|
66 |
if Model == "StoryBook":
|
67 |
story = DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1")
|
|
|
68 |
story.enable_xformers_memory_efficient_attention()
|
69 |
+
story = story.to(device)
|
70 |
torch.cuda.empty_cache()
|
71 |
if upscale == "Yes":
|
72 |
int_image = story(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
|
|
80 |
|
81 |
if Model == "SemiReal":
|
82 |
semi = DiffusionPipeline.from_pretrained("circulus/canvers-semi-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-semi-v3.8.1")
|
|
|
83 |
semi.enable_xformers_memory_efficient_attention()
|
84 |
+
semi = semi.to(device)
|
85 |
torch.cuda.empty_cache()
|
86 |
if upscale == "Yes":
|
87 |
image = semi(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
|
|
95 |
|
96 |
if Model == "Animagine XL 3.0":
|
97 |
animagine = DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.0", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.0")
|
|
|
98 |
animagine.enable_xformers_memory_efficient_attention()
|
99 |
+
animagine = animagine.to(device)
|
100 |
torch.cuda.empty_cache()
|
101 |
if upscale == "Yes":
|
102 |
int_image = animagine(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
|
|
111 |
if Model == "SDXL 1.0":
|
112 |
torch.cuda.max_memory_allocated(device=device)
|
113 |
sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
|
|
114 |
sdxl.enable_xformers_memory_efficient_attention()
|
115 |
+
sdxl = sdxl.to(device)
|
116 |
torch.cuda.empty_cache()
|
117 |
|
118 |
if upscale == "Yes":
|
119 |
+
torch.cuda.max_memory_allocated(device=device)
|
120 |
image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
|
121 |
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")
|
122 |
sdxl.enable_xformers_memory_efficient_attention()
|