sasha's picture
sasha HF staff
ok let's do like this
7e00f76
raw
history blame
4.4 kB
import gradio as gr
import pandas as pd
from huggingface_hub import list_models
import plotly.express as px
def get_plots(task):
#TO DO : hover text with energy efficiency number, parameters
task_df= pd.read_csv('data/energy/'+task)
params_df = pd.read_csv('data/params/'+task)
params_df= params_df.rename(columns={"Link": "model"})
all_df = pd.merge(task_df, params_df, on='model')
all_df['Total GPU Energy (Wh)'] = all_df['total_gpu_energy']*1000
all_df = all_df.sort_values(by=['Total GPU Energy (Wh)'])
all_df['energy_star'] = pd.cut(all_df['Total GPU Energy (Wh)'], 3, labels=["⭐⭐⭐", "⭐⭐", "⭐"])
fig = px.scatter(all_df, x="model", y='Total GPU Energy (Wh)', custom_data=['parameters'], height= 500, width= 800, color = 'energy_star', color_discrete_map={"⭐": 'red', "⭐⭐": "yellow", "⭐⭐⭐": "green"})
fig.update_traces(
hovertemplate="<br>".join([
"Total Energy: %{y}",
"Parameters: %{customdata[0]}"])
)
return fig
def get_model_names(task_data):
#TODO: add link to results in model card of each model
task_df= pd.read_csv('data/energy/'+task_data)
task_df=task_df.drop_duplicates(subset=['model'])
model_names = task_df[['model']]
return model_names
demo = gr.Blocks()
with demo:
gr.Markdown(
"""# Energy Star Leaderboard
TODO """
)
with gr.Tabs():
with gr.TabItem("Text Generation πŸ’¬"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('text_generation.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('text_generation.csv'))
with gr.TabItem("Image Generation πŸ“·"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('image_generation.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('image_generation.csv'))
with gr.TabItem("Text Classification 🎭"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('text_classification.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('text_classification.csv'))
with gr.TabItem("Image Classification πŸ–ΌοΈ"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('image_classification.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('image_classification.csv'))
with gr.TabItem("Image Captioning πŸ“"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('question_answering.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('question_answering.csv'))
with gr.TabItem("Summarization πŸ“ƒ"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('summarization.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('summarization.csv'))
with gr.TabItem("Automatic Speech Recognition πŸ’¬ "):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('asr.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('asr.csv'))
with gr.TabItem("Object Detection 🚘"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('object_detection.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('object_detection.csv'))
with gr.TabItem("Sentence Similarity πŸ“š"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('sentence_similarity.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('sentence_similarity.csv'))
with gr.TabItem("Extractive QA ❔"):
with gr.Row():
with gr.Column():
plot = gr.Plot(get_plots('question_answering.csv'))
with gr.Column():
table = gr.Dataframe(get_model_names('question_answering.csv'))
demo.launch()