None1145's picture
Update app.py
811f643 verified
raw
history blame
2 kB
import pandas as pd
import gradio as gr
def compare_csv_files():
df1 = pd.read_csv("fish-speech-1.5.csv")
df2 = pd.read_csv("fish-speech-1.4.csv")
merged_df = pd.merge(df1, df2, on="SourceText", suffixes=("_1.5", "_1.4"))
merged_df["WordErrorRate_Diff"] = merged_df["WordErrorRate_1.5"] - merged_df["WordErrorRate_1.4"]
merged_df["CharacterErrorRate_Diff"] = merged_df["CharacterErrorRate_1.5"] - merged_df["CharacterErrorRate_1.4"]
merged_df["WordErrorRate_Comparison"] = merged_df["WordErrorRate_Diff"].apply(
lambda x: f"1.5 is stronger than 1.4 ({x:.8f})" if x > 0 else (
f"1.4 is stronger than 1.5 ({-x:.8f})" if x < 0 else "1.4 is the same as 1.5 (0)"
)
)
merged_df["CharacterErrorRate_Comparison"] = merged_df["CharacterErrorRate_Diff"].apply(
lambda x: f"1.5 is stronger than 1.4 ({x:.8f})" if x > 0 else (
f"1.4 is stronger than 1.5 ({-x:.8f})" if x < 0 else "1.4 is the same as 1.5 (0)"
)
)
def overall_comparison(row):
word_diff = row["WordErrorRate_Diff"]
char_diff = row["CharacterErrorRate_Diff"]
if word_diff > 0 and char_diff > 0:
return "1.5 is overall stronger than 1.4"
elif word_diff < 0 and char_diff < 0:
return "1.4 is overall stronger than 1.5"
elif word_diff == 0 and char_diff == 0:
return "1.4 is the same as 1.5 overall"
else:
return "Mixed results: check individual metrics"
merged_df["Overall_Comparison"] = merged_df.apply(overall_comparison, axis=1)
result = merged_df[[
"SourceText",
"WordErrorRate_1.5", "WordErrorRate_1.4", "WordErrorRate_Comparison",
"CharacterErrorRate_1.5", "CharacterErrorRate_1.4", "CharacterErrorRate_Comparison",
"Overall_Comparison"
]]
return result.to_html(index=False)
gr.Interface(
fn=compare_csv_files,
inputs=None,
outputs="html"
).launch()