File size: 1,012 Bytes
dfe37be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import pandas as pd
import plotly.express as px


def plot_csv(df):
    # 将第一列作为索引
    df.set_index('Model', inplace=True)

    # 转置数据框,使得模型作为列,横轴作为行
    df_transposed = df.T

    # 使用plotly绘制折线图
    fig = px.line(df_transposed, x=df_transposed.index, y=df_transposed.columns,
                  title='Model Evaluation Results',
                  labels={'value': 'Evaluation Score', 'index': 'Evaluation Metric'},
                  color_discrete_sequence=px.colors.qualitative.Plotly)

    # 设置悬停效果
    fig.update_traces(hovertemplate='%{y}')

    return fig


# 读取本地的CSV文件
file_path = 'line_counts_QS.csv'
df = pd.read_csv(file_path)


iface = gr.Interface(
    fn=plot_csv,
    inputs=gr.Dataframe(df),
    outputs=gr.Plot(label="Line Plot"),
    title="CSV to Line Plot",
    description="Visualize the evaluation results as a line plot."
)

iface.launch()