fffiloni commited on
Commit
c05b820
1 Parent(s): b8b5ea2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -21,9 +21,16 @@ pipe.to(device)
21
 
22
  gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
23
 
 
 
 
 
 
 
 
 
24
  def infer(prompt, init_image):
25
- init_image = Image.open(BytesIO(init_image)).convert("RGB")
26
- init_image = init_image.resize((512, 512))
27
  #image = pipe(prompt, init_image=init_image)["sample"][0]
28
  images_list = pipe([prompt] * 2, init_image=init_image, strength=0.75)
29
  images = []
 
21
 
22
  gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
23
 
24
+ def resize(width,img):
25
+ basewidth = width
26
+ img = Image.open(img)
27
+ wpercent = (basewidth/float(img.size[0]))
28
+ hsize = int((float(img.size[1])*float(wpercent)))
29
+ img = img.resize((basewidth,hsize), Image.ANTIALIAS)
30
+ return img
31
+
32
  def infer(prompt, init_image):
33
+ init_image = resize(512,init_image)
 
34
  #image = pipe(prompt, init_image=init_image)["sample"][0]
35
  images_list = pipe([prompt] * 2, init_image=init_image, strength=0.75)
36
  images = []