Spaces:
Sleeping
Sleeping
added app.py files
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
# Function to perform summarization
|
6 |
+
def summarize_text(text):
|
7 |
+
try:
|
8 |
+
summerizer = pipeline('summarization', model='google/t5-small')
|
9 |
+
summarized_text = summerizer(text)[0]['summary_text']
|
10 |
+
return summarized_text
|
11 |
+
except Exception as e:
|
12 |
+
return str(e)
|
13 |
+
|
14 |
+
# Create Gradio interface
|
15 |
+
input_text = gr.Textbox(lines=10, label="Input Text", placeholder="Enter text to summarize...")
|
16 |
+
output_text = gr.Textbox(label="Summarized Text", placeholder="Summarized text will appear here...")
|
17 |
+
|
18 |
+
# Author information
|
19 |
+
author = "Ajeetkumar Ukande"
|
20 |
+
|
21 |
+
# Create Gradio interface
|
22 |
+
interface = gr.Interface(summarize_text, inputs=input_text, outputs=output_text,
|
23 |
+
title="<div style='color: #336699; font-size: 24px; font-weight: bold; border: 2px solid #336699; padding: 10px; border-radius: 10px;'>Text Summarizer</div>",
|
24 |
+
description=f"""<div style='color: #666666; font-family: Arial, sans-serif;'>
|
25 |
+
<p style='margin-top: 10px;'>Enter some text and get it summarized.</p>
|
26 |
+
<p>Developed by <span style='color: #336699; font-weight: bold;'>{author}</span>.</p>
|
27 |
+
</div>""",
|
28 |
+
theme="default" # Change theme to default
|
29 |
+
|
30 |
+
)
|
31 |
+
|
32 |
+
# Deploy the interface to Hugging Face Spaces
|
33 |
+
interface.launch(share=True, debug=True)
|
34 |
+
|