Spaces:
Running
Running
Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the summarization model
|
5 |
+
summarizer = pipeline("summarization", model="AventIQ-AI/t5-text-summarizer")
|
6 |
+
|
7 |
+
# Define the summarization function
|
8 |
+
def summarize_text(input_text):
|
9 |
+
summary = summarizer(input_text, max_length=150, min_length=30, do_sample=False)
|
10 |
+
return summary[0]['summary_text']
|
11 |
+
|
12 |
+
# Create the Gradio UI
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=summarize_text,
|
15 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize..."),
|
16 |
+
outputs="text",
|
17 |
+
title="T5 Text Summarizer",
|
18 |
+
description="Enter a passage, and the T5 model will generate a concise summary."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the app
|
22 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|