Prathamesh1420 commited on
Commit
d1591c4
·
verified ·
1 Parent(s): eb28bdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import streamlit as st
2
  import os
3
  from PIL import Image
4
- import numpy as np
5
  from chatbot import Chatbot # Assuming you have a chatbot module
6
 
7
  # Function to save uploaded file
@@ -43,11 +42,19 @@ def show_dashboard():
43
  _, recommended_products = chatbot.generate_response(caption)
44
 
45
  st.write("### Recommended Products")
46
- col1, col2, col3, col4, col5 = st.columns(5)
47
- for i, idx in enumerate(recommended_products[:5]):
48
- with col1 if i == 0 else col2 if i == 1 else col3 if i == 2 else col4 if i == 3 else col5:
 
 
 
49
  product_image = chatbot.images[idx['corpus_id']]
50
  st.image(product_image, caption=f"Product {i+1}", width=150)
 
 
 
 
 
51
  else:
52
  st.error("Error in uploading the file.")
53
 
 
1
  import streamlit as st
2
  import os
3
  from PIL import Image
 
4
  from chatbot import Chatbot # Assuming you have a chatbot module
5
 
6
  # Function to save uploaded file
 
42
  _, recommended_products = chatbot.generate_response(caption)
43
 
44
  st.write("### Recommended Products")
45
+ if 'num_recommendations' not in st.session_state:
46
+ st.session_state.num_recommendations = 5
47
+
48
+ for i, idx in enumerate(recommended_products[:st.session_state.num_recommendations]):
49
+ col = st.columns(5)[i % 5]
50
+ with col:
51
  product_image = chatbot.images[idx['corpus_id']]
52
  st.image(product_image, caption=f"Product {i+1}", width=150)
53
+
54
+ if st.session_state.num_recommendations < len(recommended_products):
55
+ if st.button("Suggest More"):
56
+ st.session_state.num_recommendations += 5
57
+ st.experimental_rerun()
58
  else:
59
  st.error("Error in uploading the file.")
60