Manjushri commited on
Commit
e8b5fd4
1 Parent(s): 0485290

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -25,13 +25,10 @@ else:
25
  refiner = refiner.to(device)
26
  refiner.unet = torch.compile(refiner.unet, mode="reduce-overhead", fullgraph=True)
27
 
28
- n_steps = 40
29
- high_noise_frac = 0.8
30
-
31
- def genie (prompt, negative_prompt, height, width, scale, steps, seed, prompt_2, negative_prompt_2):
32
- generator = torch.Generator(device=device).manual_seed(seed)
33
  int_image = pipe(prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
34
- image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image).images[0]
35
  return image
36
 
37
  gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
@@ -42,7 +39,8 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
42
  gr.Slider(25, maximum=50, value=25, step=1, label='Number of Iterations'),
43
  gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True),
44
  gr.Textbox(label='Embedded Prompt'),
45
- gr.Textbox(label='Embedded Negative Prompt')],
 
46
  outputs='image',
47
  title="Stable Diffusion XL 1.0 CPU or GPU",
48
  description="SDXL 1.0 CPU or GPU. Currently running on CPU. <br><br><b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively. This model is capable of producing NSFW (Softcore) images.",
 
25
  refiner = refiner.to(device)
26
  refiner.unet = torch.compile(refiner.unet, mode="reduce-overhead", fullgraph=True)
27
 
28
+ def genie (prompt, negative_prompt, height, width, scale, steps, seed, prompt_2, negative_prompt_2, high_noise_frac):
29
+ generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
 
 
 
30
  int_image = pipe(prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
31
+ 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]
32
  return image
33
 
34
  gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
 
39
  gr.Slider(25, maximum=50, value=25, step=1, label='Number of Iterations'),
40
  gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True),
41
  gr.Textbox(label='Embedded Prompt'),
42
+ gr.Textbox(label='Embedded Negative Prompt'),
43
+ gr.Slider(minimum=.7, maximum=.99, value=.95, step=.01, label='Refiner Denoise Start %')],
44
  outputs='image',
45
  title="Stable Diffusion XL 1.0 CPU or GPU",
46
  description="SDXL 1.0 CPU or GPU. Currently running on CPU. <br><br><b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively. This model is capable of producing NSFW (Softcore) images.",