Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import requests
|
|
7 |
from io import BytesIO
|
8 |
import io
|
9 |
import base64
|
|
|
10 |
|
11 |
hf_token = os.environ.get("HF_TOKEN_API_DEMO") # we get it from a secret env variable, such that it's private
|
12 |
auth_headers = {"api_token": hf_token}
|
@@ -37,11 +38,10 @@ def api_call(image_base64_file):
|
|
37 |
return res_image
|
38 |
|
39 |
|
40 |
-
def predict(
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
image_base64_file = convert_image_to_base64_string(init_image)
|
45 |
|
46 |
gen_img = api_call(image_base64_file)
|
47 |
|
@@ -115,7 +115,7 @@ with image_blocks as demo:
|
|
115 |
image_out = gr.Image(label="Output", elem_id="output-img")
|
116 |
|
117 |
# Button click will trigger the inpainting function (now with prompt included)
|
118 |
-
btn.click(fn=predict, inputs=
|
119 |
|
120 |
gr.HTML(
|
121 |
"""
|
|
|
7 |
from io import BytesIO
|
8 |
import io
|
9 |
import base64
|
10 |
+
from loadimg import load_img
|
11 |
|
12 |
hf_token = os.environ.get("HF_TOKEN_API_DEMO") # we get it from a secret env variable, such that it's private
|
13 |
auth_headers = {"api_token": hf_token}
|
|
|
38 |
return res_image
|
39 |
|
40 |
|
41 |
+
def predict(img_input):
|
42 |
+
img = load_img(img_input
|
43 |
+
img = img.convert("RGB")
|
44 |
+
image_base64_file = convert_image_to_base64_string(img)
|
|
|
45 |
|
46 |
gen_img = api_call(image_base64_file)
|
47 |
|
|
|
115 |
image_out = gr.Image(label="Output", elem_id="output-img")
|
116 |
|
117 |
# Button click will trigger the inpainting function (now with prompt included)
|
118 |
+
btn.click(fn=predict, inputs=image, outputs=[image_out], api_name='run')
|
119 |
|
120 |
gr.HTML(
|
121 |
"""
|