NikeZoldyck commited on
Commit
545bebe
1 Parent(s): 3ccc105

using diffusers

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -25,13 +25,13 @@ model_id = "CompVis/stable-diffusion-v1-4"
25
  device = "cuda" if torch.cuda.is_available() else "cpu"
26
  context = autocast if device == "cuda" else nullcontext
27
 
28
- # pipe = StableDiffusionPipeline.from_pretrained(model_id,use_auth_token=token).to(device)
29
- #
30
- #
31
- # def infer_original(prompt,samples):
32
- # with context(device):
33
- # images = pipe(samples*[prompt], guidance_scale=7.5).images
34
- # return images
35
 
36
 
37
 
@@ -144,8 +144,8 @@ with demo:
144
 
145
  gallery = gr.Gallery(label="Generated images", show_label=True).style(grid=(1, 3), height="auto")
146
  # image_options = gr.Radio(label="Pick", interactive=True, choices=None, type="value")
147
- text.submit(infer, inputs=[text, samples], outputs=gallery)
148
- btn.click(infer, inputs=[text, samples], outputs=gallery, show_progress=True, status_tracker=None)
149
 
150
 
151
  # Second Row - Backgrounds
 
25
  device = "cuda" if torch.cuda.is_available() else "cpu"
26
  context = autocast if device == "cuda" else nullcontext
27
 
28
+ pipe = StableDiffusionPipeline.from_pretrained(model_id,use_auth_token=token).to(device)
29
+
30
+
31
+ def infer_original(prompt,samples):
32
+ with context(device):
33
+ images = pipe(samples*[prompt], guidance_scale=7.5).images
34
+ return images
35
 
36
 
37
 
 
144
 
145
  gallery = gr.Gallery(label="Generated images", show_label=True).style(grid=(1, 3), height="auto")
146
  # image_options = gr.Radio(label="Pick", interactive=True, choices=None, type="value")
147
+ text.submit(infer_original, inputs=[text, samples], outputs=gallery)
148
+ btn.click(infer_original, inputs=[text, samples], outputs=gallery, show_progress=True, status_tracker=None)
149
 
150
 
151
  # Second Row - Backgrounds