Spaces:
Runtime error
Runtime error
File size: 815 Bytes
c52380d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
'''
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() |