Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
from transformers import pipeline
|
| 7 |
+
|
| 8 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
| 9 |
+
|
| 10 |
+
# model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots"
|
| 11 |
+
# "/a4f8f3ea906ed274767e9906dbaede7531d660ff")
|
| 12 |
+
# text_summary = pipeline("summarization", model=model_path,
|
| 13 |
+
# torch_dtype=torch.bfloat16)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# text='''Mukesh Dhirubhai Ambani (born 19 April 1957) is an Indian businessman and the chairman and managing
|
| 18 |
+
# director of Reliance Industries. With an estimated net worth of $113.7 billion as of March 2024, he is
|
| 19 |
+
# the richest person in Asia and 11th richest in the world. Sometimes characterized as a plutocrat,
|
| 20 |
+
# he has attracted both fame and notoriety for reports of market manipulation, political corruption, cronyism,
|
| 21 |
+
# and exploitation.
|
| 22 |
+
# Mukesh Dhirubhai Ambani was born on 19 April 1957 in the British Crown colony of Aden (present-day Yemen)
|
| 23 |
+
# into a Gujarati Hindu family to Dhirubhai Ambani and Kokilaben Ambani. He has a younger brother Anil Ambani
|
| 24 |
+
# and two sisters, Nina Bhadrashyam Kothari and Dipti Dattaraj Salgaonkar.
|
| 25 |
+
# Ambani lived only briefly in Yemen because his father decided to move back to India in 1958 to start a
|
| 26 |
+
# trading business that focused on spices and textiles. The latter was originally named "Vimal" but later
|
| 27 |
+
# changed to "Only Vimal". His family lived in a modest two-bedroom apartment in Bhuleshwar, Mumbai
|
| 28 |
+
# until the 1970s. The family's financial status slightly improved when they moved to India but Ambani
|
| 29 |
+
# still lived in a communal society, used public transportation, and never received an allowance. Dhirubhai
|
| 30 |
+
# later purchased a 14-floor apartment block called 'Sea Wind' in Colaba, where, until recently, Ambani and his
|
| 31 |
+
# brother lived with their families on different floors'''
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# print(text_summary(text));
|
| 35 |
+
|
| 36 |
+
def summary (input):
|
| 37 |
+
output = text_summary(input)
|
| 38 |
+
return output[0]['summary_text']
|
| 39 |
+
|
| 40 |
+
gr.close_all()
|
| 41 |
+
|
| 42 |
+
# demo = gr.Interface(fn=summary, inputs="text",outputs="text")
|
| 43 |
+
demo = gr.Interface(fn=summary,
|
| 44 |
+
inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
|
| 45 |
+
outputs=[gr.Textbox(label="Summarized text",lines=4)],
|
| 46 |
+
title="@GenAILearniverse Project 1: Text Summarizer",
|
| 47 |
+
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
|
| 48 |
+
demo.launch()
|
| 49 |
+
|
| 50 |
+
|