ankitdwivedi31 commited on
Commit
67067c8
1 Parent(s): 55cb804

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ pipe = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
8
+
9
+ # model_path = "C:/Users/ankitdwivedi/OneDrive - Adobe/Desktop/NLP Projects/Video to Text Summarization/Model/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff"
10
+
11
+ # text_summary = pipeline("summarization", model=model_path, torch_dtype=torch.bfloat16)
12
+
13
+ # text = """In 2008, Modi published a Gujarati book titled Jyotipunj, which contains profiles of RSS leaders. The longest was of M. S. Golwalkar, under whose leadership the RSS expanded and whom Modi refers to as Pujniya Shri Guruji (Guru worthy of worship).[519] According to The Economic Times, Modi's intention was to explain the workings of the RSS to his readers, and to reassure RSS members he remained ideologically aligned with them."""
14
+
15
+ # print(text_summary(text));
16
+
17
+
18
+ def summary(input):
19
+ output = text_summary(input)
20
+ return output[0]['summary_text']
21
+
22
+ gr.close_all()
23
+
24
+ demo = gr.Interface(fn=summary, inputs=[gr.Textbox(label="Input text to summarize",lines = 6)],outputs=[gr.Textbox(label="Summarized Text",lines = 4)],title="Project 1: Text summary",
25
+ description="""This is a simple text summarization model.""")
26
+ demo.launch()