Spaces:
Runtime error
Runtime error
first commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- app.py +153 -0
- index/.gitkeep +0 -0
- index/_c.fdm +0 -0
- index/_c.fdt +0 -0
- index/_c.fdx +0 -0
- index/_c.fnm +0 -0
- index/_c.nvd +0 -0
- index/_c.nvm +0 -0
- index/_c.si +0 -0
- index/_c_Lucene90_0.doc +0 -0
- index/_c_Lucene90_0.dvd +0 -0
- index/_c_Lucene90_0.dvm +0 -0
- index/_c_Lucene90_0.pos +3 -0
- index/_c_Lucene90_0.tim +0 -0
- index/_c_Lucene90_0.tip +0 -0
- index/_c_Lucene90_0.tmd +0 -0
- index/_d.fdm +0 -0
- index/_d.fdt +0 -0
- index/_d.fdx +0 -0
- index/_d.fnm +0 -0
- index/_d.nvd +0 -0
- index/_d.nvm +0 -0
- index/_d.si +0 -0
- index/_d_Lucene90_0.doc +0 -0
- index/_d_Lucene90_0.dvd +0 -0
- index/_d_Lucene90_0.dvm +0 -0
- index/_d_Lucene90_0.pos +3 -0
- index/_d_Lucene90_0.tim +0 -0
- index/_d_Lucene90_0.tip +0 -0
- index/_d_Lucene90_0.tmd +0 -0
- index/_e.fdm +0 -0
- index/_e.fdt +0 -0
- index/_e.fdx +0 -0
- index/_e.fnm +0 -0
- index/_e.nvd +0 -0
- index/_e.nvm +0 -0
- index/_e.si +0 -0
- index/_e_Lucene90_0.doc +0 -0
- index/_e_Lucene90_0.dvd +0 -0
- index/_e_Lucene90_0.dvm +0 -0
- index/_e_Lucene90_0.pos +3 -0
- index/_e_Lucene90_0.tim +0 -0
- index/_e_Lucene90_0.tip +0 -0
- index/_e_Lucene90_0.tmd +0 -0
- index/_f.fdm +0 -0
- index/_f.fdt +0 -0
- index/_f.fdx +0 -0
- index/_f.fnm +0 -0
- index/_f.nvd +0 -0
- index/_f.nvm +0 -0
app.py
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
import streamlit.components.v1 as components
|
5 |
+
from datasets import load_dataset
|
6 |
+
|
7 |
+
|
8 |
+
st.set_page_config(page_title="Gaia Search", layout="wide")
|
9 |
+
|
10 |
+
os.makedirs(os.path.join(os.getcwd(), ".streamlit"), exist_ok=True)
|
11 |
+
with open(os.path.join(os.getcwd(), ".streamlit/config.toml"), "w") as file:
|
12 |
+
file.write('[theme]\nbase="light"')
|
13 |
+
|
14 |
+
|
15 |
+
st.sidebar.markdown(
|
16 |
+
"""
|
17 |
+
<style>
|
18 |
+
.aligncenter {
|
19 |
+
text-align: center;
|
20 |
+
font-weight: bold;
|
21 |
+
font-size: 50px;
|
22 |
+
}
|
23 |
+
</style>
|
24 |
+
<p class="aligncenter">Gaia Search 🌖🌏</p>
|
25 |
+
<p style="text-align: center;"> A search engine for the LAION large scale image caption corpora</p>
|
26 |
+
""",
|
27 |
+
unsafe_allow_html=True,
|
28 |
+
)
|
29 |
+
|
30 |
+
st.sidebar.markdown(
|
31 |
+
"""
|
32 |
+
<style>
|
33 |
+
.aligncenter {
|
34 |
+
text-align: center;
|
35 |
+
}
|
36 |
+
</style>
|
37 |
+
<p style='text-align: center'>
|
38 |
+
<a href="" >GitHub</a> | <a href="" >Project Report</a>
|
39 |
+
</p>
|
40 |
+
<p class="aligncenter">
|
41 |
+
<a href="" target="_blank">
|
42 |
+
<img src="https://colab.research.google.com/assets/colab-badge.svg"/>
|
43 |
+
</a>
|
44 |
+
</p>
|
45 |
+
""",
|
46 |
+
unsafe_allow_html=True,
|
47 |
+
)
|
48 |
+
|
49 |
+
query = st.sidebar.text_input(label="Search query", value="")
|
50 |
+
|
51 |
+
footer = """<style>
|
52 |
+
.footer {
|
53 |
+
position: fixed;
|
54 |
+
left: 0;
|
55 |
+
bottom: 0;
|
56 |
+
width: 100%;
|
57 |
+
background-color: white;
|
58 |
+
color: black;
|
59 |
+
text-align: center;
|
60 |
+
}
|
61 |
+
</style>
|
62 |
+
<div class="footer">
|
63 |
+
<p>Powered by <a href="https://huggingface.co/" >HuggingFace 🤗</a> and <a href="https://github.com/castorini/pyserini" >Pyserini 🦆</a></p>
|
64 |
+
</div>
|
65 |
+
"""
|
66 |
+
st.sidebar.markdown(footer, unsafe_allow_html=True)
|
67 |
+
|
68 |
+
|
69 |
+
searcher = LuceneSearcher("index")
|
70 |
+
ds = load_dataset("imdb", split="train")
|
71 |
+
|
72 |
+
|
73 |
+
def search(query):
|
74 |
+
hits = searcher.search(query, k=10)
|
75 |
+
results = ds.select([int(hit.docid) for hit in hits])
|
76 |
+
return results + "<br><br>"
|
77 |
+
|
78 |
+
|
79 |
+
if st.sidebar.button("Search"):
|
80 |
+
results = search(query)
|
81 |
+
rendered_results = f"""
|
82 |
+
<div id="searchresultsarea">
|
83 |
+
<br>
|
84 |
+
{results}
|
85 |
+
</div>
|
86 |
+
"""
|
87 |
+
st.markdown(
|
88 |
+
"""
|
89 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
90 |
+
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
91 |
+
""",
|
92 |
+
unsafe_allow_html=True,
|
93 |
+
)
|
94 |
+
st.markdown(
|
95 |
+
"""
|
96 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
97 |
+
""",
|
98 |
+
unsafe_allow_html=True,
|
99 |
+
)
|
100 |
+
st.markdown(
|
101 |
+
f"""
|
102 |
+
<div class="row no-gutters mt-3 align-items-center">
|
103 |
+
Gaia Search 🌖🌏
|
104 |
+
<div class="col col-md-4">
|
105 |
+
<input class="form-control border-secondary rounded-pill pr-5" type="search" value="{query}" id="example-search-input2">
|
106 |
+
</div>
|
107 |
+
<div class="col-auto">
|
108 |
+
<button class="btn btn-outline-light text-dark border-0 rounded-pill ml-n5" type="button">
|
109 |
+
<i class="fa fa-search"></i>
|
110 |
+
</button>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
""",
|
114 |
+
unsafe_allow_html=True,
|
115 |
+
)
|
116 |
+
components.html(
|
117 |
+
"""
|
118 |
+
<style>
|
119 |
+
#searchresultsarea {
|
120 |
+
font-family: 'Arial';
|
121 |
+
}
|
122 |
+
|
123 |
+
#searchresultsnumber {
|
124 |
+
font-size: 0.8rem;
|
125 |
+
color: gray;
|
126 |
+
}
|
127 |
+
|
128 |
+
.searchresult h2 {
|
129 |
+
font-size: 19px;
|
130 |
+
line-height: 18px;
|
131 |
+
font-weight: normal;
|
132 |
+
color: rgb(7, 111, 222);
|
133 |
+
margin-bottom: 0px;
|
134 |
+
margin-top: 25px;
|
135 |
+
}
|
136 |
+
|
137 |
+
.searchresult a {
|
138 |
+
font-size: 12px;
|
139 |
+
line-height: 12px;
|
140 |
+
color: green;
|
141 |
+
margin-bottom: 0px;
|
142 |
+
}
|
143 |
+
|
144 |
+
.dark-mode {
|
145 |
+
color: white;
|
146 |
+
}
|
147 |
+
</style>
|
148 |
+
<button onclick="myFunction()">Toggle dark mode</button>
|
149 |
+
"""
|
150 |
+
+ rendered_results,
|
151 |
+
height=800,
|
152 |
+
scrolling=True,
|
153 |
+
)
|
index/.gitkeep
ADDED
File without changes
|
index/_c.fdm
ADDED
Binary file (158 Bytes). View file
|
|
index/_c.fdt
ADDED
Binary file (36.5 kB). View file
|
|
index/_c.fdx
ADDED
Binary file (93 Bytes). View file
|
|
index/_c.fnm
ADDED
Binary file (322 Bytes). View file
|
|
index/_c.nvd
ADDED
Binary file (6.37 kB). View file
|
|
index/_c.nvm
ADDED
Binary file (103 Bytes). View file
|
|
index/_c.si
ADDED
Binary file (498 Bytes). View file
|
|
index/_c_Lucene90_0.doc
ADDED
Binary file (927 kB). View file
|
|
index/_c_Lucene90_0.dvd
ADDED
Binary file (38.2 kB). View file
|
|
index/_c_Lucene90_0.dvm
ADDED
Binary file (171 Bytes). View file
|
|
index/_c_Lucene90_0.pos
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f4ac8c1c910a978617aa54300a6c2421ab1295ad8fd3a28da9eca9ffec36948d
|
3 |
+
size 1240149
|
index/_c_Lucene90_0.tim
ADDED
Binary file (311 kB). View file
|
|
index/_c_Lucene90_0.tip
ADDED
Binary file (8.41 kB). View file
|
|
index/_c_Lucene90_0.tmd
ADDED
Binary file (263 Bytes). View file
|
|
index/_d.fdm
ADDED
Binary file (157 Bytes). View file
|
|
index/_d.fdt
ADDED
Binary file (36.4 kB). View file
|
|
index/_d.fdx
ADDED
Binary file (93 Bytes). View file
|
|
index/_d.fnm
ADDED
Binary file (322 Bytes). View file
|
|
index/_d.nvd
ADDED
Binary file (6.29 kB). View file
|
|
index/_d.nvm
ADDED
Binary file (103 Bytes). View file
|
|
index/_d.si
ADDED
Binary file (498 Bytes). View file
|
|
index/_d_Lucene90_0.doc
ADDED
Binary file (937 kB). View file
|
|
index/_d_Lucene90_0.dvd
ADDED
Binary file (37.9 kB). View file
|
|
index/_d_Lucene90_0.dvm
ADDED
Binary file (171 Bytes). View file
|
|
index/_d_Lucene90_0.pos
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cf1185b23dfe7d554487554e5b731375c22821508fcf8781aec15d0899984efa
|
3 |
+
size 1262499
|
index/_d_Lucene90_0.tim
ADDED
Binary file (314 kB). View file
|
|
index/_d_Lucene90_0.tip
ADDED
Binary file (8.64 kB). View file
|
|
index/_d_Lucene90_0.tmd
ADDED
Binary file (257 Bytes). View file
|
|
index/_e.fdm
ADDED
Binary file (158 Bytes). View file
|
|
index/_e.fdt
ADDED
Binary file (35.6 kB). View file
|
|
index/_e.fdx
ADDED
Binary file (83 Bytes). View file
|
|
index/_e.fnm
ADDED
Binary file (322 Bytes). View file
|
|
index/_e.nvd
ADDED
Binary file (6.18 kB). View file
|
|
index/_e.nvm
ADDED
Binary file (103 Bytes). View file
|
|
index/_e.si
ADDED
Binary file (498 Bytes). View file
|
|
index/_e_Lucene90_0.doc
ADDED
Binary file (917 kB). View file
|
|
index/_e_Lucene90_0.dvd
ADDED
Binary file (37.3 kB). View file
|
|
index/_e_Lucene90_0.dvm
ADDED
Binary file (171 Bytes). View file
|
|
index/_e_Lucene90_0.pos
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4ccaee5e5633b5c35ba7045c5e12e692587380d32c3020b81bac24a28da69ca2
|
3 |
+
size 1238216
|
index/_e_Lucene90_0.tim
ADDED
Binary file (309 kB). View file
|
|
index/_e_Lucene90_0.tip
ADDED
Binary file (8.29 kB). View file
|
|
index/_e_Lucene90_0.tmd
ADDED
Binary file (258 Bytes). View file
|
|
index/_f.fdm
ADDED
Binary file (158 Bytes). View file
|
|
index/_f.fdt
ADDED
Binary file (36.7 kB). View file
|
|
index/_f.fdx
ADDED
Binary file (93 Bytes). View file
|
|
index/_f.fnm
ADDED
Binary file (322 Bytes). View file
|
|
index/_f.nvd
ADDED
Binary file (6.39 kB). View file
|
|
index/_f.nvm
ADDED
Binary file (103 Bytes). View file
|
|