Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
import pandas as pd
|
4 |
-
from evaluate import
|
5 |
-
from evaluate.visualization import radar_plot
|
6 |
|
7 |
-
#
|
8 |
scores = {
|
9 |
-
"Model A": [4.0, 4.5, 3.5, 4.0],
|
10 |
"Model B": [3.5, 4.0, 4.0, 3.5]
|
11 |
}
|
12 |
labels = ["Generalization", "Relevance", "Artistry", "Efficiency"]
|
13 |
df = pd.DataFrame(scores, index=labels).T
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
with gr.Blocks() as demo:
|
16 |
-
gr.Markdown("##
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import pandas as pd
|
3 |
+
from evaluate.visualization import radar_plot # 正确模块
|
|
|
4 |
|
5 |
+
# 模拟的评分数据
|
6 |
scores = {
|
7 |
+
"Model A": [4.0, 4.5, 3.5, 4.0],
|
8 |
"Model B": [3.5, 4.0, 4.0, 3.5]
|
9 |
}
|
10 |
labels = ["Generalization", "Relevance", "Artistry", "Efficiency"]
|
11 |
df = pd.DataFrame(scores, index=labels).T
|
12 |
|
13 |
+
# 图表绘制函数
|
14 |
+
def plot_radar():
|
15 |
+
data = []
|
16 |
+
for model in df.index:
|
17 |
+
data.append({label: df.loc[model, label] for label in df.columns})
|
18 |
+
fig = radar_plot(data=data, model_names=list(df.index), title="GRACE 评估维度雷达图")
|
19 |
+
return fig
|
20 |
+
|
21 |
+
# Gradio 界面构建
|
22 |
with gr.Blocks() as demo:
|
23 |
+
gr.Markdown("## ✨ 模型 GRACE 维度雷达图")
|
24 |
+
with gr.Row():
|
25 |
+
generate_button = gr.Button("生成图表")
|
26 |
+
output_plot = gr.Plot()
|
27 |
+
generate_button.click(fn=plot_radar, inputs=[], outputs=output_plot)
|
28 |
+
|
29 |
demo.launch()
|