TanmayP commited on
Commit
4257f16
·
verified ·
1 Parent(s): b53687e

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +41 -0
App.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import gradio
4
+ from transformers import pipeline
5
+
6
+ # Used the model ID from the Hugging Face Hub
7
+ text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
8
+
9
+ Example text
10
+ # text = '''Costello's (also known as Tim's) was a bar and restaurant in Midtown Manhattan,
11
+ # New York City, from 1929 to 1992. The bar operated at several locations near the intersection
12
+ # of East 44th Street and Third Avenue. Costello's was known as a drinking spot for journalists with the
13
+ # New York Daily News, writers with The New Yorker, novelists, and cartoonists, including the author Ernest Hemingway,
14
+ # the cartoonist James Thurber, the journalist John McNulty, the poet Brendan Behan, the short-story writer John O'Hara,
15
+ # and the writers Maeve Brennan and A. J. Liebling. The bar is also known for having been home to a wall where Thurber drew a
16
+ # cartoon depiction of the "Battle of the Sexes" at some point between 1934 and 1935; the cartoon was destroyed, illustrated again,
17
+ # and then lost in the 1990s. A wall illustrated in 1976 by several cartoonists, including Bill Gallo, Stan Lee, Mort Walker,
18
+ # Al Jaffee, Sergio Aragonés, and Dik Browne, is still on display at the bar's final location.'''
19
+ #
20
+ # # Print the summary
21
+ # print(text_summary(text))
22
+
23
+
24
+ #we are writing this function gardio accepts function, this function will return the output
25
+ def summary(input):
26
+ output = text_summary(input)
27
+ return output[0]['summary_text']
28
+
29
+
30
+ gradio.close_all()
31
+
32
+ # demo = gradio.Interface(fn=summuray,inputs="text",outputs="text")
33
+
34
+ demo = gradio.Interface(fn=summary,
35
+ inputs=[gradio.Textbox(label="Input text to summarize",lines=6)],
36
+ outputs=[gradio.Textbox(label="Summarized text", lines=4)],
37
+ title="@GenAi Project 1: Text Summarizer",
38
+ description="THis application can used for summarizing the text")
39
+
40
+
41
+ demo.launch()