Spaces:
Running
Running
import torch | |
import gradio as gr | |
from transformers import pipeline | |
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16) | |
# model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots" | |
# "/a4f8f3ea906ed274767e9906dbaede7531d660ff") | |
# text_summary = pipeline("summarization", model=model_path, | |
# torch_dtype=torch.bfloat16) | |
# text='''Mukesh Dhirubhai Ambani (born 19 April 1957) is an Indian businessman and the chairman and managing | |
# director of Reliance Industries. With an estimated net worth of $113.7 billion as of March 2024, he is | |
# the richest person in Asia and 11th richest in the world. Sometimes characterized as a plutocrat, | |
# he has attracted both fame and notoriety for reports of market manipulation, political corruption, cronyism, | |
# and exploitation. | |
# Mukesh Dhirubhai Ambani was born on 19 April 1957 in the British Crown colony of Aden (present-day Yemen) | |
# into a Gujarati Hindu family to Dhirubhai Ambani and Kokilaben Ambani. He has a younger brother Anil Ambani | |
# and two sisters, Nina Bhadrashyam Kothari and Dipti Dattaraj Salgaonkar. | |
# Ambani lived only briefly in Yemen because his father decided to move back to India in 1958 to start a | |
# trading business that focused on spices and textiles. The latter was originally named "Vimal" but later | |
# changed to "Only Vimal". His family lived in a modest two-bedroom apartment in Bhuleshwar, Mumbai | |
# until the 1970s. The family's financial status slightly improved when they moved to India but Ambani | |
# still lived in a communal society, used public transportation, and never received an allowance. Dhirubhai | |
# later purchased a 14-floor apartment block called 'Sea Wind' in Colaba, where, until recently, Ambani and his | |
# brother lived with their families on different floors''' | |
# 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 text to summarize",lines=6)], | |
outputs=[gr.Textbox(label="Summarized text",lines=4)], | |
title="Text Summarizer", | |
description="This application can be used to summarise the text") | |
demo.launch() |