File size: 814 Bytes
9415e6f
defebef
9415e6f
 
 
7b51b62
defebef
9415e6f
 
 
 
 
defebef
 
9415e6f
 
 
 
 
defebef
9415e6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline
from transformers import  AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("51la5/roberta-large-NER")
model = AutoModelForTokenClassification.from_pretrained("51la5/roberta-large-NER")
classifier = pipeline("ner", model=model, tokenizer=tokenizer,grouped_entities=True)

def get_ner(text):
    output = classifier(text)
    for elm in output:
        elm['entity'] = elm['entity_group']
    return {"text": text, "entities": output}


demo = gr.Interface(fn=get_ner,
                    title="Atoqli nomlarni topish(NER)",
                    inputs=gr.Textbox(lines=4, placeholder="Matinni kiriting!", label="Matn*"),
                    outputs=gr.HighlightedText(label="Natija:")
                    )

demo.launch()