Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
from litie.pipelines import EventExtractionPipeline
|
6 |
+
|
7 |
+
pipeline = EventExtractionPipeline(task_model_name="gplinker", model_name_or_path="xusenlin/duee-gplinker")
|
8 |
+
|
9 |
+
|
10 |
+
def extract(text):
|
11 |
+
start = time.time()
|
12 |
+
res = pipeline(text)
|
13 |
+
running_time = time.time() - start
|
14 |
+
|
15 |
+
return running_time, res
|
16 |
+
|
17 |
+
|
18 |
+
demo = gr.Interface(
|
19 |
+
extract,
|
20 |
+
[
|
21 |
+
gr.Textbox(
|
22 |
+
placeholder="Enter sentence here...",
|
23 |
+
lines=5
|
24 |
+
),
|
25 |
+
],
|
26 |
+
[gr.Number(label="Run Time"), gr.Json(label="Result")],
|
27 |
+
examples=[
|
28 |
+
["油服巨头哈里伯顿裁员650人 因美国油气开采活动放缓"],
|
29 |
+
],
|
30 |
+
title="Event Extraction Demo",
|
31 |
+
)
|
32 |
+
|
33 |
+
demo.launch()
|