gilalnauman commited on
Commit
db5c9f8
·
verified ·
1 Parent(s): 07b4ac7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +163 -163
app.py CHANGED
@@ -105,148 +105,6 @@
105
  # interactive Bubble plot
106
 
107
 
108
- # import streamlit as st
109
- # import pandas as pd
110
- # import altair as alt
111
-
112
- # # Set page layout to wide mode
113
- # st.set_page_config(
114
- # page_title="PathVLMs Leaderboard",
115
- # page_icon="🏆",
116
- # layout="wide"
117
- # )
118
-
119
- # # Load the leaderboard data
120
- # df = pd.read_csv("leaderboard.csv")
121
-
122
- # # Add title and description
123
- # st.title("PathVLMs Leaderboard 🏆")
124
- # st.markdown("""
125
- # Welcome to the **PathVLMs Leaderboard**! This leaderboard displays evaluation results for various Vision-Language Models (VLMs) in Pathology, focusing on multiple-choice questions (MCQs), answers, and explanations.
126
- # You can search, filter, and visualize metrics for better insights.
127
- # """)
128
-
129
- # # Sidebar Filters
130
- # with st.sidebar:
131
- # st.subheader("Filters")
132
- # # Search by model name (fuzzy search)
133
- # search_query = st.text_input("Search for Model Name", value="", placeholder="e.g., llava")
134
-
135
- # # Filter by model size
136
- # model_sizes = df['Params (B)'].unique()
137
- # selected_sizes = st.multiselect("Select Model Sizes", options=model_sizes, default=model_sizes)
138
-
139
- # # Filter by model type
140
- # if 'Language Model' in df.columns:
141
- # model_types = df['Language Model'].unique()
142
- # selected_types = st.multiselect("Select Model Types", options=model_types, default=model_types)
143
- # else:
144
- # selected_types = []
145
-
146
- # # Apply Filters
147
- # filtered_df = df[
148
- # (df['Params (B)'].isin(selected_sizes)) &
149
- # (df['Language Model'].isin(selected_types) if selected_types else True) &
150
- # (df['Method'].str.contains(search_query, case=False, na=False))
151
- # ]
152
-
153
- # # Main Leaderboard Section
154
- # st.subheader("Leaderboard Table")
155
- # if filtered_df.empty:
156
- # st.warning("No results found. Try adjusting the filters.")
157
- # else:
158
- # # Display table in wide layout
159
- # st.dataframe(
160
- # filtered_df,
161
- # height=600, # Adjust table height
162
- # width=1600 # Adjust table width
163
- # )
164
-
165
- # # Visualization of selected metric
166
- # st.subheader("Performance Metrics Visualization")
167
- # metric = st.selectbox("Select Metric to Visualize", options=filtered_df.columns[5:])
168
-
169
- # # Visualization Chart
170
- # chart = alt.Chart(filtered_df).mark_bar().encode(
171
- # x=alt.X('Method', sort=alt.EncodingSortField(field=metric, order='descending'), title="Model"),
172
- # y=alt.Y(metric, title=metric),
173
- # color='Method',
174
- # tooltip=['Method', metric]
175
- # ).properties(
176
- # width=1400, # Full width
177
- # height=600 # Increased height
178
- # )
179
- # st.altair_chart(chart, use_container_width=True)
180
-
181
- # # Interactive Bubble Plot: Metric vs. Model Size
182
- # st.subheader("Interactive Bubble Plot: Metric vs. Model Size")
183
- # bubble_metric = st.selectbox("Select Metric for Bubble Plot", options=filtered_df.columns[5:], index=0)
184
-
185
- # if bubble_metric in filtered_df.columns and 'Params (B)' in filtered_df.columns:
186
- # interactive_bubble_chart = alt.Chart(filtered_df).mark_circle(size=200).encode(
187
- # x=alt.X('Params (B):Q', title="Model Size (in Billion Params)"),
188
- # y=alt.Y(f'{bubble_metric}:Q', title=bubble_metric),
189
- # size=alt.Size('Params (B):Q', legend=None),
190
- # color=alt.Color('Method:N', title="Model"),
191
- # tooltip=['Method', 'Params (B)', bubble_metric]
192
- # ).properties(
193
- # width=800,
194
- # height=600
195
- # )
196
- # st.altair_chart(interactive_bubble_chart, use_container_width=True)
197
- # else:
198
- # st.warning(f"Columns '{bubble_metric}' and 'Params (B)' are required for the bubble plot.")
199
-
200
- # # # Highlight Top N Models
201
- # # st.subheader("Highlight Top N Models")
202
- # # top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
203
- # # top_models_df = filtered_df.nlargest(top_n, metric)
204
-
205
- # # top_chart = alt.Chart(top_models_df).mark_bar().encode(
206
- # # x=alt.X('Method', title="Model"),
207
- # # y=alt.Y(metric, title=metric),
208
- # # color='Method',
209
- # # tooltip=['Method', metric]
210
- # # ).properties(
211
- # # width=1400, # Full width
212
- # # height=400 # Adjusted height for smaller chart
213
- # # )
214
- # # st.altair_chart(top_chart, use_container_width=True)
215
-
216
- # # Highlight Top N Models
217
- # st.subheader("Highlight Top N Models")
218
- # top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
219
- # top_models_df = filtered_df.nlargest(top_n, metric)
220
-
221
- # top_chart = alt.Chart(top_models_df).mark_bar().encode(
222
- # x=alt.X('Method', title="Model"),
223
- # y=alt.Y(metric, title=metric),
224
- # color='Method',
225
- # tooltip=['Method', metric]
226
- # ).properties(
227
- # width=1400, # Full width
228
- # height=400 # Adjusted height for smaller chart
229
- # )
230
- # st.altair_chart(top_chart, use_container_width=True)
231
-
232
-
233
- # # Download Button
234
- # @st.cache
235
- # def convert_df_to_csv(dataframe):
236
- # return dataframe.to_csv(index=False).encode('utf-8')
237
-
238
- # csv_data = convert_df_to_csv(filtered_df)
239
- # st.download_button(
240
- # label="Download Filtered Results",
241
- # data=csv_data,
242
- # file_name="filtered_leaderboard.csv",
243
- # mime="text/csv"
244
- # )
245
-
246
-
247
-
248
- # inteactive bubble plot and pagination
249
-
250
  import streamlit as st
251
  import pandas as pd
252
  import altair as alt
@@ -265,7 +123,7 @@ df = pd.read_csv("leaderboard.csv")
265
  st.title("PathVLMs Leaderboard 🏆")
266
  st.markdown("""
267
  Welcome to the **PathVLMs Leaderboard**! This leaderboard displays evaluation results for various Vision-Language Models (VLMs) in Pathology, focusing on multiple-choice questions (MCQs), answers, and explanations.
268
- You can search, filter, and sort the leaderboard dynamically by score for better insights.
269
  """)
270
 
271
  # Sidebar Filters
@@ -292,30 +150,24 @@ filtered_df = df[
292
  (df['Method'].str.contains(search_query, case=False, na=False))
293
  ]
294
 
295
- # Add Sorting Option
296
- st.subheader("Leaderboard Table with Dynamic Sorting")
297
  if filtered_df.empty:
298
  st.warning("No results found. Try adjusting the filters.")
299
  else:
300
- # Dropdown to select the score column to sort by
301
- sort_column = st.selectbox(
302
- "Sort by Score Column",
303
- options=filtered_df.columns[5:], # Only score-related columns
304
- index=0 # Default to the first score column
305
  )
306
 
307
- # Sort the dataframe by the selected column in descending order
308
- sorted_df = filtered_df.sort_values(by=sort_column, ascending=False)
309
-
310
- # Display the sorted table
311
- st.dataframe(sorted_df, use_container_width=True)
312
-
313
  # Visualization of selected metric
314
  st.subheader("Performance Metrics Visualization")
315
  metric = st.selectbox("Select Metric to Visualize", options=filtered_df.columns[5:])
316
 
317
  # Visualization Chart
318
- chart = alt.Chart(sorted_df).mark_bar().encode(
319
  x=alt.X('Method', sort=alt.EncodingSortField(field=metric, order='descending'), title="Model"),
320
  y=alt.Y(metric, title=metric),
321
  color='Method',
@@ -326,7 +178,7 @@ else:
326
  )
327
  st.altair_chart(chart, use_container_width=True)
328
 
329
- # Bubble Plot: Metric vs. Model Size
330
  st.subheader("Interactive Bubble Plot: Metric vs. Model Size")
331
  bubble_metric = st.selectbox("Select Metric for Bubble Plot", options=filtered_df.columns[5:], index=0)
332
 
@@ -345,10 +197,26 @@ else:
345
  else:
346
  st.warning(f"Columns '{bubble_metric}' and 'Params (B)' are required for the bubble plot.")
347
 
348
- # Highlight Top N Models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  st.subheader("Highlight Top N Models")
350
  top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
351
- top_models_df = sorted_df.nlargest(top_n, metric)
352
 
353
  top_chart = alt.Chart(top_models_df).mark_bar().encode(
354
  x=alt.X('Method', title="Model"),
@@ -361,20 +229,152 @@ else:
361
  )
362
  st.altair_chart(top_chart, use_container_width=True)
363
 
 
364
  # Download Button
365
  @st.cache
366
  def convert_df_to_csv(dataframe):
367
  return dataframe.to_csv(index=False).encode('utf-8')
368
 
369
- csv_data = convert_df_to_csv(sorted_df)
370
  st.download_button(
371
- label="Download Sorted Results",
372
  data=csv_data,
373
- file_name="sorted_leaderboard.csv",
374
  mime="text/csv"
375
  )
376
 
377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  # with bubble plot
379
 
380
  # import streamlit as st
 
105
  # interactive Bubble plot
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  import streamlit as st
109
  import pandas as pd
110
  import altair as alt
 
123
  st.title("PathVLMs Leaderboard 🏆")
124
  st.markdown("""
125
  Welcome to the **PathVLMs Leaderboard**! This leaderboard displays evaluation results for various Vision-Language Models (VLMs) in Pathology, focusing on multiple-choice questions (MCQs), answers, and explanations.
126
+ You can search, filter, and visualize metrics for better insights.
127
  """)
128
 
129
  # Sidebar Filters
 
150
  (df['Method'].str.contains(search_query, case=False, na=False))
151
  ]
152
 
153
+ # Main Leaderboard Section
154
+ st.subheader("Leaderboard Table")
155
  if filtered_df.empty:
156
  st.warning("No results found. Try adjusting the filters.")
157
  else:
158
+ # Display table in wide layout
159
+ st.dataframe(
160
+ filtered_df,
161
+ height=600, # Adjust table height
162
+ width=1600 # Adjust table width
163
  )
164
 
 
 
 
 
 
 
165
  # Visualization of selected metric
166
  st.subheader("Performance Metrics Visualization")
167
  metric = st.selectbox("Select Metric to Visualize", options=filtered_df.columns[5:])
168
 
169
  # Visualization Chart
170
+ chart = alt.Chart(filtered_df).mark_bar().encode(
171
  x=alt.X('Method', sort=alt.EncodingSortField(field=metric, order='descending'), title="Model"),
172
  y=alt.Y(metric, title=metric),
173
  color='Method',
 
178
  )
179
  st.altair_chart(chart, use_container_width=True)
180
 
181
+ # Interactive Bubble Plot: Metric vs. Model Size
182
  st.subheader("Interactive Bubble Plot: Metric vs. Model Size")
183
  bubble_metric = st.selectbox("Select Metric for Bubble Plot", options=filtered_df.columns[5:], index=0)
184
 
 
197
  else:
198
  st.warning(f"Columns '{bubble_metric}' and 'Params (B)' are required for the bubble plot.")
199
 
200
+ # # Highlight Top N Models
201
+ # st.subheader("Highlight Top N Models")
202
+ # top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
203
+ # top_models_df = filtered_df.nlargest(top_n, metric)
204
+
205
+ # top_chart = alt.Chart(top_models_df).mark_bar().encode(
206
+ # x=alt.X('Method', title="Model"),
207
+ # y=alt.Y(metric, title=metric),
208
+ # color='Method',
209
+ # tooltip=['Method', metric]
210
+ # ).properties(
211
+ # width=1400, # Full width
212
+ # height=400 # Adjusted height for smaller chart
213
+ # )
214
+ # st.altair_chart(top_chart, use_container_width=True)
215
+
216
+ # Highlight Top N Models
217
  st.subheader("Highlight Top N Models")
218
  top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
219
+ top_models_df = filtered_df.nlargest(top_n, metric)
220
 
221
  top_chart = alt.Chart(top_models_df).mark_bar().encode(
222
  x=alt.X('Method', title="Model"),
 
229
  )
230
  st.altair_chart(top_chart, use_container_width=True)
231
 
232
+
233
  # Download Button
234
  @st.cache
235
  def convert_df_to_csv(dataframe):
236
  return dataframe.to_csv(index=False).encode('utf-8')
237
 
238
+ csv_data = convert_df_to_csv(filtered_df)
239
  st.download_button(
240
+ label="Download Filtered Results",
241
  data=csv_data,
242
+ file_name="filtered_leaderboard.csv",
243
  mime="text/csv"
244
  )
245
 
246
 
247
+
248
+ # inteactive bubble plot and pagination
249
+
250
+ # import streamlit as st
251
+ # import pandas as pd
252
+ # import altair as alt
253
+
254
+ # # Set page layout to wide mode
255
+ # st.set_page_config(
256
+ # page_title="PathVLMs Leaderboard",
257
+ # page_icon="🏆",
258
+ # layout="wide"
259
+ # )
260
+
261
+ # # Load the leaderboard data
262
+ # df = pd.read_csv("leaderboard.csv")
263
+
264
+ # # Add title and description
265
+ # st.title("PathVLMs Leaderboard 🏆")
266
+ # st.markdown("""
267
+ # Welcome to the **PathVLMs Leaderboard**! This leaderboard displays evaluation results for various Vision-Language Models (VLMs) in Pathology, focusing on multiple-choice questions (MCQs), answers, and explanations.
268
+ # You can search, filter, and sort the leaderboard dynamically by score for better insights.
269
+ # """)
270
+
271
+ # # Sidebar Filters
272
+ # with st.sidebar:
273
+ # st.subheader("Filters")
274
+ # # Search by model name (fuzzy search)
275
+ # search_query = st.text_input("Search for Model Name", value="", placeholder="e.g., llava")
276
+
277
+ # # Filter by model size
278
+ # model_sizes = df['Params (B)'].unique()
279
+ # selected_sizes = st.multiselect("Select Model Sizes", options=model_sizes, default=model_sizes)
280
+
281
+ # # Filter by model type
282
+ # if 'Language Model' in df.columns:
283
+ # model_types = df['Language Model'].unique()
284
+ # selected_types = st.multiselect("Select Model Types", options=model_types, default=model_types)
285
+ # else:
286
+ # selected_types = []
287
+
288
+ # # Apply Filters
289
+ # filtered_df = df[
290
+ # (df['Params (B)'].isin(selected_sizes)) &
291
+ # (df['Language Model'].isin(selected_types) if selected_types else True) &
292
+ # (df['Method'].str.contains(search_query, case=False, na=False))
293
+ # ]
294
+
295
+ # # Add Sorting Option
296
+ # st.subheader("Leaderboard Table with Dynamic Sorting")
297
+ # if filtered_df.empty:
298
+ # st.warning("No results found. Try adjusting the filters.")
299
+ # else:
300
+ # # Dropdown to select the score column to sort by
301
+ # sort_column = st.selectbox(
302
+ # "Sort by Score Column",
303
+ # options=filtered_df.columns[5:], # Only score-related columns
304
+ # index=0 # Default to the first score column
305
+ # )
306
+
307
+ # # Sort the dataframe by the selected column in descending order
308
+ # sorted_df = filtered_df.sort_values(by=sort_column, ascending=False)
309
+
310
+ # # Display the sorted table
311
+ # st.dataframe(sorted_df, use_container_width=True)
312
+
313
+ # # Visualization of selected metric
314
+ # st.subheader("Performance Metrics Visualization")
315
+ # metric = st.selectbox("Select Metric to Visualize", options=filtered_df.columns[5:])
316
+
317
+ # # Visualization Chart
318
+ # chart = alt.Chart(sorted_df).mark_bar().encode(
319
+ # x=alt.X('Method', sort=alt.EncodingSortField(field=metric, order='descending'), title="Model"),
320
+ # y=alt.Y(metric, title=metric),
321
+ # color='Method',
322
+ # tooltip=['Method', metric]
323
+ # ).properties(
324
+ # width=1400, # Full width
325
+ # height=600 # Increased height
326
+ # )
327
+ # st.altair_chart(chart, use_container_width=True)
328
+
329
+ # # Bubble Plot: Metric vs. Model Size
330
+ # st.subheader("Interactive Bubble Plot: Metric vs. Model Size")
331
+ # bubble_metric = st.selectbox("Select Metric for Bubble Plot", options=filtered_df.columns[5:], index=0)
332
+
333
+ # if bubble_metric in filtered_df.columns and 'Params (B)' in filtered_df.columns:
334
+ # interactive_bubble_chart = alt.Chart(filtered_df).mark_circle(size=200).encode(
335
+ # x=alt.X('Params (B):Q', title="Model Size (in Billion Params)"),
336
+ # y=alt.Y(f'{bubble_metric}:Q', title=bubble_metric),
337
+ # size=alt.Size('Params (B):Q', legend=None),
338
+ # color=alt.Color('Method:N', title="Model"),
339
+ # tooltip=['Method', 'Params (B)', bubble_metric]
340
+ # ).properties(
341
+ # width=800,
342
+ # height=600
343
+ # )
344
+ # st.altair_chart(interactive_bubble_chart, use_container_width=True)
345
+ # else:
346
+ # st.warning(f"Columns '{bubble_metric}' and 'Params (B)' are required for the bubble plot.")
347
+
348
+ # # Highlight Top N Models
349
+ # st.subheader("Highlight Top N Models")
350
+ # top_n = st.slider("Number of Top Models", min_value=1, max_value=len(filtered_df), value=5)
351
+ # top_models_df = sorted_df.nlargest(top_n, metric)
352
+
353
+ # top_chart = alt.Chart(top_models_df).mark_bar().encode(
354
+ # x=alt.X('Method', title="Model"),
355
+ # y=alt.Y(metric, title=metric),
356
+ # color='Method',
357
+ # tooltip=['Method', metric]
358
+ # ).properties(
359
+ # width=1400, # Full width
360
+ # height=400 # Adjusted height for smaller chart
361
+ # )
362
+ # st.altair_chart(top_chart, use_container_width=True)
363
+
364
+ # # Download Button
365
+ # @st.cache
366
+ # def convert_df_to_csv(dataframe):
367
+ # return dataframe.to_csv(index=False).encode('utf-8')
368
+
369
+ # csv_data = convert_df_to_csv(sorted_df)
370
+ # st.download_button(
371
+ # label="Download Sorted Results",
372
+ # data=csv_data,
373
+ # file_name="sorted_leaderboard.csv",
374
+ # mime="text/csv"
375
+ # )
376
+
377
+
378
  # with bubble plot
379
 
380
  # import streamlit as st