Update src/streamlit_app.py
Browse files- src/streamlit_app.py +33 -9
src/streamlit_app.py
CHANGED
|
@@ -232,21 +232,45 @@ def create_bar_chart(df, view_type):
|
|
| 232 |
|
| 233 |
return fig
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
# Main content
|
| 236 |
st.title("NaviTrace Leaderboard")
|
| 237 |
|
| 238 |
# Links
|
| 239 |
st.markdown("""
|
| 240 |
<div class="links-container">
|
|
|
|
|
|
|
|
|
|
| 241 |
<a href="https://your-paper-website.com" target="_blank">
|
| 242 |
<i class="fas fa-file-pdf"></i> Paper
|
| 243 |
</a>
|
| 244 |
-
<a href="https://huggingface.co/datasets/your-username/navitrace" target="_blank">
|
| 245 |
-
<i class="fas fa-database"></i> Dataset
|
| 246 |
-
</a>
|
| 247 |
<a href="https://github.com/your-username/navitrace" target="_blank">
|
| 248 |
<i class="fab fa-github"></i> Code
|
| 249 |
</a>
|
|
|
|
|
|
|
|
|
|
| 250 |
<a href="https://your-demo-link.com" target="_blank">
|
| 251 |
<i class="far fa-images"></i> Demo
|
| 252 |
</a>
|
|
@@ -304,7 +328,7 @@ with st.expander("How to Test Your Model", expanded=True):
|
|
| 304 |
<div class="instruction-content">
|
| 305 |
<div><b>Run Evaluation</b></div>
|
| 306 |
<div>
|
| 307 |
-
Download and run our evaluation notebook
|
| 308 |
</div>
|
| 309 |
</div>
|
| 310 |
</div>
|
|
@@ -319,13 +343,13 @@ with st.expander("How to Test Your Model", expanded=True):
|
|
| 319 |
<div class="instruction-content">
|
| 320 |
<div><b>Upload Results</b></div>
|
| 321 |
<div>
|
| 322 |
-
Upload the TSV file generated by the evaluation notebook.
|
| 323 |
</div>
|
| 324 |
</div>
|
| 325 |
</div>
|
| 326 |
""", unsafe_allow_html=True)
|
| 327 |
|
| 328 |
-
uploaded_file = st.file_uploader("
|
| 329 |
|
| 330 |
# Step 3
|
| 331 |
st.markdown("""
|
|
@@ -334,19 +358,19 @@ with st.expander("How to Test Your Model", expanded=True):
|
|
| 334 |
<div class="instruction-content">
|
| 335 |
<div><b>Calculate Score</b></div>
|
| 336 |
<div>
|
| 337 |
-
Click the button below to evaluate your predictions. Scores are calculated using
|
| 338 |
</div>
|
| 339 |
</div>
|
| 340 |
</div>
|
| 341 |
""", unsafe_allow_html=True)
|
| 342 |
|
| 343 |
if uploaded_file is not None:
|
| 344 |
-
if st.button("Calculate Score", use_container_width=
|
| 345 |
with st.spinner("Validating and calculating scores..."):
|
| 346 |
# Validate format
|
| 347 |
is_valid, result = validate_tsv_format(uploaded_file)
|
| 348 |
if is_valid:
|
| 349 |
-
# Calculate score using
|
| 350 |
scores = calculate_score(result)
|
| 351 |
if scores is not None:
|
| 352 |
st.success(f"✅ Score calculated successfully: **{scores['Total Score']:.1f}**")
|
|
|
|
| 232 |
|
| 233 |
return fig
|
| 234 |
|
| 235 |
+
# Serve only the chart as JSON if parameter "only_chart" is set
|
| 236 |
+
# E.g. https://huggingface.co/spaces/leggedrobotics/navitrace_leaderboard/?only_chart=total_score
|
| 237 |
+
params = st.query_params()
|
| 238 |
+
if "only_chart" in params:
|
| 239 |
+
if params["only_chart"] == "total_score":
|
| 240 |
+
view_type = "Total Score"
|
| 241 |
+
elif params["only_chart"] == "per_embodiment":
|
| 242 |
+
view_type = "Per Embodiment"
|
| 243 |
+
elif params["only_chart"] == "per_category":
|
| 244 |
+
view_type = "Per Category"
|
| 245 |
+
else:
|
| 246 |
+
break
|
| 247 |
+
|
| 248 |
+
# Create chart
|
| 249 |
+
df = load_sample_data()
|
| 250 |
+
fig = create_bar_chart(df, view_type)
|
| 251 |
+
|
| 252 |
+
# Only output JSON
|
| 253 |
+
st.write(json.dumps(fig.to_dict()))
|
| 254 |
+
st.stop()
|
| 255 |
+
|
| 256 |
# Main content
|
| 257 |
st.title("NaviTrace Leaderboard")
|
| 258 |
|
| 259 |
# Links
|
| 260 |
st.markdown("""
|
| 261 |
<div class="links-container">
|
| 262 |
+
<a href="https://leggedrobotics.github.io/navitrace_webpage/" target="_blank">
|
| 263 |
+
<i class="fas fa-house"></i> Project
|
| 264 |
+
</a>
|
| 265 |
<a href="https://your-paper-website.com" target="_blank">
|
| 266 |
<i class="fas fa-file-pdf"></i> Paper
|
| 267 |
</a>
|
|
|
|
|
|
|
|
|
|
| 268 |
<a href="https://github.com/your-username/navitrace" target="_blank">
|
| 269 |
<i class="fab fa-github"></i> Code
|
| 270 |
</a>
|
| 271 |
+
<a href="https://huggingface.co/datasets/your-username/navitrace" target="_blank">
|
| 272 |
+
<i class="fas fa-database"></i> Dataset
|
| 273 |
+
</a>
|
| 274 |
<a href="https://your-demo-link.com" target="_blank">
|
| 275 |
<i class="far fa-images"></i> Demo
|
| 276 |
</a>
|
|
|
|
| 328 |
<div class="instruction-content">
|
| 329 |
<div><b>Run Evaluation</b></div>
|
| 330 |
<div>
|
| 331 |
+
Download and run our evaluation notebook adjusted to your model. The notebook will generate a TSV file with your model's predictions on the test set.
|
| 332 |
</div>
|
| 333 |
</div>
|
| 334 |
</div>
|
|
|
|
| 343 |
<div class="instruction-content">
|
| 344 |
<div><b>Upload Results</b></div>
|
| 345 |
<div>
|
| 346 |
+
Upload the TSV file generated by the evaluation notebook.
|
| 347 |
</div>
|
| 348 |
</div>
|
| 349 |
</div>
|
| 350 |
""", unsafe_allow_html=True)
|
| 351 |
|
| 352 |
+
uploaded_file = st.file_uploader("", type=['tsv', 'txt'])
|
| 353 |
|
| 354 |
# Step 3
|
| 355 |
st.markdown("""
|
|
|
|
| 358 |
<div class="instruction-content">
|
| 359 |
<div><b>Calculate Score</b></div>
|
| 360 |
<div>
|
| 361 |
+
Click the button below to evaluate your predictions. Scores are calculated using hidden test set ground-truths.
|
| 362 |
</div>
|
| 363 |
</div>
|
| 364 |
</div>
|
| 365 |
""", unsafe_allow_html=True)
|
| 366 |
|
| 367 |
if uploaded_file is not None:
|
| 368 |
+
if st.button("🧮 Calculate Score", use_container_width=True):
|
| 369 |
with st.spinner("Validating and calculating scores..."):
|
| 370 |
# Validate format
|
| 371 |
is_valid, result = validate_tsv_format(uploaded_file)
|
| 372 |
if is_valid:
|
| 373 |
+
# Calculate score using hidden ground-truth
|
| 374 |
scores = calculate_score(result)
|
| 375 |
if scores is not None:
|
| 376 |
st.success(f"✅ Score calculated successfully: **{scores['Total Score']:.1f}**")
|