Commit
·
d9c1e0e
1
Parent(s):
86a4cd6
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from dataclasses import dataclass
|
| 3 |
|
| 4 |
-
from pytorch_ie import
|
| 5 |
-
from pytorch_ie.
|
| 6 |
-
from pytorch_ie.
|
|
|
|
|
|
|
| 7 |
from spacy import displacy
|
| 8 |
|
| 9 |
|
|
@@ -13,10 +15,8 @@ class ExampleDocument(TextDocument):
|
|
| 13 |
|
| 14 |
|
| 15 |
model_name_or_path = "pie/example-ner-spanclf-conll03"
|
| 16 |
-
ner_taskmodule = TransformerSpanClassificationTaskModule.from_pretrained(model_name_or_path)
|
| 17 |
-
ner_model = TransformerSpanClassificationModel.from_pretrained(model_name_or_path)
|
| 18 |
|
| 19 |
-
ner_pipeline =
|
| 20 |
|
| 21 |
|
| 22 |
def predict(text):
|
|
@@ -44,5 +44,12 @@ def predict(text):
|
|
| 44 |
return html
|
| 45 |
|
| 46 |
|
| 47 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from dataclasses import dataclass
|
| 3 |
|
| 4 |
+
from pytorch_ie.annotations import LabeledSpan
|
| 5 |
+
from pytorch_ie.auto import AutoPipeline
|
| 6 |
+
from pytorch_ie.core import AnnotationList, annotation_field
|
| 7 |
+
from pytorch_ie.documents import TextDocument
|
| 8 |
+
|
| 9 |
from spacy import displacy
|
| 10 |
|
| 11 |
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
model_name_or_path = "pie/example-ner-spanclf-conll03"
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
ner_pipeline = AutoPipeline.from_pretrained(model_name_or_path, device=-1, num_workers=0)
|
| 20 |
|
| 21 |
|
| 22 |
def predict(text):
|
|
|
|
| 44 |
return html
|
| 45 |
|
| 46 |
|
| 47 |
+
iface = gr.Interface(
|
| 48 |
+
fn=predict,
|
| 49 |
+
inputs=gr.inputs.Textbox(
|
| 50 |
+
lines=5,
|
| 51 |
+
default="There is still some uncertainty that Musk - also chief executive of electric car maker Tesla and rocket company SpaceX - will pull off his planned buyout.",
|
| 52 |
+
),
|
| 53 |
+
outputs="html",
|
| 54 |
+
)
|
| 55 |
iface.launch()
|