TextSummarizer / app.py
Jitendra6262's picture
Create app.py
e9c6643 verified
import torch
import gradio as gr
# Use a pipeline as a high-level helper
from transformers import pipeline
# model_path = ("../model/models--sshleifer--distilbart-cnn-12-6/"
# "snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6"
, torch_dtype=torch.bfloat16)
#
# text = """
# Ratan Naval Tata[a] (28 December 1937 – 9 October 2024)
# was an Indian industrialist and philanthropist. He served as
# the chairman of Tata Group and Tata Sons from 1991 to 2012 and he held
# the position of interim chairman from October 2016 to February 2017.[3][4] In 2000,
# he received the Padma Bhushan, the third highest civilian honour in India,
# followed by the Padma Vibhushan, the country's second highest civilian honour, in 2008.[5]
# """
# print(text_summary(text))
def summary(input):
output = text_summary(input)
return output[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 to summarize",lines = 6 )],
outputs= [gr.Textbox(label = "Summarized text",lines = 6)],
title="GenerativeAI Project 1 : Text summarize",
description="THIS APPLICATION WILL BE USE TO SUMMARIZE THE TEXT")
demo.launch()