yurapodk commited on
Commit
5da6813
·
1 Parent(s): b5bd9ee
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -16,23 +16,23 @@ if(input_image):
16
  st.header("Original")
17
  st.image(input_image, use_column_width=True)
18
  if st.button("Get prediction"):
19
- col1, col2 = st.columns(2)
20
- col1.subheader("Prediction")
21
- response = requests.post(os.path.join(api, "bounding-boxes/"), files = {"file": input_image.getvalue()})
22
- prediction = ast.literal_eval(response.text)
23
- col1.write(prediction)
24
-
25
- col2.subheader("Image")
26
  with st.spinner("Loading..."):
 
 
 
 
 
 
 
27
  response = requests.post(os.path.join(api, "image-w-boxes/"), files = {"file": input_image.getvalue()})
28
- col2.image(response.content, use_column_width=True)
29
 
30
- arr = []
31
- for b in prediction["bboxes"]:
32
- stamp = image.crop((b["xmin"], b["ymin"], b["xmin"] + b["width"], b["ymin"] + b["height"]))
33
- output = io.BytesIO()
34
- stamp.save(output, format="BMP")
35
- response = ast.literal_eval(requests.post(os.path.join(api, "embeddings-from-cropped/"), files = {"file": output.getvalue()}).text)
36
- arr.extend(response["embedding"])
37
 
38
  st.write(arr)
 
16
  st.header("Original")
17
  st.image(input_image, use_column_width=True)
18
  if st.button("Get prediction"):
 
 
 
 
 
 
 
19
  with st.spinner("Loading..."):
20
+ col1, col2 = st.columns(2)
21
+ col1.subheader("Prediction")
22
+ response = requests.post(os.path.join(api, "bounding-boxes/"), files = {"file": input_image.getvalue()})
23
+ prediction = ast.literal_eval(response.text)
24
+ col1.write(prediction)
25
+
26
+ col2.subheader("Image")
27
  response = requests.post(os.path.join(api, "image-w-boxes/"), files = {"file": input_image.getvalue()})
28
+ col2.image(response.content, use_column_width=True)
29
 
30
+ arr = []
31
+ for b in prediction["bboxes"]:
32
+ stamp = image.crop((b["xmin"], b["ymin"], b["xmin"] + b["width"], b["ymin"] + b["height"]))
33
+ output = io.BytesIO()
34
+ stamp.save(output, format="BMP")
35
+ response = ast.literal_eval(requests.post(os.path.join(api, "embeddings-from-cropped/"), files = {"file": output.getvalue()}).text)
36
+ arr.extend(response["embedding"])
37
 
38
  st.write(arr)