Nikhil0987 commited on
Commit
34cf9cf
β€’
1 Parent(s): c226dff

Update home.py

Browse files
Files changed (1) hide show
  1. home.py +30 -1
home.py CHANGED
@@ -4,6 +4,32 @@ from streamlit_option_menu import option_menu
4
  from convo import Convo
5
  from remainder import rem
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  def homepage():
8
  st.title("Home")
9
  # st.header("Home Page")
@@ -14,7 +40,8 @@ def dashboard():
14
  # st.header("Dashboard")
15
 
16
  with st.sidebar:
17
- selected = option_menu("Menu", ["Home", "Dashboar","Remainder","VISUAL Q&A","Conversation","Logout"], icons=['house', 'activity'], menu_icon="cast", default_index=0)
 
18
  if selected == "Home":
19
  homepage()
20
 
@@ -29,4 +56,6 @@ def dashboard():
29
  st.experimental_rerun()
30
  elif selected == "Remainder":
31
  rem()
 
 
32
 
 
4
  from convo import Convo
5
  from remainder import rem
6
 
7
+
8
+
9
+ def load_image():
10
+ with st.sidebar:
11
+ if img := st.text_input("Enter Image URL") or st.selectbox("Select Image", ("https://images.unsplash.com/photo-1593466144596-8abd50ad2c52?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3434&q=80", "https://images.unsplash.com/photo-1566438480900-0609be27a4be?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3394&q=80")):
12
+ if st.button("Load Image"):
13
+ st.write("Image Uploaded!")
14
+ st.image(img)
15
+ else:
16
+ st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
17
+ return img
18
+
19
+
20
+
21
+ def visual_qna():
22
+ st.title("Visual Q&A")
23
+ img = load_image()
24
+ if img:
25
+ if query := st.chat_input("Enter your message"):
26
+ response = visualqna(question=query, image=img)
27
+ with st.chat_message("assistant"):
28
+ st.write(response)
29
+ else:
30
+ st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
31
+
32
+
33
  def homepage():
34
  st.title("Home")
35
  # st.header("Home Page")
 
40
  # st.header("Dashboard")
41
 
42
  with st.sidebar:
43
+ selected = option_menu("Menu", ["Home", "Dashboar","Remainder","VISUAL Q&A","Conversation","Logout"], icons=['house', 'activity'], menu_icon="cast", default_index=0),icons=['πŸ’¬','❓', 'πŸ“', 'πŸ”€', 'πŸ–ΌοΈ', 'πŸ“‘', 'πŸ”Ž', 'πŸ”“'])
44
+
45
  if selected == "Home":
46
  homepage()
47
 
 
56
  st.experimental_rerun()
57
  elif selected == "Remainder":
58
  rem()
59
+ elif selected == 'Visual Q&A':
60
+ visual_qna()
61