Spaces:
Runtime error
Runtime error
Update app.py
Browse filesAdding Refiner Dteps
app.py
CHANGED
@@ -34,17 +34,16 @@ else:
|
|
34 |
refiner = refiner.to(device)
|
35 |
refiner.unet = torch.compile(refiner.unet, mode="reduce-overhead", fullgraph=True)
|
36 |
|
37 |
-
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaling, prompt_2, negative_prompt_2, high_noise_frac):
|
38 |
-
#n_steps = 40
|
39 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
40 |
int_image = pipe(prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, num_inference_steps=steps, height=height, width=width, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
|
41 |
if upscaling == 'Yes':
|
42 |
-
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image, denoising_start=high_noise_frac).images[0] #num_inference_steps=n_steps,
|
43 |
upscaled = upscaler(prompt=prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=5, guidance_scale=0).images[0]
|
44 |
torch.cuda.empty_cache()
|
45 |
return (image, upscaled)
|
46 |
else:
|
47 |
-
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image, denoising_start=high_noise_frac).images[0]
|
48 |
torch.cuda.empty_cache()
|
49 |
return (image, image)
|
50 |
|
@@ -58,7 +57,8 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
|
|
58 |
gr.Radio(['Yes', 'No'], value='No', label='Upscale?'),
|
59 |
gr.Textbox(label='Embedded Prompt'),
|
60 |
gr.Textbox(label='Embedded Negative Prompt'),
|
61 |
-
gr.Slider(minimum=.7, maximum=.99, value=.95, step=.01, label='Refiner Denoise Start %')
|
|
|
62 |
outputs=['image', 'image'],
|
63 |
title="Stable Diffusion XL 1.0 GPU",
|
64 |
description="SDXL 1.0 GPU. <br><br><b>WARNING: Capable of producing NSFW (Softcore) images.</b>",
|
|
|
34 |
refiner = refiner.to(device)
|
35 |
refiner.unet = torch.compile(refiner.unet, mode="reduce-overhead", fullgraph=True)
|
36 |
|
37 |
+
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaling, prompt_2, negative_prompt_2, high_noise_frac, n_steps):
|
|
|
38 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
39 |
int_image = pipe(prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, num_inference_steps=steps, height=height, width=width, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
|
40 |
if upscaling == 'Yes':
|
41 |
+
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image, num_inference_steps=n_steps, denoising_start=high_noise_frac).images[0] #num_inference_steps=n_steps,
|
42 |
upscaled = upscaler(prompt=prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=5, guidance_scale=0).images[0]
|
43 |
torch.cuda.empty_cache()
|
44 |
return (image, upscaled)
|
45 |
else:
|
46 |
+
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image, num_inference_steps=n_steps ,denoising_start=high_noise_frac).images[0]
|
47 |
torch.cuda.empty_cache()
|
48 |
return (image, image)
|
49 |
|
|
|
57 |
gr.Radio(['Yes', 'No'], value='No', label='Upscale?'),
|
58 |
gr.Textbox(label='Embedded Prompt'),
|
59 |
gr.Textbox(label='Embedded Negative Prompt'),
|
60 |
+
gr.Slider(minimum=.7, maximum=.99, value=.95, step=.01, label='Refiner Denoise Start %'),
|
61 |
+
gr.Slider(minimum=5, maximum=100, value=30, step=1, label='Refiner Number of Iterations')],
|
62 |
outputs=['image', 'image'],
|
63 |
title="Stable Diffusion XL 1.0 GPU",
|
64 |
description="SDXL 1.0 GPU. <br><br><b>WARNING: Capable of producing NSFW (Softcore) images.</b>",
|