NERBERT / app.py
sd99's picture
Created app.py
1d685e8
raw
history blame
701 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
description = "Named Entity Recognition Using BERT"
title = "NERBERT"
examples = [["Hey, Alex here from London!"], ["My name is Wolfgang and I live in Berlin"]]
def findNER(example):
tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
return ner_pipeline(example)
interface = gr.Interface(fn=findNER, inputs='text', outputs='text', examples=examples, description=description, title=title)
interface.launch()