-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
58 lines (52 loc) · 1.78 KB
/
app.py
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
import streamlit as st
from Text2Image_search import MultimodalSearch
st.set_page_config(
layout="wide",
page_title="Text2Image Search App",
page_icon="🔍"
)
# Add custom CSS for styling
st.markdown(
"""
<style>
body {
background-color: #89cff0; /* Set your desired background color */
}
.stMarkdown h1 {
text-align: center;
color: #cb4154;
}
.stTextInput {
width: 50%; /* Adjust the width as needed */
margin: auto;
}
</style>
""",
unsafe_allow_html=True
)
def main():
st.markdown("<h1>Text2Image Search App</h1>", unsafe_allow_html=True)
multimodal_search = MultimodalSearch()
query = st.text_input("Enter your query:")
C1, C2, C3 = st.columns([1, 1, 1])
with C2:
searchBtn = C2.button('Search')
if searchBtn:
if len(query) > 0:
results = multimodal_search.search(query)
st.warning("Your query was "+query)
st.subheader("Search Results:")
col1, col2, col3 = st.columns([1,1,1])
with col1:
st.write(f"Score: {round(results[0].score*100, 2)}%")
st.image(results[0].content, use_column_width=True)
with col2:
st.write(f"Score: {round(results[1].score*100, 2)}%")
st.image(results[1].content, use_column_width=True)
with col3:
st.write(f"Score: {round(results[2].score*100, 2)}%")
st.image(results[2].content, use_column_width=True)
else:
st.warning("Please enter a query.")
if __name__ == "__main__":
main()