Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,18 @@
|
|
| 1 |
-
import
|
| 2 |
-
import gradio as gr
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
# its its used for local after installing the model
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",torch_dtype=torch.bfloat16)
|
| 11 |
-
# text = '''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman known for his key roles in Tesla, SpaceX, PayPal, OpenAI, Twitter (which he rebranded as X) and America PAC. Since 2025, he has been a senior advisor to United States president Donald Trump and the de facto head of the Department of Government Efficiency (DOGE). Musk is the wealthiest person in the world; as of March 2025, Forbes estimates his net worth to be US$345 billion. '''
|
| 12 |
-
# print(text_summary(text));
|
| 13 |
|
| 14 |
-
def summary
|
| 15 |
output = text_summary(input)
|
| 16 |
return output[0]['summary_text']
|
| 17 |
|
| 18 |
-
gr.close_all()
|
| 19 |
-
|
| 20 |
-
# demo = gr.Interface(fn=summary, inputs="text", outputs="text")
|
| 21 |
-
|
| 22 |
demo = gr.Interface(
|
| 23 |
fn=summary,
|
| 24 |
inputs=[gr.Textbox(label="Input text to summarize", lines=7)],
|
|
@@ -26,4 +20,6 @@ demo = gr.Interface(
|
|
| 26 |
title="@cygon: Text summarizer",
|
| 27 |
description="SIMPLE UNPAID APPLICATION FOR TEXT SUMMARIZING"
|
| 28 |
)
|
|
|
|
| 29 |
demo.launch()
|
|
|
|
|
|
| 1 |
+
import os
|
|
|
|
| 2 |
|
| 3 |
+
# Install dependencies manually if not found
|
| 4 |
+
os.system("pip install torch torchvision torchaudio transformers gradio")
|
|
|
|
| 5 |
|
| 6 |
+
import torch
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from transformers import pipeline
|
| 9 |
|
| 10 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
def summary(input):
|
| 13 |
output = text_summary(input)
|
| 14 |
return output[0]['summary_text']
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=summary,
|
| 18 |
inputs=[gr.Textbox(label="Input text to summarize", lines=7)],
|
|
|
|
| 20 |
title="@cygon: Text summarizer",
|
| 21 |
description="SIMPLE UNPAID APPLICATION FOR TEXT SUMMARIZING"
|
| 22 |
)
|
| 23 |
+
|
| 24 |
demo.launch()
|
| 25 |
+
|