Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import requests
|
|
6 |
from io import BytesIO
|
7 |
from bs4 import BeautifulSoup
|
8 |
import pandas as pd
|
9 |
-
import base64
|
10 |
import os
|
11 |
|
12 |
def download_model(model_url, model_path):
|
@@ -66,9 +65,6 @@ def main():
|
|
66 |
input_shape = input_details[0]['shape']
|
67 |
input_size = input_shape[1] # assuming square input
|
68 |
|
69 |
-
data = []
|
70 |
-
errors = []
|
71 |
-
|
72 |
for img_url in img_urls:
|
73 |
try:
|
74 |
response = requests.get(img_url)
|
@@ -78,31 +74,20 @@ def main():
|
|
78 |
output_data_shopping_intent = run_inference(interpreter, input_data)
|
79 |
|
80 |
shopping_intent_percentages = (output_data_shopping_intent.flatten() * 100).tolist()
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
st.write(f"Shopping Intent 1 (%): {shopping_intent_percentages[0]}")
|
93 |
-
st.write(f"Shopping Intent 2 (%): {shopping_intent_percentages[1]}")
|
94 |
-
st.write(f"Shopping Intent 3 (%): {shopping_intent_percentages[2]}")
|
95 |
-
st.write(f"Shopping Intent 4 (%): {shopping_intent_percentages[3]}")
|
96 |
st.write("---")
|
97 |
-
|
98 |
except Exception as e:
|
99 |
-
|
100 |
-
|
101 |
-
# Display errors in an expandable section
|
102 |
-
if errors:
|
103 |
-
with st.expander(f"Could not process {len(errors)} images"):
|
104 |
-
for error in errors:
|
105 |
-
st.write(error)
|
106 |
|
107 |
if __name__ == "__main__":
|
108 |
main()
|
|
|
6 |
from io import BytesIO
|
7 |
from bs4 import BeautifulSoup
|
8 |
import pandas as pd
|
|
|
9 |
import os
|
10 |
|
11 |
def download_model(model_url, model_path):
|
|
|
65 |
input_shape = input_details[0]['shape']
|
66 |
input_size = input_shape[1] # assuming square input
|
67 |
|
|
|
|
|
|
|
68 |
for img_url in img_urls:
|
69 |
try:
|
70 |
response = requests.get(img_url)
|
|
|
74 |
output_data_shopping_intent = run_inference(interpreter, input_data)
|
75 |
|
76 |
shopping_intent_percentages = (output_data_shopping_intent.flatten() * 100).tolist()
|
77 |
+
formatted_percentages = [f"{intent:.2f} %" for intent in shopping_intent_percentages]
|
78 |
+
|
79 |
+
col1, col2 = st.columns([1, 3])
|
80 |
+
with col1:
|
81 |
+
st.image(image.resize((224, 224)), width=224)
|
82 |
+
with col2:
|
83 |
+
st.write(f"[URL]({img_url})")
|
84 |
+
st.write(f"Intent 1: {formatted_percentages[0]}")
|
85 |
+
st.write(f"Intent 2: {formatted_percentages[1]}")
|
86 |
+
st.write(f"Intent 3: {formatted_percentages[2]}")
|
87 |
+
st.write(f"Intent 4: {formatted_percentages[3]}")
|
|
|
|
|
|
|
|
|
88 |
st.write("---")
|
|
|
89 |
except Exception as e:
|
90 |
+
st.write(f"Could not process image {img_url}: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
main()
|