rexoscare commited on
Commit
9b76863
1 Parent(s): 7c6aebd

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ #!pip install -q torch transformers gradio
4
+
5
+ import os
6
+ import io
7
+ from transformers import pipeline
8
+ import gradio as gr
9
+
10
+ get_completion = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
11
+
12
+ def summarize(input):
13
+ output = get_completion(input) #takes an input
14
+ return output[0]['summary_text'] #returns an output as summarized text
15
+
16
+
17
+
18
+
19
+ gr.close_all()
20
+ #create an interface in Gradio
21
+ demo = gr.Interface(fn=summarize, #mentioning the function
22
+ inputs=[gr.Textbox(label="Text to summarize", lines=6)], #input interface Textbox
23
+ outputs=[gr.Textbox(label="Result", lines=3)],
24
+ title="Text summarization with distilbart-cnn",
25
+ description="Summarize any text using the `sshleifer/distilbart-cnn-12-6` model under the hood!"
26
+ )
27
+ demo.launch() #to luanch an app. share=True it creates a global link which can be used to access it without a localhost
28
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio