huckiyang's picture
fix csv
4f39516
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import csv
# Load the leaderboard data
def load_data():
df = pd.read_csv("leaderboard_results.csv", quotechar='"', escapechar='\\',
skipinitialspace=True, quoting=csv.QUOTE_MINIMAL)
return df
# Create a bar chart visualization of the accuracy scores
def create_accuracy_chart(df):
fig, ax = plt.subplots(figsize=(10, 6))
# Sort by accuracy for better visualization
df_sorted = df.sort_values(by='Test Acc', ascending=False)
# Create bar chart
bars = ax.bar(df_sorted['Solution'], df_sorted['Test Acc'], color='skyblue')
# Highlight the best performer
bars[0].set_color('gold')
# Add labels and title
ax.set_xlabel('Solution')
ax.set_ylabel('Test Accuracy')
ax.set_title('Leaderboard Results by Accuracy')
# Rotate x-axis labels for better readability
plt.xticks(rotation=45, ha='right')
# Add text labels on bars
for bar in bars:
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width()/2., height + 0.01,
f'{height:.5f}', ha='center', va='bottom')
plt.tight_layout()
return fig
# Display detailed information for a selected solution
def display_solution_details(solution_name):
df = load_data()
if solution_name:
solution_data = df[df['Solution'] == solution_name].iloc[0]
details = f"""
## {solution_data['Solution']} Details
- **Test Accuracy**: {solution_data['Test Acc']:.5f}
- **Institution**: {solution_data['Institution']}
- **Region**: {solution_data['Region']}
- **Paper**: {solution_data['Paper']}
- **Lead Author**: {solution_data['Lead Author']}
"""
return details
return "Please select a solution to see details."
# Main interface
def create_interface():
df = load_data()
with gr.Blocks(title="Emotion Recognition Leaderboard") as demo:
gr.Markdown("# Speech-based Emotion Recognition Leaderboard")
with gr.Row():
with gr.Column():
# Display the full leaderboard table
gr.DataFrame(
df.sort_values(by='Test Acc', ascending=False),
label="Leaderboard Results"
)
with gr.Row():
# Add dropdown for selecting a specific solution for more details
solution_dropdown = gr.Dropdown(
choices=df['Solution'].tolist(),
label="Select Solution for Details"
)
# Display area for solution details
solution_details = gr.Markdown()
with gr.Row():
with gr.Column():
# Display the visualization
gr.Plot(create_accuracy_chart(df))
# Update solution details when dropdown changes
solution_dropdown.change(
display_solution_details,
inputs=solution_dropdown,
outputs=solution_details
)
return demo
# Load data, create and launch the interface
if __name__ == "__main__":
demo = create_interface()
demo.launch()