NikeZoldyck commited on
Commit
ea3f597
1 Parent(s): 08454fc

SD pipeline

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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
 
@@ -145,8 +145,8 @@ with demo:
145
 
146
  gallery = gr.Gallery(label="Generated images", show_label=True).style(grid=(1, 3), height="auto")
147
  # image_options = gr.Radio(label="Pick", interactive=True, choices=None, type="value")
148
- text.submit(infer, inputs=[text, samples], outputs=gallery)
149
- btn.click(infer, inputs=[text, samples], outputs=gallery, show_progress=True, status_tracker=None)
150
 
151
 
152
  # 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
 
 
145
 
146
  gallery = gr.Gallery(label="Generated images", show_label=True).style(grid=(1, 3), height="auto")
147
  # image_options = gr.Radio(label="Pick", interactive=True, choices=None, type="value")
148
+ text.submit(infer_original, inputs=[text, samples], outputs=gallery)
149
+ btn.click(infer_original, inputs=[text, samples], outputs=gallery, show_progress=True, status_tracker=None)
150
 
151
 
152
  # Second Row - Backgrounds