Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +60 -25
src/streamlit_app.py
CHANGED
@@ -68,31 +68,66 @@ max_ranks = {col: df[f"{col}_rank"].max() for col in score_cols}
|
|
68 |
# one page description
|
69 |
st.markdown("## Leaderboard")
|
70 |
# st.markdown("**Leaderboard:** higher scores shaded green; best models bolded.")
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
#
|
77 |
-
for
|
78 |
-
html
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
pipeline_image = Image.open("src/pipeline.png")
|
98 |
buffered2 = BytesIO()
|
|
|
68 |
# one page description
|
69 |
st.markdown("## Leaderboard")
|
70 |
# st.markdown("**Leaderboard:** higher scores shaded green; best models bolded.")
|
71 |
+
|
72 |
+
tiers = ['F1', 'Accuracy']
|
73 |
+
selected_tier = st.selectbox('Select metric:', tiers)
|
74 |
+
|
75 |
+
if selected_tier == 'F1':
|
76 |
+
# Build raw HTML table
|
77 |
+
cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
|
78 |
+
html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
|
79 |
+
# header
|
80 |
+
html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
|
81 |
+
# rows
|
82 |
+
for _, row in df.iterrows():
|
83 |
+
html += "<tr>"
|
84 |
+
for col in cols:
|
85 |
+
val = row[col]
|
86 |
+
if col == "Model":
|
87 |
+
html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
|
88 |
+
else:
|
89 |
+
rank = int(row[f"{col}_rank"])
|
90 |
+
norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
91 |
+
# interpolate green (182,243,182) → white (255,255,255)
|
92 |
+
r = int(255 - norm*(255-182))
|
93 |
+
g = int(255 - norm*(255-243))
|
94 |
+
b = 255
|
95 |
+
bold = "font-weight:bold;" if rank == 1 else ""
|
96 |
+
style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
|
97 |
+
html += f"<td style='{style}'>{val}</td>"
|
98 |
+
html += "</tr>"
|
99 |
+
html += "</table>"
|
100 |
+
st.markdown(html, unsafe_allow_html=True)
|
101 |
+
else:
|
102 |
+
# # Build raw HTML table
|
103 |
+
# cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
|
104 |
+
# html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
|
105 |
+
# # header
|
106 |
+
# html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
|
107 |
+
# # rows
|
108 |
+
# for _, row in df.iterrows():
|
109 |
+
# html += "<tr>"
|
110 |
+
# for col in cols:
|
111 |
+
# val = row[col]
|
112 |
+
# if col == "Model":
|
113 |
+
# html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
|
114 |
+
# else:
|
115 |
+
# rank = int(row[f"{col}_rank"])
|
116 |
+
# norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
|
117 |
+
# # interpolate green (182,243,182) → white (255,255,255)
|
118 |
+
# r = int(255 - norm*(255-182))
|
119 |
+
# g = int(255 - norm*(255-243))
|
120 |
+
# b = 255
|
121 |
+
# bold = "font-weight:bold;" if rank == 1 else ""
|
122 |
+
# style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
|
123 |
+
# html += f"<td style='{style}'>{val}</td>"
|
124 |
+
# html += "</tr>"
|
125 |
+
# html += "</table>"
|
126 |
+
# st.markdown(html, unsafe_allow_html=True)
|
127 |
+
st.markdown(...)
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
|
132 |
pipeline_image = Image.open("src/pipeline.png")
|
133 |
buffered2 = BytesIO()
|