Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Initialize the BART summarization model from Hugging Face
|
| 5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 6 |
+
|
| 7 |
+
# Define the function that will summarize the text
|
| 8 |
+
def summarize_text(input_text):
|
| 9 |
+
summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
|
| 10 |
+
return summary[0]['summary_text']
|
| 11 |
+
|
| 12 |
+
# Create a Gradio interface
|
| 13 |
+
iface = gr.Interface(fn=summarize_text,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="Text Summarization App",
|
| 17 |
+
description="This app summarizes long-form text (articles, papers, books) into concise key points or a paragraph.",
|
| 18 |
+
examples=[["Enter your article text here"]])
|
| 19 |
+
|
| 20 |
+
# Launch the interface
|
| 21 |
+
iface.launch()
|