SeyedAli commited on
Commit
4c7eeb3
1 Parent(s): a8f7745

Create app.txt

Browse files
Files changed (1) hide show
  1. app.txt +13 -0
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)