Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
# Use a pipeline as a high-level helper
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
# Initialize the summarization pipeline
|
7 |
+
pipe = pipeline("summarization", model="Falconsai/text_summarization", torch_dtype=torch.float16)
|
8 |
+
|
9 |
+
# Define the summarize function
|
10 |
+
def summarize(input):
|
11 |
+
output = pipe(input)
|
12 |
+
return output[0]['summary_text']
|
13 |
+
|
14 |
+
# Define the Gradio interface
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=summarize,
|
17 |
+
inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize here..."),
|
18 |
+
outputs="text",
|
19 |
+
title="Text Summarizer",
|
20 |
+
description="Enter a long piece of text, and the summarizer will provide a concise summary."
|
21 |
+
)
|
22 |
+
|
23 |
+
# Launch the interface
|
24 |
+
if __name__ == "__main__":
|
25 |
+
iface.launch()
|