NER-Deneme / app.py
firatkazak's picture
Upload app.py
5b25403 verified
raw
history blame contribute delete
643 Bytes
from transformers import pipeline
import os
import gradio as gr
os.environ["HF_HUB_DISABLE_SYMLINKS_WARNING"] = "1"
ner_pipeline = pipeline(task="ner", model="Tirendaz/roberta-base-NER", framework="pt")
def ner(text):
output = ner_pipeline(text, aggregation_strategy="simple")
return {"text": text, "entities": output}
examples = \
[
"My name is Tim and I live in California",
"Ich arbeite bei Google in Berlin",
"Ali, Ankara'lı mı?"
]
demo = (gr.Interface(ner, gr.Textbox(placeholder="Enter sentence here..."), gr.Highlightedtext(), examples))
demo.launch(share=True)