j-tobias commited on
Commit
4c0593e
·
1 Parent(s): 61ba593

Results visualisation

Browse files
Files changed (1) hide show
  1. app.py +49 -33
app.py CHANGED
@@ -1,7 +1,9 @@
1
- import gradio as gr # needs to be installed
2
  from dataset import Dataset
3
  from model import Model
4
  from utils import compute_wer
 
 
5
 
6
  # from utils import hf_login
7
  # hf_login()
@@ -12,11 +14,9 @@ import os
12
  hf_token = os.getenv("HF_Token")
13
  login(hf_token)
14
 
15
-
16
  dataset = Dataset()
17
  models = Model()
18
 
19
-
20
  def run_tests (dataset_choice:str, model:str):
21
 
22
  MoDeL = Model()
@@ -28,21 +28,46 @@ def run_tests (dataset_choice:str, model:str):
28
  wer = compute_wer(references=references, predictions=predictions)
29
  return wer
30
 
31
-
32
  def eval(data_subset:str, model_1:str, model_2:str)->str:
33
 
34
  wer_result_1 = run_tests(data_subset, model_1)
35
  wer_result_2 = run_tests(data_subset, model_2)
36
 
37
- return f"WER Score: {wer_result_1}", f"WER Score: {wer_result_2}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  def get_card(selected_model:str)->str:
40
 
 
41
  with open("cards.txt", "r") as f:
42
  cards = f.read()
 
 
43
 
44
  cards = cards.split("@@")
45
  for card in cards:
 
46
  if "ID: "+selected_model in card:
47
  return card
48
 
@@ -60,9 +85,21 @@ def is_own(data_subset:str):
60
  with gr.Blocks() as demo:
61
 
62
 
63
- gr.Markdown('# <p style="text-align: center;">VocalVenturer 💬</p>')
64
  gr.Markdown("-------")
65
- gr.Markdown("""#### Hello there, this is the VocalVenturer, this app is aimed at helping you making more informed model choices for ASR. Please choose a Data Subset to evalutate the Models on. You also have the opportunity to record and transcibe an own sample. The Models will be evaluated using the *WER* metric -> here is an amazing Leaderboard for it LINK""")
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  with gr.Row():
68
  with gr.Column(scale=1):
@@ -79,7 +116,6 @@ with gr.Blocks() as demo:
79
  with gr.Row():
80
  own_audio = gr.Audio(sources=['microphone'],streaming=False,visible=False)
81
  own_transcription = gr.TextArea(lines=2, visible=False)
82
-
83
  data_subset.change(is_own, inputs=[data_subset], outputs=[own_audio, own_transcription])
84
 
85
 
@@ -99,39 +135,19 @@ with gr.Blocks() as demo:
99
  )
100
  model_2_card = gr.Markdown("")
101
 
102
- # with gr.Column(scale=1):
103
- # model_3 = gr.Dropdown(
104
- # choices=models.get_options(),
105
- # label="Select Model"
106
- # )
107
- # model_3_card = gr.Markdown("")
108
 
109
  model_1.change(get_card, inputs=model_1, outputs=model_1_card)
110
  model_2.change(get_card, inputs=model_2, outputs=model_2_card)
111
- # model_3.change(get_card, inputs=model_3, outputs=model_3_card)
112
 
113
  eval_btn = gr.Button(
114
  value="Evaluate",
115
  variant="primary",
116
- size="sm"
117
- )
118
-
119
-
120
 
121
  gr.Markdown('## <p style="text-align: center;">Results</p>')
122
- gr.Markdown("-------")
123
-
124
-
125
- with gr.Row():
126
-
127
- with gr.Column(scale=1):
128
- results_model_1 = gr.Markdown("")
129
-
130
- with gr.Column(scale=1):
131
- results_model_2 = gr.Markdown("")
132
-
133
- eval_btn.click(eval, [data_subset, model_1, model_2], [results_model_1, results_model_2])
134
-
135
-
136
 
137
  demo.launch(debug=True)
 
1
+ import gradio as gr
2
  from dataset import Dataset
3
  from model import Model
4
  from utils import compute_wer
5
+ import plotly.graph_objs as go
6
+
7
 
8
  # from utils import hf_login
9
  # hf_login()
 
14
  hf_token = os.getenv("HF_Token")
15
  login(hf_token)
16
 
 
17
  dataset = Dataset()
18
  models = Model()
19
 
 
20
  def run_tests (dataset_choice:str, model:str):
21
 
22
  MoDeL = Model()
 
28
  wer = compute_wer(references=references, predictions=predictions)
29
  return wer
30
 
 
31
  def eval(data_subset:str, model_1:str, model_2:str)->str:
32
 
33
  wer_result_1 = run_tests(data_subset, model_1)
34
  wer_result_2 = run_tests(data_subset, model_2)
35
 
36
+ results_md = f"""#### {model_1}
37
+ - WER Score: {wer_result_1}
38
+
39
+ #### {model_2}
40
+ - WER Score: {wer_result_2}"""
41
+
42
+ # Create the bar plot
43
+ fig = go.Figure(
44
+ data=[
45
+ go.Bar(x=[f"{model_1}"], y=[wer_result_1]),
46
+ go.Bar(x=[f"{model_2}"], y=[wer_result_2]),
47
+ ]
48
+ )
49
+
50
+ # Update the layout for better visualization
51
+ fig.update_layout(
52
+ title="Comparison of Two Models",
53
+ xaxis_title="Models",
54
+ yaxis_title="Value",
55
+ barmode="group",
56
+ )
57
+
58
+ return results_md, fig
59
 
60
  def get_card(selected_model:str)->str:
61
 
62
+ print("Selected Model for Card: ", selected_model)
63
  with open("cards.txt", "r") as f:
64
  cards = f.read()
65
+
66
+ print(cards)
67
 
68
  cards = cards.split("@@")
69
  for card in cards:
70
+ print("CARD: ", card)
71
  if "ID: "+selected_model in card:
72
  return card
73
 
 
85
  with gr.Blocks() as demo:
86
 
87
 
88
+ gr.Markdown('# <p style="text-align: center;">ASR Model Comparison 💬</p>')
89
  gr.Markdown("-------")
90
+
91
+
92
+ gr.Markdown("""### Welcome to ASR Model Comparison Hub! 🎉
93
+
94
+ Hey there, and welcome to an app designed just for developers like you, who are passionate about pushing the boundaries of Automatic Speech Recognition (ASR) technology!
95
+
96
+ Here, you can easily compare different ASR models by selecting a dataset and choosing two models from the dropdown to see how they stack up against each other. If you're feeling creative, go ahead and select 'OWN' as your dataset option to upload your own audio file or record something new right in the app. Don’t forget to provide a transcription, and the app will handle the rest!
97
+
98
+ ASR Model Comparison Hub uses the Word Error Rate (WER) ⬇️ (the lower the better) metric to give you a clear picture of each model's performance. And hey, don't miss out on checking the **Amazing Leaderboard** where you can see how a wide range of models have been evaluated—[Check it out here](https://huggingface.co/spaces/hf-audio/open_asr_leaderboard).
99
+
100
+ Happy experimenting and comparing! 🚀""")
101
+
102
+
103
 
104
  with gr.Row():
105
  with gr.Column(scale=1):
 
116
  with gr.Row():
117
  own_audio = gr.Audio(sources=['microphone'],streaming=False,visible=False)
118
  own_transcription = gr.TextArea(lines=2, visible=False)
 
119
  data_subset.change(is_own, inputs=[data_subset], outputs=[own_audio, own_transcription])
120
 
121
 
 
135
  )
136
  model_2_card = gr.Markdown("")
137
 
 
 
 
 
 
 
138
 
139
  model_1.change(get_card, inputs=model_1, outputs=model_1_card)
140
  model_2.change(get_card, inputs=model_2, outputs=model_2_card)
141
+
142
 
143
  eval_btn = gr.Button(
144
  value="Evaluate",
145
  variant="primary",
146
+ size="sm")
 
 
 
147
 
148
  gr.Markdown('## <p style="text-align: center;">Results</p>')
149
+ results_md = gr.Markdown("")
150
+ results_plot = gr.Plot(show_label=False)
151
+ eval_btn.click(eval, [data_subset, model_1, model_2], [results_md, results_plot])
 
 
 
 
 
 
 
 
 
 
 
152
 
153
  demo.launch(debug=True)