|
|
import gradio as gr |
|
|
import pandas as pd |
|
|
from evaluate.visualization import radar_plot |
|
|
|
|
|
|
|
|
scores = { |
|
|
"Model A": [4.0, 4.5, 3.5, 4.0], |
|
|
"Model B": [3.5, 4.0, 4.0, 3.5] |
|
|
} |
|
|
labels = ["Generalization", "Relevance", "Artistry", "Efficiency"] |
|
|
df = pd.DataFrame(scores, index=labels).T |
|
|
|
|
|
|
|
|
def plot_radar(): |
|
|
data = [] |
|
|
for model in df.index: |
|
|
data.append({label: df.loc[model, label] for label in df.columns}) |
|
|
fig = radar_plot(data=data, model_names=list(df.index)) |
|
|
fig.suptitle("GRACE 模型评估对比图", fontsize=14) |
|
|
return fig |
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("## ✨ 模型 GRACE 维度雷达图") |
|
|
with gr.Row(): |
|
|
generate_button = gr.Button("生成图表") |
|
|
output_plot = gr.Plot() |
|
|
generate_button.click(fn=plot_radar, inputs=[], outputs=output_plot) |
|
|
|
|
|
demo.launch() |