File size: 2,140 Bytes
9e04f95
 
4dbc387
9fed614
 
4ecbae5
fa2bec2
9e04f95
34cf9cf
316fa78
 
34cf9cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f33c2bf
34cf9cf
 
 
 
 
 
9e04f95
 
 
 
 
6085ca5
da73757
9e04f95
 
 
 
e8278a8
34cf9cf
9e04f95
 
 
 
 
b921497
 
5bfab8c
74a1018
d75866e
 
 
c910970
cf9b250
34cf9cf
 
cf9b250
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import streamlit as st
from streamlit_option_menu import option_menu
from chat import Chat

from convo import Convo
from remainder import rem
from transformers import pipeline


visualqna = pipeline(model="dandelin/vilt-b32-finetuned-vqa")


def load_image():
    with st.sidebar:
        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")):
            if st.button("Load Image"):
                st.write("Image Uploaded!")
                st.image(img)
        else:
            st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
    return img



def visual_qna():
    st.title("Visual Q&A")
    img = load_image()
    if img:
        if query := st.chat_input("Enter your message"):
            response = visualqna(question=query, image=img)
            with st.chat_message("assistant"):
                st.write(response)
    else:
        st.warning("Please enter an image URL and click 'Load Image' before asking a question.")
    

def homepage():
    st.title("Home")   
    # st.header("Home Page")
    st.subheader("Welcome to the Home Page")

def Dashboard():
    # st.title("Chat")
    # st.title("Dashboard")
    # st.header("Dashboard")

    with st.sidebar:
        selected = option_menu("Menu", ["Home", "Dashboar","Remainder","Visual Q&A","Conversation","Logout"])
                    
    if selected == "Home":
        homepage()
        
    elif selected == "Dashboard":
        "gfjfvjhvjhv"
    elif selected == "Chat":
        Chat()
    elif selected == "Conversation": 
        Convo()
    elif selected == "Logout":
        st.session_state["user"] = "visitor"
        st.experimental_rerun()
    elif selected == "Remainder":
        rem()
    elif selected == 'Visual Q&A':
        visual_qna()