jjuarez's picture
Update app.py
c1ba50f
raw
history blame contribute delete
935 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
# Loading summarization model
summarization_tokenizer = AutoTokenizer.from_pretrained("ieuniversity/sciencebrief_summarization")
summarization_model = AutoModelForSeq2SeqLM.from_pretrained("ieuniversity/sciencebrief_summarization")
def summarize(text):
input_ids = summarization_tokenizer.encode(text, return_tensors="pt")
output_ids = summarization_model.generate(input_ids)
output_text = summarization_tokenizer.decode(output_ids[0], skip_special_tokens=True)
return output_text
iface_summarize = gr.Interface(
fn=summarize,
inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
outputs=gr.outputs.Textbox(label="Summary"),
title="ScienceBrief Summarization model",
description="Get a summary of your text using the ScienceBrief summarization model.",
theme="compact"
)
iface_summarize.launch()