changed app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,30 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
logger.error("To create a metric widget with Gradio make sure gradio is installed.")
|
5 |
-
raise error
|
6 |
|
7 |
-
# if there are several input types, use first as default.
|
8 |
-
# if isinstance(metric.features, list):
|
9 |
-
# (feature_names, feature_types) = zip(*metric.features[0].items())
|
10 |
-
# else:
|
11 |
-
# (feature_names, feature_types) = zip(*metric.features.items())
|
12 |
-
# gradio_input_types = infer_gradio_input_types(feature_types)
|
13 |
|
14 |
-
def compute(
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
iface = gr.Interface(
|
18 |
-
fn=compute,
|
19 |
-
inputs=gr.inputs.Dataframe(
|
20 |
-
headers=feature_names,
|
21 |
-
col_count=len(feature_names),
|
22 |
-
row_count=1,
|
23 |
-
datatype=json_to_string_type(gradio_input_types),
|
24 |
-
),
|
25 |
-
outputs=gr.outputs.Textbox(label=metric.name),
|
26 |
-
description=(
|
27 |
-
metric.info.description + "\nIf this is a text-based metric, make sure to wrap you input in double quotes."
|
28 |
-
" Alternatively you can use a JSON-formatted list as input."
|
29 |
-
),
|
30 |
-
title=f"Metric: {metric.name}",
|
31 |
-
# article=parse_readme(local_path / "README.md"),
|
32 |
-
)
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from jiwer import wer
|
|
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
def compute(input):
|
7 |
+
preds = input['prediction'].tolist()
|
8 |
+
truths = input['truth'].tolist()
|
9 |
+
print(truths, preds, type(truths))
|
10 |
+
err = wer(truths, preds)
|
11 |
+
print(err)
|
12 |
+
return err
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=compute,
|
17 |
+
inputs=gr.components.Dataframe(
|
18 |
+
headers=["truth", "prediction"],
|
19 |
+
col_count=2,
|
20 |
+
row_count=1,
|
21 |
+
label="Input"
|
22 |
+
),
|
23 |
+
outputs=gr.components.Textbox(label="WER"),
|
24 |
+
description=(
|
25 |
+
"This is a calculator that you can use to find WER"
|
26 |
+
),
|
27 |
+
title="WER Calculator",
|
28 |
+
)
|
29 |
+
|
30 |
+
demo.launch()
|