Manjushri commited on
Commit
d152942
·
verified ·
1 Parent(s): 295288e

Update app.py

Browse files

Added option to not use refiner

Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -34,16 +34,21 @@ 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, 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=15, 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,9 +62,11 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
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=1, maximum=100, value=100, 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>",
65
- article = "If You Enjoyed this Demo and would like to Donate, you can send to any of these Wallets. <br>BTC: bc1qzdm9j73mj8ucwwtsjx4x4ylyfvr6kp7svzjn84 <br>3LWRoKYx6bCLnUrKEdnPo3FCSPQUSFDjFP <br>DOGE: DK6LRc4gfefdCTRk9xPD239N31jh9GjKez <br>SHIB (BEP20): 0xbE8f2f3B71DFEB84E5F7E3aae1909d60658aB891 <br>PayPal: https://www.paypal.me/ManjushriBodhisattva <br>ETH: 0xbE8f2f3B71DFEB84E5F7E3aae1909d60658aB891 <br>Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
 
 
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, refining, high_noise_frac, n_steps):
38
  generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
39
+ if refining == 'Yes':
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, num_inference_steps=n_steps, 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=15, 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, num_inference_steps=n_steps ,denoising_start=high_noise_frac).images[0]
48
+ torch.cuda.empty_cache()
49
+ return (image, image)
50
  else:
51
+ 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).images[0]
52
  torch.cuda.empty_cache()
53
  return (image, image)
54
 
 
62
  gr.Radio(['Yes', 'No'], value='No', label='Upscale?'),
63
  gr.Textbox(label='Embedded Prompt'),
64
  gr.Textbox(label='Embedded Negative Prompt'),
65
+ gr.Radio(["Yes", "No"], label='SDXL 1.0 Refiner: Use if the Image has too much Noise', value='No'),
66
  gr.Slider(minimum=.7, maximum=.99, value=.95, step=.01, label='Refiner Denoise Start %'),
67
  gr.Slider(minimum=1, maximum=100, value=100, step=1, label='Refiner Number of Iterations %')],
68
  outputs=['image', 'image'],
69
  title="Stable Diffusion XL 1.0 GPU",
70
  description="SDXL 1.0 GPU. <br><br><b>WARNING: Capable of producing NSFW (Softcore) images.</b>",
71
+ article = "If You Enjoyed this Demo and would like to Donate, you can send to any of these Wallets. <br>BTC: bc1qzdm9j73mj8ucwwtsjx4x4ylyfvr6kp7svzjn84 <br>BTC2: 3LWRoKYx6bCLnUrKEdnPo3FCSPQUSFDjFP <br>DOGE: DK6LRc4gfefdCTRk9xPD239N31jh9GjKez <br>SHIB (BEP20): 0xbE8f2f3B71DFEB84E5F7E3aae1909d60658aB891 <br>PayPal: https://www.paypal.me/ManjushriBodhisattva <br>ETH: 0xbE8f2f3B71DFEB84E5F7E3aae1909d60658aB891 <br>Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
72
+