None1145 commited on
Commit
811f643
·
verified ·
1 Parent(s): c7750c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -12
app.py CHANGED
@@ -2,36 +2,50 @@ import pandas as pd
2
  import gradio as gr
3
 
4
  def compare_csv_files():
5
- file1 = "fish-speech-1.5.csv"
6
- file2 = "fish-speech-1.4.csv"
7
-
8
- df1 = pd.read_csv(file1)
9
- df2 = pd.read_csv(file2)
10
 
11
  merged_df = pd.merge(df1, df2, on="SourceText", suffixes=("_1.5", "_1.4"))
12
-
13
  merged_df["WordErrorRate_Diff"] = merged_df["WordErrorRate_1.5"] - merged_df["WordErrorRate_1.4"]
 
 
14
  merged_df["WordErrorRate_Comparison"] = merged_df["WordErrorRate_Diff"].apply(
15
- lambda x: f"1.5 is stronger than 1.4 ({x})" if x > 0 else (
16
- f"1.4 is stronger than 1.5 ({-x})" if x < 0 else "1.4 is the same as 1.5 (0)"
17
  )
18
  )
19
 
20
- merged_df["CharacterErrorRate_Diff"] = merged_df["CharacterErrorRate_1.5"] - merged_df["CharacterErrorRate_1.4"]
21
  merged_df["CharacterErrorRate_Comparison"] = merged_df["CharacterErrorRate_Diff"].apply(
22
- lambda x: f"1.5 is stronger than 1.4 ({x})" if x > 0 else (
23
- f"1.4 is stronger than 1.5 ({-x})" if x < 0 else "1.4 is the same as 1.5 (0)"
24
  )
25
  )
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  result = merged_df[[
28
  "SourceText",
29
  "WordErrorRate_1.5", "WordErrorRate_1.4", "WordErrorRate_Comparison",
30
- "CharacterErrorRate_1.5", "CharacterErrorRate_1.4", "CharacterErrorRate_Comparison"
 
31
  ]]
32
 
33
  return result.to_html(index=False)
34
 
 
35
  gr.Interface(
36
  fn=compare_csv_files,
37
  inputs=None,
 
2
  import gradio as gr
3
 
4
  def compare_csv_files():
5
+ df1 = pd.read_csv("fish-speech-1.5.csv")
6
+ df2 = pd.read_csv("fish-speech-1.4.csv")
 
 
 
7
 
8
  merged_df = pd.merge(df1, df2, on="SourceText", suffixes=("_1.5", "_1.4"))
9
+
10
  merged_df["WordErrorRate_Diff"] = merged_df["WordErrorRate_1.5"] - merged_df["WordErrorRate_1.4"]
11
+ merged_df["CharacterErrorRate_Diff"] = merged_df["CharacterErrorRate_1.5"] - merged_df["CharacterErrorRate_1.4"]
12
+
13
  merged_df["WordErrorRate_Comparison"] = merged_df["WordErrorRate_Diff"].apply(
14
+ lambda x: f"1.5 is stronger than 1.4 ({x:.8f})" if x > 0 else (
15
+ f"1.4 is stronger than 1.5 ({-x:.8f})" if x < 0 else "1.4 is the same as 1.5 (0)"
16
  )
17
  )
18
 
 
19
  merged_df["CharacterErrorRate_Comparison"] = merged_df["CharacterErrorRate_Diff"].apply(
20
+ lambda x: f"1.5 is stronger than 1.4 ({x:.8f})" if x > 0 else (
21
+ f"1.4 is stronger than 1.5 ({-x:.8f})" if x < 0 else "1.4 is the same as 1.5 (0)"
22
  )
23
  )
24
 
25
+ def overall_comparison(row):
26
+ word_diff = row["WordErrorRate_Diff"]
27
+ char_diff = row["CharacterErrorRate_Diff"]
28
+ if word_diff > 0 and char_diff > 0:
29
+ return "1.5 is overall stronger than 1.4"
30
+ elif word_diff < 0 and char_diff < 0:
31
+ return "1.4 is overall stronger than 1.5"
32
+ elif word_diff == 0 and char_diff == 0:
33
+ return "1.4 is the same as 1.5 overall"
34
+ else:
35
+ return "Mixed results: check individual metrics"
36
+
37
+ merged_df["Overall_Comparison"] = merged_df.apply(overall_comparison, axis=1)
38
+
39
  result = merged_df[[
40
  "SourceText",
41
  "WordErrorRate_1.5", "WordErrorRate_1.4", "WordErrorRate_Comparison",
42
+ "CharacterErrorRate_1.5", "CharacterErrorRate_1.4", "CharacterErrorRate_Comparison",
43
+ "Overall_Comparison"
44
  ]]
45
 
46
  return result.to_html(index=False)
47
 
48
+
49
  gr.Interface(
50
  fn=compare_csv_files,
51
  inputs=None,