Spaces:
Sleeping
Sleeping
Update app.py
Browse filesTesting two models
app.py
CHANGED
@@ -10,22 +10,34 @@ device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
10 |
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")
|
11 |
pipe = pipe.to(device)
|
12 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
|
|
|
|
13 |
refiner = 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")
|
14 |
refiner.enable_xformers_memory_efficient_attention()
|
15 |
refiner = refiner.to(device)
|
16 |
|
17 |
-
def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale, high_noise_frac):
|
18 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
19 |
-
if
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
else:
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return image
|
27 |
|
28 |
-
gr.Interface(fn=genie, inputs=[gr.
|
|
|
29 |
gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
|
30 |
gr.Slider(512, 1024, 768, step=128, label='Height'),
|
31 |
gr.Slider(512, 1024, 768, step=128, label='Width'),
|
|
|
10 |
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")
|
11 |
pipe = pipe.to(device)
|
12 |
pipe.enable_xformers_memory_efficient_attention()
|
13 |
+
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")
|
14 |
+
anime = anime.to(device)
|
15 |
+
anime.enable_xformers_memory_efficient_attention()
|
16 |
refiner = 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")
|
17 |
refiner.enable_xformers_memory_efficient_attention()
|
18 |
refiner = refiner.to(device)
|
19 |
|
20 |
+
def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, upscale, high_noise_frac):
|
21 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
22 |
+
if Model == "Real":
|
23 |
+
if upscale == "Yes":
|
24 |
+
int_image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
25 |
+
image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=high_noise_frac).images[0]
|
26 |
+
return image
|
27 |
+
else:
|
28 |
+
image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
29 |
else:
|
30 |
+
if upscale == "Yes":
|
31 |
+
int_image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
|
32 |
+
image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=high_noise_frac).images[0]
|
33 |
+
return image
|
34 |
+
else:
|
35 |
+
image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
36 |
+
|
37 |
return image
|
38 |
|
39 |
+
gr.Interface(fn=genie, inputs=[gr.Radio(['Real', 'Anime'], label='Choose Canvers Model'),
|
40 |
+
gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|
41 |
gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
|
42 |
gr.Slider(512, 1024, 768, step=128, label='Height'),
|
43 |
gr.Slider(512, 1024, 768, step=128, label='Width'),
|