multiner_demo / app.py
PaulNdrei's picture
Adapt code to use gr.Interface
292db1c
raw
history blame
680 Bytes
import gradio as gr
from AinaTheme import AinaGradioTheme
from transformers import pipeline
# gr.load("projecte-aina/multiner_ceil",src="models",aggregation_strategy="first", **AinaGradioTheme().get_kwargs()).launch()
import gradio as gr
ner_pipeline = pipeline("token-classification", model="projecte-aina/multiner_ceil")
# examples = [
# "Does Chicago have any stores and does Joe live here?",
# ]
def ner(text):
output = ner_pipeline(text)
return {"text": text, "entities": output}
demo = gr.Interface(ner,
gr.Textbox(placeholder="Enter sentence here..."),
gr.HighlightedText(), **AinaGradioTheme().get_kwargs())
demo.launch()