import gradio as gr from utils import * from content import * from css_html_js import * with gr.Blocks(title=f'{benchname} Leaderboard', css=custom_css) as demo: gr.Markdown(intro_md) with gr.Tabs(elem_classes='tab-buttons') as tabs: with gr.TabItem('🏅 Main Leaderboard', elem_id='main', id=0): table, type_map = build_df() headers = [coln for coln in table.columns if not coln.startswith('_')] datatypes = [type_map[x] for x in headers] colwidths = [80, 400, 120, 130] + [155 for _ in headers[4:]] with gr.Row(): model_name = gr.Textbox( value=search_default_val, label='Model Name', interactive=True, visible=True, ) model_size = gr.CheckboxGroup( choices=MODEL_SIZE, value=MODEL_SIZE, label='Model Size', interactive=True, ) model_type = gr.CheckboxGroup( choices=MODEL_TYPE, value=MODEL_TYPE, label='Model Type', interactive=True, ) data_component = gr.components.DataFrame( value=table[headers], type='pandas', datatype=datatypes, interactive=False, visible=True, max_height=700, column_widths=colwidths, ) def filter_df(model_name, model_size, model_type): df = table.copy(deep=True) df['_vis'] = [model_size_flag(x, model_size) for x in df['_parameters']] df['_vis'] &= pd.Series([model_type_flag(df.iloc[i], model_type) for i in range(len(df))]) if model_name != search_default_val: model_name_lower = model_name.lower() df['_vis'] &= pd.Series([(model_name_lower in name.lower()) for name in df['_name'].tolist()]) df = df[df['_vis']] df['Rank'] = list(range(1, len(df)+1)) ret = gr.components.DataFrame( value=df[headers], type='pandas', datatype=datatypes, interactive=False, wrap=True, visible=True, column_widths=colwidths, ) return ret model_name.submit(filter_df, [model_name, model_size, model_type], data_component) model_size.change(filter_df, [model_name, model_size, model_type], data_component) model_type.change(filter_df, [model_name, model_size, model_type], data_component) with gr.TabItem('📝 About', elem_id='about', id=1): gr.Markdown(about_md) with gr.TabItem('🚀 Submit your model', elem_id='submit', id=2): gr.Markdown(submit_md) # with gr.Row(): # with gr.Accordion('Citation', open=False): # gr.Markdown(citation_md) gr.Markdown(Bottom_logo) if __name__=="__main__": demo.launch()