Manjushri commited on
Commit
99abb5b
·
verified ·
1 Parent(s): cd81805

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -3,7 +3,7 @@ import torch
3
  import numpy as np
4
  import modin.pandas as pd
5
  from PIL import Image
6
- from diffusers import DiffusionPipeline #, StableDiffusion3Pipeline
7
  from huggingface_hub import hf_hub_download
8
 
9
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
@@ -52,9 +52,24 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed):
52
  image = pipe(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
53
  torch.cuda.empty_cache()
54
  return image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  return image
56
 
57
- gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 4', "FXL"], value='PhotoReal', label='Choose Model'),
58
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
59
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
60
  gr.Slider(512, 1024, 768, step=128, label='Height'),
 
3
  import numpy as np
4
  import modin.pandas as pd
5
  from PIL import Image
6
+ from diffusers import DiffusionPipeline, StableDiffusion3Pipeline
7
  from huggingface_hub import hf_hub_download
8
 
9
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
 
52
  image = pipe(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
53
  torch.cuda.empty_cache()
54
  return image
55
+ if Model == "SD3.5":
56
+ torch.cuda.max_memory_allocated(device=device)
57
+ torch.cuda.empty_cache()
58
+ pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium", torch_dtype=torch.float16).to(device)
59
+ pipe.enable_xformers_memory_efficient_attention()
60
+ torch.cuda.empty_cache()
61
+ image = pipe(
62
+ prompt=Prompt,
63
+ height=height,
64
+ width=width,
65
+ negative_prompt=negative_prompt,
66
+ guidance_scale=scale,
67
+ num_images_per_prompt=1,
68
+ num_inference_steps=steps).images[0]
69
+ torch.cuda.empty_cache()
70
  return image
71
 
72
+ gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 4', "FXL", "SD3.5"], value='PhotoReal', label='Choose Model'),
73
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
74
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
75
  gr.Slider(512, 1024, 768, step=128, label='Height'),