Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize the summarization pipeline with a specified model
|
5 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
6 |
+
|
7 |
+
def summarize_text(input_text):
|
8 |
+
"""Function to summarize the input text."""
|
9 |
+
summary_result = text_summary(input_text)
|
10 |
+
return summary_result[0]['summary_text']
|
11 |
+
|
12 |
+
# Close any existing Gradio interfaces
|
13 |
+
gr.close_all()
|
14 |
+
|
15 |
+
# Define a Gradio interface for the summarization function
|
16 |
+
demo = gr.Interface(
|
17 |
+
fn=summarize_text,
|
18 |
+
inputs=gr.Textbox(label="Input text to summarize", lines=10, placeholder="Enter your text here..."),
|
19 |
+
outputs=gr.Textbox(label="Summarized text", lines=4),
|
20 |
+
title="Text Summarizer",
|
21 |
+
description="This application summarizes text. Just paste your text and get a summary!"
|
22 |
+
)
|
23 |
+
|
24 |
+
# Launch the Gradio interface
|
25 |
+
demo.launch()
|