Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
|
5 |
from PIL import Image
|
6 |
import numpy as np
|
7 |
-
|
8 |
import os
|
9 |
MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
|
10 |
|
@@ -26,17 +26,9 @@ source_img = gr.Image(image_mode="RGB",
|
|
26 |
|
27 |
gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
|
28 |
|
29 |
-
def resize(width,img):
|
30 |
-
basewidth = width
|
31 |
-
img = Image.open(img)
|
32 |
-
wpercent = (basewidth/float(img.size[0]))
|
33 |
-
hsize = int((float(img.size[1])*float(wpercent)))
|
34 |
-
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
35 |
-
return img
|
36 |
-
|
37 |
def infer(prompt, init_image):
|
38 |
-
init_image =
|
39 |
-
init_image.
|
40 |
#image = pipe(prompt, init_image=init_image)["sample"][0]
|
41 |
images_list = pipe([prompt] * 2, init_image="init_image.png", strength=0.75)
|
42 |
images = []
|
|
|
4 |
|
5 |
from PIL import Image
|
6 |
import numpy as np
|
7 |
+
from io import BytesIO
|
8 |
import os
|
9 |
MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
|
10 |
|
|
|
26 |
|
27 |
gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def infer(prompt, init_image):
|
30 |
+
init_image = Image.open(BytesIO(init_image)).convert("RGB")
|
31 |
+
init_image = init_image.resize((768, 512))
|
32 |
#image = pipe(prompt, init_image=init_image)["sample"][0]
|
33 |
images_list = pipe([prompt] * 2, init_image="init_image.png", strength=0.75)
|
34 |
images = []
|