learnervarun commited on
Commit
21a0079
·
verified ·
1 Parent(s): e4b360a

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +29 -0
App.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+
4
+ # Use a pipeline as a high-level helper
5
+ from transformers import pipeline
6
+
7
+ #model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
8
+
9
+ text_summary = pipeline("summarization", model= model_path,
10
+
11
+ torch_dtype=torch.bfloat16)
12
+
13
+ #text= ''''''
14
+
15
+ #print(text_summary(text));
16
+
17
+ def summary (input):
18
+ output = text_summary(input)
19
+ return output[0]['summary_text']
20
+
21
+ gr.close_all()
22
+
23
+ # demo = gr.Interface(fn=summary, inputs="text",outputs="text")
24
+ demo = gr.Interface(fn=summary,
25
+ inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
26
+ outputs=[gr.Textbox(label="Summarized text",lines=4)],
27
+ title="@GenAILearniverse Project 1: Text Summarizer",
28
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
29
+ demo.launch()