maqiuping59 commited on
Commit
3baca8d
·
verified ·
1 Parent(s): 6ee5ac2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -3
app.py CHANGED
@@ -1,6 +1,37 @@
1
  import evaluate
2
- from evaluate.utils import launch_gradio_widget
 
3
 
4
 
5
- module = evaluate.load("maqiuping59/table_markdown")
6
- launch_gradio_widget(module)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import evaluate
2
+ import gradio as gr
3
+ import os
4
 
5
 
6
+ current_dir = os.path.dirname(os.path.abspath(__file__))
7
+
8
+
9
+ module = evaluate.load(current_dir)
10
+
11
+ def compute_metrics(predictions, references):
12
+ results = module.compute(predictions=predictions, references=references)
13
+ return results
14
+
15
+ # 创建界面
16
+ demo = gr.Interface(
17
+ fn=compute_metrics,
18
+ inputs=[
19
+ gr.Textbox(label="Predictions (Markdown Table)", lines=10),
20
+ gr.Textbox(label="References (Markdown Table)", lines=10)
21
+ ],
22
+ outputs=gr.JSON(label="Results"),
23
+ title="Table Markdown Metrics",
24
+ description="Evaluate the accuracy of table data extraction or generation by comparing predicted tables with reference tables.",
25
+ examples=[
26
+ [
27
+ "|A|B|\n|1|2|",
28
+ "|A|B|\n|1|3|"
29
+ ],
30
+ [
31
+ "| | lobby | search | band |\n|--|-------|--------|------|\n| desire | 5 | 8 | 7 |\n| wage | 1 | 5 | 3 |",
32
+ "| | lobby | search | band |\n|--|-------|--------|------|\n| desire | 5 | 8 | 7 |\n| wage | 1 | 5 | 3 |"
33
+ ]
34
+ ]
35
+ )
36
+
37
+ demo.launch()