Spaces:
Sleeping
Sleeping
File size: 1,218 Bytes
be95b82 ba37341 be95b82 ba37341 be95b82 ba37341 db16d10 ba37341 5f6c6c9 ba37341 dde29c3 ba37341 be95b82 44b7d5d ba37341 44b7d5d ba37341 44b7d5d 8371819 44b7d5d ba37341 be95b82 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from transformers import pipeline
import gradio as gr
# text summarizer
summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
def get_summary(text):
output = summarizer(text)
return output[0]["summary_text"]
# named entity recognition
ner_model = pipeline("ner", model = "dslim/bert-large-NER")
def get_ner(text):
output = ner_model(text)
return {"text":text, "entities":output}
demo = gr.Blocks()
with demo:
gr.Markdown("# Try out some cool tasks!")
with gr.Tab("Text Summarizer"):
sum_input = [gr.Textbox(label="Text to Summarize", placeholder="Enter text to summarize...", lines=4)]
sum_output = [gr.Textbox(label="Summarized Text")]
sum_btn = gr.Button("Summarize text")
sum_btn.click(get_summary, sum_input, sum_output)
with gr.Tab("Named Entity Recognition"):
ner_input = [gr.Textbox(label="Text to find Entities", placeholder = "Enter text...", lines = 4)]
# ner_output = gr.Textbox()
ner_output = [gr.HighlightedText(label="Text with entities")]
allow_flagging = "never"
ner_btn = gr.Button("Generate entities")
ner_btn.click(get_ner, ner_input, ner_output)
demo.launch() |