dejanseo commited on
Commit
25eb719
·
verified ·
1 Parent(s): e2c8383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -45,6 +45,11 @@ def fetch_images_from_url(url):
45
  img_urls = [img['src'] for img in img_tags if 'src' in img.attrs]
46
  return img_urls
47
 
 
 
 
 
 
48
  def main():
49
  st.set_page_config(layout="wide")
50
  st.title("Shopping Intent Classification - SEO by DEJAN")
@@ -81,16 +86,13 @@ def main():
81
  output_data_shopping_intent = run_inference(interpreter, input_data)
82
 
83
  shopping_intent_percentages = (output_data_shopping_intent.flatten() * 100).tolist()
84
- formatted_percentages = [f"{intent:.2f} %" for intent in shopping_intent_percentages]
85
-
86
  col1, col2 = st.columns([1, 3])
87
  with col1:
88
  st.image(image.resize((224, 224)), width=224)
89
  with col2:
90
  st.write(f"[URL]({img_url})")
91
- for category, percentage in zip(categories, shopping_intent_percentages):
92
- st.write(f"{category}: {percentage:.2f} %")
93
- st.progress(int(percentage))
94
  st.write("---")
95
  except Exception as e:
96
  st.write(f"Could not process image {img_url}: {e}")
 
45
  img_urls = [img['src'] for img in img_tags if 'src' in img.attrs]
46
  return img_urls
47
 
48
+ def render_intent_bars(labels, percentages):
49
+ for label, percentage in zip(labels, percentages):
50
+ bar = "#" * int(percentage // 5) # Adjust the scale as needed
51
+ st.write(f"{label} | {bar} {percentage:.2f} %")
52
+
53
  def main():
54
  st.set_page_config(layout="wide")
55
  st.title("Shopping Intent Classification - SEO by DEJAN")
 
86
  output_data_shopping_intent = run_inference(interpreter, input_data)
87
 
88
  shopping_intent_percentages = (output_data_shopping_intent.flatten() * 100).tolist()
89
+
 
90
  col1, col2 = st.columns([1, 3])
91
  with col1:
92
  st.image(image.resize((224, 224)), width=224)
93
  with col2:
94
  st.write(f"[URL]({img_url})")
95
+ render_intent_bars(categories, shopping_intent_percentages)
 
 
96
  st.write("---")
97
  except Exception as e:
98
  st.write(f"Could not process image {img_url}: {e}")