gsmayuresh commited on
Commit
e7ddb6c
·
verified ·
1 Parent(s): a582dde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -3,18 +3,20 @@ import gradio as gr
3
  from transformers import pipeline
4
 
5
  text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
 
 
6
 
7
  def summary(input_text):
8
  out = text_summary(input_text)
9
- return out[0]["summary_text"] # ✅ fixed
10
 
11
  gr.close_all()
12
-
13
  demo = gr.Interface(
14
  fn=summary,
15
- inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
16
- outputs=[gr.Textbox(label="Summarized text", lines=4)],
17
- title="@GenAILearniverse Project 1: Text Summarizer",
18
- description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT"
19
  )
20
  demo.launch()
 
3
  from transformers import pipeline
4
 
5
  text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
6
+ # text='''Narendra Damodardas Modi[a] (born 17 September 1950) is an Indian politician who has served as the prime minister of India since 2014. Modi was the chief minister of Gujarat from 2001 to 2014 and is the member of parliament (MP) for Varanasi. He is a member of the Bharatiya Janata Party (BJP) and of the Rashtriya Swayamsevak Sangh (RSS), a right-wing Hindutva paramilitary volunteer organisation. He is the longest-serving prime minister outside the Indian National Congress.'''
7
+ # print(text_summary(text));
8
 
9
  def summary(input_text):
10
  out = text_summary(input_text)
11
+ return out[0]["summary_text"]
12
 
13
  gr.close_all()
14
+ # demo=gr.Interface(fn=summary, inputs="text", outputs="text")
15
  demo = gr.Interface(
16
  fn=summary,
17
+ inputs=gr.Textbox(label="📝 Input Text", lines=10, placeholder="Paste your text here..."),
18
+ outputs=gr.Textbox(label="📄 Summary", lines=6),
19
+ title="AI Text Summarizer",
20
+ description="Paste any text and get a concise summary powered by DistilBART-CNN.",
21
  )
22
  demo.launch()