Spaces:
Runtime error
Runtime error
Nik Ska
commited on
Commit
•
f700bcc
1
Parent(s):
f92697a
endpoint tst
Browse files
app.py
CHANGED
@@ -11,7 +11,9 @@ from PIL import Image
|
|
11 |
import base64
|
12 |
import numpy as np
|
13 |
import io
|
|
|
14 |
|
|
|
15 |
|
16 |
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
|
17 |
model_path = huggingface_hub.hf_hub_download(
|
@@ -60,10 +62,15 @@ def get_mask(img_in):
|
|
60 |
|
61 |
print(f"{img_in=}")
|
62 |
|
|
|
|
|
|
|
|
|
|
|
63 |
file_path = "/tmp/img_in.jpg"
|
64 |
-
|
65 |
|
66 |
-
upload_url =
|
67 |
|
68 |
files = {'file': open(file_path, 'rb')}
|
69 |
|
@@ -73,7 +80,8 @@ def get_mask(img_in):
|
|
73 |
result = response.json()
|
74 |
print('Result:', result)
|
75 |
|
76 |
-
mask = Image.open(io.BytesIO(base64.b64decode(
|
|
|
77 |
img_in = img_in.convert("RGBA")
|
78 |
img_in.putalpha(mask)
|
79 |
|
|
|
11 |
import base64
|
12 |
import numpy as np
|
13 |
import io
|
14 |
+
import streamlit as st
|
15 |
|
16 |
+
print(st.secrets["ENDPOINT"])
|
17 |
|
18 |
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
|
19 |
model_path = huggingface_hub.hf_hub_download(
|
|
|
62 |
|
63 |
print(f"{img_in=}")
|
64 |
|
65 |
+
# covert to 8-bit RGB
|
66 |
+
img_in = img_in.convert("RGB")
|
67 |
+
|
68 |
+
img_in_smol = img_in.resize((256, 256))
|
69 |
+
|
70 |
file_path = "/tmp/img_in.jpg"
|
71 |
+
img_in_smol.save(file_path)
|
72 |
|
73 |
+
upload_url = st.secrets["ENDPOINT"]
|
74 |
|
75 |
files = {'file': open(file_path, 'rb')}
|
76 |
|
|
|
80 |
result = response.json()
|
81 |
print('Result:', result)
|
82 |
|
83 |
+
mask = Image.open(io.BytesIO(base64.b64decode(
|
84 |
+
result['mask']))).resize(img_in.size)
|
85 |
img_in = img_in.convert("RGBA")
|
86 |
img_in.putalpha(mask)
|
87 |
|