Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import ast
|
2 |
import os
|
3 |
import requests
|
4 |
-
from requests_toolbelt.multipart.encoder import MultipartEncoder
|
5 |
from PIL import Image
|
6 |
import streamlit as st
|
7 |
import io
|
@@ -9,13 +8,14 @@ import io
|
|
9 |
api = "https://7bb4-188-130-155-168.ngrok-free.app"
|
10 |
|
11 |
st.title("Stamp2vec")
|
|
|
12 |
|
13 |
input_image = st.file_uploader("insert image")
|
14 |
if(input_image):
|
15 |
image = Image.open(input_image)
|
16 |
st.header("Original")
|
17 |
st.image(input_image, use_column_width=True)
|
18 |
-
if
|
19 |
with st.spinner("Loading..."):
|
20 |
response = requests.post(os.path.join(api, "bounding-boxes/"), files = {"file": input_image.getvalue()})
|
21 |
prediction = ast.literal_eval(response.text)
|
@@ -29,11 +29,11 @@ if(input_image):
|
|
29 |
response = ast.literal_eval(requests.post(os.path.join(api, "embeddings-from-cropped/"), files = {"file": output.getvalue()}).text)
|
30 |
arr.extend(response["embedding"])
|
31 |
|
32 |
-
col1, col2 = st.columns(2)
|
33 |
col1.subheader("Prediction")
|
34 |
col1.write(prediction)
|
35 |
|
36 |
col2.subheader("Image")
|
37 |
col2.image(image_with_boxes, use_column_width=True)
|
38 |
|
39 |
-
|
|
|
|
1 |
import ast
|
2 |
import os
|
3 |
import requests
|
|
|
4 |
from PIL import Image
|
5 |
import streamlit as st
|
6 |
import io
|
|
|
8 |
api = "https://7bb4-188-130-155-168.ngrok-free.app"
|
9 |
|
10 |
st.title("Stamp2vec")
|
11 |
+
col1, col2, col3 = st.columns(3)
|
12 |
|
13 |
input_image = st.file_uploader("insert image")
|
14 |
if(input_image):
|
15 |
image = Image.open(input_image)
|
16 |
st.header("Original")
|
17 |
st.image(input_image, use_column_width=True)
|
18 |
+
if col2.button("Get prediction"):
|
19 |
with st.spinner("Loading..."):
|
20 |
response = requests.post(os.path.join(api, "bounding-boxes/"), files = {"file": input_image.getvalue()})
|
21 |
prediction = ast.literal_eval(response.text)
|
|
|
29 |
response = ast.literal_eval(requests.post(os.path.join(api, "embeddings-from-cropped/"), files = {"file": output.getvalue()}).text)
|
30 |
arr.extend(response["embedding"])
|
31 |
|
|
|
32 |
col1.subheader("Prediction")
|
33 |
col1.write(prediction)
|
34 |
|
35 |
col2.subheader("Image")
|
36 |
col2.image(image_with_boxes, use_column_width=True)
|
37 |
|
38 |
+
col3.subheader("Embedding")
|
39 |
+
col3.write(arr)
|