ai-lab-macree commited on
Commit
c52380d
1 Parent(s): e027a6c

Add application file

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ A script that uses gradio to make a web app that takes in a dialog and outputs a summary.
3
+ Import a huggingface model.
4
+ '''
5
+
6
+ import gradio as gr
7
+ from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
8
+
9
+ MODEL_NAME = "Firefly777a/bart-large-samsum-candice-set-summary-3ep-3"
10
+
11
+ # Import the model
12
+ summarizer = pipeline("summarization", model=MODEL_NAME, tokenizer=MODEL_NAME)
13
+ # tokenizer = AutoTokenizer.from_pretrained(PRETRAIN_MODEL_NAME)
14
+
15
+ # Define the function that will be used by the web app
16
+ def summarize_dialog(dialog):
17
+ # Summarize the dialog
18
+ summary = summarizer(dialog, max_length=50, min_length=10, do_sample=False)
19
+ # Return the summary
20
+ return summary[0]['summary_text']
21
+
22
+ # Define the web app & launch
23
+ gr.Interface(fn=summarize_dialog, inputs="text", outputs="text").launch()