Spaces:
Runtime error
Runtime error
Create app.txt
Browse files
app.txt
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import AutoModelForTokenClassification,AutoTokenizer,pipeline
|
3 |
+
|
4 |
+
model = AutoModelForTokenClassification.from_pretrained('HooshvareLab/bert-fa-base-uncased')
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained('HooshvareLab/bert-fa-base-uncased')
|
6 |
+
|
7 |
+
def NER(text):
|
8 |
+
pipline = pipeline(task="token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
9 |
+
output=pipline(text)
|
10 |
+
return output
|
11 |
+
|
12 |
+
iface = gr.Interface(fn=NER, inputs="text", outputs="text")
|
13 |
+
iface.launch(share=False)
|