note-ner-demo / app.py
andrewgleave's picture
Add initial stub
bdf7636
raw
history blame
599 Bytes
import json
import gradio as gr
def ner(text):
api = gr.Interface.load("d4data/biomedical-ner-all", src="models")
output = api(text)
replaced_spans = [
(key, None) if value == "No Disease" else (key, value) for (key, value) in spans
]
return replaced_spans
EXAMPLE_TEXTS = []
with open("examples.json", "r") as f:
example_json = json.load(f)
EXAMPLE_TEXTS = [x["text"] for x in example_json]
interface = gr.Interface(
ner,
inputs=gr.Textbox(label="Input", value=""),
outputs="highlightedtext",
examples=EXAMPLE_TEXTS,
)
interface.launch()