TextSummarizer / app.py
SamuelVijayJacob's picture
Create app.py
342436c verified
import torch
import gradio as gr
# Use a pipeline as a high-level helper
from transformers import pipeline
# model_name = ("../Models\models--sshleifer--distilbart-cnn-12-6\snapshots" "\a4f8f3ea906ed274767e9906dbaede7531d660ff")
# text_summary = pipeline ( task= "summarization", model=model_name, torch_dtype=torch.bfloat16)
text_summary = pipeline ( task= "summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
# text ='''A Srinagar-bound IndiGo flight from Delhi with more than 200 passengers on board experienced strong turbulence as it navigated through an unexpected hailstorm that damaged a small portion of the aircraft's nose, on Wednesday.
# In a viral video from inside Indigo flight 6E2142, passengers and children can be heard screaming and crying in distress as the aircraft shakes violently after getting caught in the storm. The lightning flashes could be seen through the airplane videos.'''
# 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=[gr.Textbox(label="Input text to summarize",lines=6)],
outputs=[gr.Textbox(label="summarized text",lines=4)],
title="@GenAILearniverse Project 1: Text Summarizer",
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
print("πŸš€ App is launching...")
demo.launch(share=True)