Spaces:
Running
Running
Update src/streamlit_app.py
#3
by
amyliiu
- opened
- src/streamlit_app.py +12 -11
src/streamlit_app.py
CHANGED
@@ -17,13 +17,9 @@ def encode_image(image):
|
|
17 |
return base64.b64encode(buffered.getvalue()).decode("utf-8")
|
18 |
|
19 |
# Display logo
|
20 |
-
# buffered = BytesIO()
|
21 |
-
# logo_image.save(buffered, format="PNG")
|
22 |
-
# img_data = base64.b64encode(buffered.getvalue()).decode("utf-8")
|
23 |
img_logo = encode_image(logo_small)
|
24 |
img_data = encode_image(logo_image)
|
25 |
|
26 |
-
# <div class="logo-container" style="display:flex; justify-content: center;">
|
27 |
st.markdown(
|
28 |
f"""
|
29 |
<div class="logo-container" style="display:flex; justify-content: center; align-items: center; gap: 20px;">
|
@@ -49,6 +45,7 @@ st.markdown(
|
|
49 |
''',
|
50 |
unsafe_allow_html=True
|
51 |
)
|
|
|
52 |
# βββ Load data ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
53 |
@st.cache_data
|
54 |
def load_data(path):
|
@@ -64,7 +61,6 @@ def load_data(path):
|
|
64 |
|
65 |
# one page description
|
66 |
st.markdown("## π Leaderboard")
|
67 |
-
# st.markdown("**Leaderboard:** higher scores shaded green; best models bolded.")
|
68 |
|
69 |
tiers = ['F1', 'Accuracy']
|
70 |
selected_tier = st.selectbox('Select metric:', tiers)
|
@@ -91,12 +87,15 @@ if selected_tier == 'F1':
|
|
91 |
else:
|
92 |
rank = int(row[f"{col}_rank"])
|
93 |
norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
94 |
-
# interpolate green (182,243,182) β white
|
95 |
r = int(255 - norm*(255-182))
|
96 |
g = int(255 - norm*(255-243))
|
97 |
b = 255
|
98 |
bold = "font-weight:bold;" if rank == 1 else ""
|
99 |
-
|
|
|
|
|
|
|
100 |
html += f"<td style='{style}'>{val}</td>"
|
101 |
html += "</tr>"
|
102 |
html += "</table>"
|
@@ -107,6 +106,7 @@ else:
|
|
107 |
# Precompute max ranks for color scaling
|
108 |
score_cols = [f"T{i}" for i in range(1, 12)] + ["Avg"]
|
109 |
max_ranks = {col: df2[f"{col}_rank"].max() for col in score_cols}
|
|
|
110 |
# Build raw HTML table
|
111 |
cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
|
112 |
html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
|
@@ -123,12 +123,15 @@ else:
|
|
123 |
else:
|
124 |
rank = int(row[f"{col}_rank"])
|
125 |
norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
126 |
-
# interpolate green (182,243,182) β white
|
127 |
r = int(255 - norm*(255-182))
|
128 |
g = int(255 - norm*(255-243))
|
129 |
b = 255
|
130 |
bold = "font-weight:bold;" if rank == 1 else ""
|
131 |
-
|
|
|
|
|
|
|
132 |
html += f"<td style='{style}'>{val}</td>"
|
133 |
html += "</tr>"
|
134 |
html += "</table>"
|
@@ -136,8 +139,6 @@ else:
|
|
136 |
|
137 |
|
138 |
|
139 |
-
|
140 |
-
|
141 |
pipeline_image = Image.open("src/pipeline.png")
|
142 |
buffered2 = BytesIO()
|
143 |
pipeline_image.save(buffered2, format="PNG")
|
|
|
17 |
return base64.b64encode(buffered.getvalue()).decode("utf-8")
|
18 |
|
19 |
# Display logo
|
|
|
|
|
|
|
20 |
img_logo = encode_image(logo_small)
|
21 |
img_data = encode_image(logo_image)
|
22 |
|
|
|
23 |
st.markdown(
|
24 |
f"""
|
25 |
<div class="logo-container" style="display:flex; justify-content: center; align-items: center; gap: 20px;">
|
|
|
45 |
''',
|
46 |
unsafe_allow_html=True
|
47 |
)
|
48 |
+
|
49 |
# βββ Load data ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
50 |
@st.cache_data
|
51 |
def load_data(path):
|
|
|
61 |
|
62 |
# one page description
|
63 |
st.markdown("## π Leaderboard")
|
|
|
64 |
|
65 |
tiers = ['F1', 'Accuracy']
|
66 |
selected_tier = st.selectbox('Select metric:', tiers)
|
|
|
87 |
else:
|
88 |
rank = int(row[f"{col}_rank"])
|
89 |
norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
90 |
+
# interpolate green (182,243,182) β white/transparent for better contrast
|
91 |
r = int(255 - norm*(255-182))
|
92 |
g = int(255 - norm*(255-243))
|
93 |
b = 255
|
94 |
bold = "font-weight:bold;" if rank == 1 else ""
|
95 |
+
|
96 |
+
# Use dark text color for better contrast against light green backgrounds
|
97 |
+
text_color = "#000" if norm > 0.5 else "var(--text-color, #000)"
|
98 |
+
style = f"background-color:rgba({r},{g},{b},0.8); padding:6px; {bold} color:{text_color}; border: 1px solid #444;"
|
99 |
html += f"<td style='{style}'>{val}</td>"
|
100 |
html += "</tr>"
|
101 |
html += "</table>"
|
|
|
106 |
# Precompute max ranks for color scaling
|
107 |
score_cols = [f"T{i}" for i in range(1, 12)] + ["Avg"]
|
108 |
max_ranks = {col: df2[f"{col}_rank"].max() for col in score_cols}
|
109 |
+
|
110 |
# Build raw HTML table
|
111 |
cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
|
112 |
html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
|
|
|
123 |
else:
|
124 |
rank = int(row[f"{col}_rank"])
|
125 |
norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
126 |
+
# interpolate green (182,243,182) β white/transparent for better contrast
|
127 |
r = int(255 - norm*(255-182))
|
128 |
g = int(255 - norm*(255-243))
|
129 |
b = 255
|
130 |
bold = "font-weight:bold;" if rank == 1 else ""
|
131 |
+
|
132 |
+
# Use dark text color for better contrast against light green backgrounds
|
133 |
+
text_color = "#000" if norm > 0.5 else "var(--text-color, #000)"
|
134 |
+
style = f"background-color:rgba({r},{g},{b},0.8); padding:6px; {bold} color:{text_color}; border: 1px solid #444;"
|
135 |
html += f"<td style='{style}'>{val}</td>"
|
136 |
html += "</tr>"
|
137 |
html += "</table>"
|
|
|
139 |
|
140 |
|
141 |
|
|
|
|
|
142 |
pipeline_image = Image.open("src/pipeline.png")
|
143 |
buffered2 = BytesIO()
|
144 |
pipeline_image.save(buffered2, format="PNG")
|