fffiloni commited on
Commit
5a2437e
1 Parent(s): 46d3c81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -17,8 +17,13 @@ device="cpu"
17
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
18
  pipe.to(device)
19
 
20
- def infer(prompt):
21
- image = pipe(prompt)["sample"][0]
 
 
 
 
 
22
  return image
23
 
24
  print("Great sylvain ! Everything is working fine !")
@@ -26,5 +31,5 @@ print("Great sylvain ! Everything is working fine !")
26
  title="Stable Diffusion CPU"
27
  description="Stable Diffusion example using CPU and HF token. Warning: Slow process... ~5/10 min inference time"
28
 
29
- gr.Interface(fn=infer, inputs="text", outputs="image",title=title,description=description).launch(enable_queue=True)
30
 
 
17
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
18
  pipe.to(device)
19
 
20
+ def infer(prompt, init_image):
21
+ if init_image != None:
22
+ init_image = init_image.resize((512, 512))
23
+ init_image = preprocess(init_image)
24
+ image = pipe(prompt, init_image=init_image)["sample"][0]
25
+ else:
26
+ image = pipe(prompt)["sample"][0]
27
  return image
28
 
29
  print("Great sylvain ! Everything is working fine !")
 
31
  title="Stable Diffusion CPU"
32
  description="Stable Diffusion example using CPU and HF token. Warning: Slow process... ~5/10 min inference time"
33
 
34
+ gr.Interface(fn=infer, inputs=["text", "image"], outputs="image",title=title,description=description).launch(enable_queue=True)
35