Spaces:
Sleeping
Sleeping
add streamlit frontend stuff
Browse files- frontend/styles.css +44 -0
- streamlit.py +37 -0
frontend/styles.css
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* White mode CSS */
|
| 2 |
+
|
| 3 |
+
body {
|
| 4 |
+
background-color: #FFFFFF; /* Light background */
|
| 5 |
+
color: #212529; /* Dark text */
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.stApp {
|
| 9 |
+
background-color: #FFFFFF; /* Light background */
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
h1, h2, h3, h4, h5, h6 {
|
| 13 |
+
color: #212529; /* Dark headings */
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
a {
|
| 17 |
+
color: #007BFF; /* Bootstrap primary link color */
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.css-18e3th9 {
|
| 21 |
+
background-color: #F8F9FA; /* Light gray for input fields */
|
| 22 |
+
border-color: #CED4DA; /* Gray border for input fields */
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.dark-mode-btn {
|
| 26 |
+
position: absolute;
|
| 27 |
+
top: 10px;
|
| 28 |
+
right: 10px;
|
| 29 |
+
background-color: transparent;
|
| 30 |
+
border: none;
|
| 31 |
+
font-size: 20px;
|
| 32 |
+
cursor: pointer;
|
| 33 |
+
color: #212529; /* Dark button text */
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Change the text color of the input field */
|
| 37 |
+
input {
|
| 38 |
+
color: #212529; /* Dark input text */
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Change the placeholder text color */
|
| 42 |
+
input::placeholder {
|
| 43 |
+
color: #6C757D; /* Placeholder color */
|
| 44 |
+
}
|
streamlit.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from core.recommender import EmbeddingProcessor, Recommender
|
| 4 |
+
|
| 5 |
+
st.title("U.S. ML PhD Faculty Advisor Recommender")
|
| 6 |
+
|
| 7 |
+
# Define CSS for light and dark mode toggle
|
| 8 |
+
def load_css(css_file):
|
| 9 |
+
with open(css_file, "r") as f:
|
| 10 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
| 11 |
+
|
| 12 |
+
load_css("frontend/styles.css")
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# Set up
|
| 16 |
+
embedding_processor = EmbeddingProcessor()
|
| 17 |
+
recommender = Recommender(embedding_processor)
|
| 18 |
+
|
| 19 |
+
# Query input field
|
| 20 |
+
query = st.text_input("Name an ML research area you are interested in (e.g. low-rank adaptation)")
|
| 21 |
+
|
| 22 |
+
# Search and display professors
|
| 23 |
+
if query:
|
| 24 |
+
top_k_indices = recommender.get_top_k(query, top_k=10)
|
| 25 |
+
professors_data = recommender.get_recommended_data(top_k_indices)
|
| 26 |
+
|
| 27 |
+
if professors_data:
|
| 28 |
+
for professor_data in professors_data:
|
| 29 |
+
st.subheader(professor_data["name"])
|
| 30 |
+
st.write(f"{professor_data['title']} of {professor_data['department']}, {professor_data['university']}")
|
| 31 |
+
|
| 32 |
+
# List of papers
|
| 33 |
+
st.write("Most Relevant Papers:")
|
| 34 |
+
for paper in professor_data["papers"]:
|
| 35 |
+
st.markdown(f"- [{paper[1]}](https://arxiv.org/abs/{paper[0]})")
|
| 36 |
+
else:
|
| 37 |
+
st.write("No results found for your query.")
|