Spaces:
Sleeping
Sleeping
File size: 6,533 Bytes
7ffe939 c15eee2 7ffe939 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7c3776d c15eee2 7ffe939 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
import gradio as gr
import plotly.graph_objects as go
import numpy as np
import pandas as pd
def create_sota_plot(df):
"""
Create a plot showing model performance evolution over time.
Parameters:
df: DataFrame with columns ['model_name', 'release_date', 'score']
"""
# Sort by release date to ensure chronological order
df_sorted = df.sort_values('release_date').copy()
# Calculate cumulative best (SOTA) for each point
df_sorted['cumulative_best'] = df_sorted['score'].cummax()
# Identify which models are SOTA (where score equals cumulative best)
df_sorted['is_sota'] = df_sorted['score'] == df_sorted['cumulative_best']
# Get SOTA models for the line
sota_df = df_sorted[df_sorted['is_sota']].copy()
# Create the plot
fig = go.Figure()
# Add all models as scatter points (gray for non-SOTA, cyan for SOTA)
fig.add_trace(go.Scatter(
x=df_sorted['release_date'],
y=df_sorted['score'],
mode='markers',
name='All models',
marker=dict(
color=['#00CED1' if is_sota else 'lightgray'
for is_sota in df_sorted['is_sota']],
size=8,
opacity=0.7
),
text=df_sorted['model_name'],
hovertemplate='<b>%{text}</b><br>Date: %{x}<br>Score: %{y:.2f}%<extra></extra>'
))
# Add SOTA line (cumulative best)
fig.add_trace(go.Scatter(
x=df_sorted['release_date'],
y=df_sorted['cumulative_best'],
mode='lines',
name='State-of-the-art (cumulative best)',
line=dict(color='#00CED1', width=2, dash='solid'),
hovertemplate='SOTA Score: %{y:.2f}%<br>Date: %{x}<extra></extra>'
))
# Add labels for SOTA models (models that improved the best score)
for _, row in sota_df.iterrows():
fig.add_annotation(
x=row['release_date'],
y=row['score'],
text=row['model_name'],
showarrow=True,
arrowhead=2,
arrowsize=1,
arrowwidth=1,
arrowcolor='gray',
ax=0,
ay=-30,
font=dict(size=10)
)
# Update layout
fig.update_layout(
title='Evolution of Model Performance Over Time',
xaxis_title='Release Date',
yaxis_title='Score (%)',
xaxis=dict(
showgrid=True,
gridcolor='lightgray'
),
yaxis=dict(
showgrid=True,
gridcolor='lightgray'
),
plot_bgcolor='white',
paper_bgcolor='white',
height=600,
legend=dict(
yanchor="top",
y=0.99,
xanchor="left",
x=0.01
),
hovermode='closest'
)
return fig
def create_sample_dataframe():
"""
Create a sample DataFrame with model performance data.
"""
# Create sample data
data = {
'model_name': [
'SIFT + FVs', 'AlexNet', 'VGG-16', 'GoogLeNet', 'ResNet-50',
'SPPNet', 'Inception V2', 'Inception V3', 'ResNet-152', 'DenseNet',
'MobileNet', 'NASNET-A(6)', 'EfficientNet', 'Vision Transformer',
'CoAtNet-7', 'CLIP', 'DALL-E', 'GPT-Vision', 'Model-X', 'Model-Y',
# Add some models that don't improve SOTA
'SmallNet-1', 'SmallNet-2', 'BasicCNN', 'SimpleDNN', 'QuickNet',
'FastNet', 'LiteModel', 'CompactNet', 'MiniVGG', 'TinyResNet'
],
'release_date': pd.to_datetime([
'2012-01-15', '2012-09-30', '2014-04-10', '2014-09-17', '2015-12-10',
'2014-06-18', '2015-02-11', '2015-12-02', '2016-05-11', '2016-08-25',
'2017-04-17', '2017-11-04', '2019-05-28', '2020-10-22',
'2021-06-09', '2021-01-05', '2021-01-05', '2022-03-14', '2022-07-20', '2022-11-15',
# Dates for non-SOTA models
'2013-03-10', '2013-07-22', '2014-01-15', '2015-03-20', '2016-02-14',
'2017-06-30', '2018-09-12', '2019-02-28', '2020-04-15', '2021-08-30'
]),
'score': [
53.0, 65.0, 71.5, 74.8, 76.0,
74.0, 78.0, 81.0, 77.8, 79.2,
70.6, 82.7, 84.3, 85.2,
90.88, 86.5, 87.0, 87.79, 87.73, 88.1,
# Scores for non-SOTA models (below SOTA at their time)
58.0, 62.0, 68.0, 72.0, 73.5,
75.0, 78.5, 80.0, 82.0, 84.0
]
}
return pd.DataFrame(data)
# Create Gradio interface
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# State-of-the-Art Models Timeline with Cumulative Best")
gr.Markdown("""
This visualization shows the evolution of model performance over time.
The line represents the cumulative best (SOTA) score achieved up to each point in time.
""")
plot = gr.Plot(label="Model Performance Evolution")
# Create the main DataFrame inline
df_main = create_sample_dataframe()
# Display data info
with gr.Row():
with gr.Column():
gr.Markdown(f"**Total models in dataset:** {len(df_main)}")
gr.Markdown(f"**Date range:** {df_main['release_date'].min().date()} to {df_main['release_date'].max().date()}")
gr.Markdown(f"**Best score achieved:** {df_main['score'].max():.2f}%")
# Create plot on load
demo.load(fn=lambda: create_sota_plot(df_main), outputs=plot)
# Add interactive controls
with gr.Row():
refresh_btn = gr.Button("Refresh Plot")
show_data_btn = gr.Button("Show DataFrame")
# DataFrame display (initially hidden)
df_display = gr.Dataframe(
value=df_main,
label="Model Performance Data",
visible=False
)
refresh_btn.click(fn=lambda: create_sota_plot(df_main), outputs=plot)
def toggle_dataframe(current_df):
return gr.Dataframe(value=current_df, visible=True)
show_data_btn.click(
fn=lambda: toggle_dataframe(df_main),
outputs=df_display
)
gr.Markdown("""
### About this visualization:
- **Cyan line**: Cumulative best (SOTA) score over time - shows the highest score achieved up to each date
- **Cyan dots**: Models that achieved a new SOTA when released
- **Gray dots**: Other models that didn't beat the existing SOTA
- **Hover over points**: See model names, release dates, and scores
- The SOTA line only increases or stays flat, never decreases (cumulative maximum)
""")
demo.launch() |