Bekhouche commited on
Commit
47a7d13
·
verified ·
1 Parent(s): 51361fe

Fix Gradio widget to support newer version

Browse files
Files changed (1) hide show
  1. app.py +37 -3
app.py CHANGED
@@ -1,6 +1,40 @@
1
  import evaluate
2
- from evaluate.utils import launch_gradio_widget
3
-
4
 
5
  module = evaluate.load("Bekhouche/NED")
6
- launch_gradio_widget(module)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import evaluate
2
+ import gradio as gr
 
3
 
4
  module = evaluate.load("Bekhouche/NED")
5
+
6
+ def compute_ned(dataframe):
7
+ predictions = dataframe['Predictions'].tolist()
8
+ references = dataframe['References'].tolist()
9
+ if len(predictions) != len(references):
10
+ return "Error: Number of predictions and references must match!"
11
+ module.add_batch(predictions=predictions, references=references)
12
+ result = module.compute()
13
+ return result
14
+
15
+ def custom_launch_gradio_widget(module):
16
+ metric_info = module._info()
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown(f"### {metric_info.description}")
20
+ gr.Markdown(f"**Citation:** {metric_info.citation}")
21
+ gr.Markdown(f"**Inputs Description:** {metric_info.inputs_description}")
22
+
23
+ input_data = gr.Dataframe(
24
+ headers=["Predictions", "References"],
25
+ row_count=1,
26
+ label="Input Predictions and References"
27
+ )
28
+
29
+ run_button = gr.Button("Run NED")
30
+ output = gr.Textbox(label="NED Score")
31
+
32
+ run_button.click(
33
+ compute_ned,
34
+ inputs=input_data,
35
+ outputs=output,
36
+ )
37
+
38
+ demo.launch()
39
+
40
+ custom_launch_gradio_widget(module)