TextSummarizer / app.py
gsmayuresh's picture
Update app.py
e7ddb6c verified
import torch
import gradio as gr
from transformers import pipeline
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
# 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.'''
# print(text_summary(text));
def summary(input_text):
out = text_summary(input_text)
return out[0]["summary_text"]
gr.close_all()
# demo=gr.Interface(fn=summary, inputs="text", outputs="text")
demo = gr.Interface(
fn=summary,
inputs=gr.Textbox(label="πŸ“ Input Text", lines=10, placeholder="Paste your text here..."),
outputs=gr.Textbox(label="πŸ“„ Summary", lines=6),
title="AI Text Summarizer",
description="Paste any text and get a concise summary powered by DistilBART-CNN.",
)
demo.launch()