Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Use a pipeline as a high-level helper
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
|
| 7 |
+
text_summary = pipeline("summarization", model="models--sshleifer--distilbart-cnn-12-6",
|
| 8 |
+
torch_dtype=torch.bfloat16)
|
| 9 |
+
|
| 10 |
+
# model_path ="../Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff"
|
| 11 |
+
|
| 12 |
+
# text_summary = pipeline("summarization", model=model_path,
|
| 13 |
+
# torch_dtype=torch.bfloat16)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# text=''Elon Reeve Musk (/ˈiːlɒn mʌsk/; born June 28, 1971) is a businessman and United States
|
| 17 |
+
# special government employee known for his key roles in the automotive company Tesla, Inc.
|
| 18 |
+
# and the space company SpaceX. He is also known for his ownership of the technology company
|
| 19 |
+
# X Corp. and his role in the founding of the Boring Company, xAI, Neuralink, and OpenAI.
|
| 20 |
+
# Musk is the wealthiest individual in the world; as of January 2025, Forbes estimates his net
|
| 21 |
+
# worth to be US$426 billion. Musk has engaged in political activities in several countries, including
|
| 22 |
+
# as a vocal and financial supporter of U.S. president Donald Trump. He became the largest
|
| 23 |
+
# donor in the 2024 United States presidential election, and a supporter of international
|
| 24 |
+
# far-right political parties, activists, and causes.
|
| 25 |
+
#
|
| 26 |
+
# A member of the wealthy South African Musk family, Musk was born in Pretoria before immigrating to
|
| 27 |
+
# Canada, acquiring its citizenship through his Canadian-born mother, Maye. Two years later, he matriculated
|
| 28 |
+
# at Queen's University in Canada. Musk later transferred to the University of Pennsylvania and received bachelor's
|
| 29 |
+
# degrees in economics and physics. He moved to California in 1995 to attend Stanford University, and with his brother
|
| 30 |
+
# Kimbal co-founded the software company Zip2, that was later acquired by Compaq in 1999. That same year, Musk co-founded
|
| 31 |
+
# X.com, a direct bank, that later formed PayPal. In 2002, Musk acquired United States citizenship, and eBay acquired PayPal.
|
| 32 |
+
# Using the money he made from the sale, Musk founded SpaceX, a spaceflight services company, in 2002. ''
|
| 33 |
+
# print(text_summary(text))
|
| 34 |
+
|
| 35 |
+
def summary(inputtext):
|
| 36 |
+
output= text_summary(inputtext)
|
| 37 |
+
return output[0]['summary_text']
|
| 38 |
+
|
| 39 |
+
gr.close_all()
|
| 40 |
+
|
| 41 |
+
demo = gr.Interface(fn=summary, inputs="text", outputs="text")
|
| 42 |
+
# demo = gr.Interface(fn=summary,
|
| 43 |
+
# inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
|
| 44 |
+
# outputs=[gr.Textbox(label="Summarized text",lines=4)],
|
| 45 |
+
# title="GenAI Project 1: Text Summarizer",
|
| 46 |
+
# description="THIS APPLICATION IS USED TO SUMMARIZE TEXT")
|
| 47 |
+
demo.launch()
|