Spaces:
Sleeping
Sleeping
Update home.py
Browse files
home.py
CHANGED
@@ -1,5 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def dashboard():
|
5 |
st.title("Dashboard")
|
|
|
1 |
import streamlit as st
|
2 |
+
from streamlit_option_menu import option_menu
|
3 |
+
from transformers import pipeline, Conversation
|
4 |
+
|
5 |
+
visualqna = pipeline(model="dandelin/vilt-b32-finetuned-vqa")
|
6 |
+
|
7 |
+
def load_image():
|
8 |
+
with st.sidebar:
|
9 |
+
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")):
|
10 |
+
if st.button("Load Image"):
|
11 |
+
st.write("Image Uploaded!")
|
12 |
+
st.image(img)
|
13 |
+
else:
|
14 |
+
st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
|
15 |
+
return img
|
16 |
+
|
17 |
+
def visual_qna():
|
18 |
+
st.title("Visual Q&A")
|
19 |
+
img = load_image()
|
20 |
+
if img:
|
21 |
+
if query := st.chat_input("Enter your message"):
|
22 |
+
response = visualqna(question=query, image=img)
|
23 |
+
with st.chat_message("assistant"):
|
24 |
+
st.write(response)
|
25 |
+
else:
|
26 |
+
st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
|
31 |
def dashboard():
|
32 |
st.title("Dashboard")
|