Update app.py
Browse files
app.py
CHANGED
@@ -10,19 +10,18 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
10 |
pipe = DiffusionPipeline.from_pretrained("circulus/canvers-realistic-v3.6", torch_dtype=torch.float16, safety_checker=None)
|
11 |
pipe = pipe.to(device)
|
12 |
pipe.enable_xformers_memory_efficient_attention()
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
|
19 |
-
|
20 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
21 |
-
|
22 |
if upscale == "Yes":
|
|
|
|
|
23 |
image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
24 |
-
|
25 |
-
return (image,
|
26 |
else:
|
27 |
image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
28 |
return (image, image)
|
@@ -34,7 +33,7 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
|
|
34 |
gr.Slider(1, maximum=15, value=7, step=.25, label='Guidance Scale'),
|
35 |
gr.Slider(25, maximum=100, value=50, step=25, label='Number of Iterations'),
|
36 |
gr.Slider(minimum=0, step=1, maximum=9999999999999999, randomize=True, label='Seed: 0 is Random'),
|
37 |
-
gr.Radio(["Yes", "No"], label='
|
38 |
],
|
39 |
outputs=[gr.Image(label='Generated Image'), gr.Image(label='Generated Image')],
|
40 |
title="PhotoReal V3.6 with SD x2 Upscaler - GPU",
|
|
|
10 |
pipe = DiffusionPipeline.from_pretrained("circulus/canvers-realistic-v3.6", torch_dtype=torch.float16, safety_checker=None)
|
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")
|
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):
|
|
|
18 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
|
|
19 |
if upscale == "Yes":
|
20 |
+
n_steps = 40
|
21 |
+
high_noise_frac = 0.8
|
22 |
image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
23 |
+
image = refiner(prompt=prompt, negative_prompt=negative_prompt, image=int_image, num_inference_steps=n_steps, denoising_start=high_noise_frac).images[0]
|
24 |
+
return (image, refined)
|
25 |
else:
|
26 |
image = pipe(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
|
27 |
return (image, image)
|
|
|
33 |
gr.Slider(1, maximum=15, value=7, step=.25, label='Guidance Scale'),
|
34 |
gr.Slider(25, maximum=100, value=50, step=25, label='Number of Iterations'),
|
35 |
gr.Slider(minimum=0, step=1, maximum=9999999999999999, randomize=True, label='Seed: 0 is Random'),
|
36 |
+
gr.Radio(["Yes", "No"], label='SDXL 1.0 Refiner', value='No'),
|
37 |
],
|
38 |
outputs=[gr.Image(label='Generated Image'), gr.Image(label='Generated Image')],
|
39 |
title="PhotoReal V3.6 with SD x2 Upscaler - GPU",
|