Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the summarization model
|
| 5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 6 |
+
|
| 7 |
+
def summarize_text(input_text):
|
| 8 |
+
# Summarize the input text
|
| 9 |
+
summary = summarizer(input_text, min_length=10, max_length=100, do_sample=False)
|
| 10 |
+
return summary[0]['summary_text']
|
| 11 |
+
|
| 12 |
+
# Create the Gradio interface
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=summarize_text,
|
| 15 |
+
inputs=gr.Textbox(label="Enter Text", placeholder="Type or paste your long text here...", lines=10),
|
| 16 |
+
outputs=gr.Textbox(label="Summary"),
|
| 17 |
+
title="Text Summarization App",
|
| 18 |
+
description="Enter a long piece of text and click the button to get a summarized version."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Launch the app
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
interface.launch()
|