Changing model
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
import spacy
|
@@ -31,8 +31,11 @@ def text_to_sentiment(text):
|
|
31 |
|
32 |
##Company Extraction
|
33 |
def ner(text):
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
#replaced_spans = [(key, None) if value=='No Disease' else (key, value) for (key, value) in spans]
|
37 |
return spans
|
38 |
|
|
|
1 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
import spacy
|
|
|
31 |
|
32 |
##Company Extraction
|
33 |
def ner(text):
|
34 |
+
tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
35 |
+
model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
36 |
+
ner = pipeline("ner", model=model, tokenizer=tokenizer)
|
37 |
+
#api = gr.Interface.load("dslim/bert-base-NER", src='models')
|
38 |
+
spans = ner(text)
|
39 |
#replaced_spans = [(key, None) if value=='No Disease' else (key, value) for (key, value) in spans]
|
40 |
return spans
|
41 |
|