Manjushri commited on
Commit
b08bb51
·
verified ·
1 Parent(s): 22ff8d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -26
app.py CHANGED
@@ -54,35 +54,10 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, re
54
  torch.cuda.empty_cache()
55
  return image
56
 
57
- if Model == "SDXL 1.0":
58
-
59
- torch.cuda.empty_cache()
60
- torch.cuda.max_memory_allocated(device=device)
61
- sdxl = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
62
- sdxl.enable_xformers_memory_efficient_attention()
63
- sdxl = sdxl.to(device)
64
- torch.cuda.empty_cache()
65
 
66
- if refine == "Yes":
67
- torch.cuda.max_memory_allocated(device=device)
68
- torch.cuda.empty_cache()
69
- image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale, output_type="latent").images
70
- torch.cuda.empty_cache()
71
- sdxl = 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")
72
- sdxl.enable_xformers_memory_efficient_attention()
73
- sdxl = sdxl.to(device)
74
- torch.cuda.empty_cache()
75
- refined = sdxl(Prompt, negative_prompt=negative_prompt, image=image, denoising_start=high_noise_frac).images[0]
76
- torch.cuda.empty_cache()
77
- return refined
78
- else:
79
- image = sdxl(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
80
- torch.cuda.empty_cache()
81
- return image
82
-
83
  return image
84
 
85
- gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 3.0', 'SDXL 1.0',], value='PhotoReal', label='Choose Model'),
86
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
87
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
88
  gr.Slider(512, 1024, 768, step=128, label='Height'),
 
54
  torch.cuda.empty_cache()
55
  return image
56
 
 
 
 
 
 
 
 
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  return image
59
 
60
+ gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 3.0',], value='PhotoReal', label='Choose Model'),
61
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
62
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
63
  gr.Slider(512, 1024, 768, step=128, label='Height'),