Update app.py
Browse files
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 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
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 |
|