Firefly777a's picture
Update app.py
a27a635
raw
history blame
No virus
816 Bytes
'''
A script that uses gradio to make a web app that takes in a dialog and outputs a summary.
Import a huggingface model.
'''
import gradio as gr
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
MODEL_NAME = "Firefly777a/bart-large-samsum-candice-set-summary-3ep-3"
# Import the model
summarizer = pipeline("summarization", model=MODEL_NAME, tokenizer=MODEL_NAME)
# tokenizer = AutoTokenizer.from_pretrained(PRETRAIN_MODEL_NAME)
# Define the function that will be used by the web app
def summarize_dialog(dialog):
# Summarize the dialog
summary = summarizer(dialog, max_length=50, min_length=10, do_sample=False)
# Return the summary
return summary[0]['summary_text']
# Define the web app & launch
gr.Interface(fn=summarize_dialog, inputs="text", outputs="text").launch()