DanielCL commited on
Commit
4b5f72d
·
1 Parent(s): f12d42f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import libraries
2
+ import gradio as gr
3
+ import torch
4
+ import transformers
5
+ from transformers import pipeline
6
+
7
+ # define summarizer function
8
+ def summarizer(text):
9
+ summarizer = pipeline("summarization")
10
+ summary = summarizer(text, max_length=100, min_length=30, do_sample=False)
11
+ return summary
12
+
13
+ # define input and output
14
+ inputs = gr.inputs.Textbox(lines=5, label="Enter text to summarize")
15
+ outputs = gr.outputs.Textbox(label="Summary")
16
+
17
+ # define interface
18
+ interface = gr.Interface(summarizer, inputs, outputs, live=True, capture_session=True)
19
+
20
+ # run interface
21
+ interface.launch(inline=False)