Spaces:
Runtime error
Runtime error
Commit ·
234195a
1
Parent(s): abbf116
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
summarization_pipeline = pipeline("summarization")
|
| 5 |
+
|
| 6 |
+
def summarize_text(text, max_length):
|
| 7 |
+
summary = summarization_pipeline(text, max_length=max_length, do_sample=True)[0]['summary_text']
|
| 8 |
+
return summary
|
| 9 |
+
|
| 10 |
+
input_text = gr.inputs.Textbox(label="Input Text")
|
| 11 |
+
max_length = gr.inputs.Number(default=100, label="Maximum Length")
|
| 12 |
+
output_text = gr.outputs.Textbox(label="Summary")
|
| 13 |
+
|
| 14 |
+
gr.Interface(fn=summarize_text, inputs=[input_text, max_length], outputs=output_text, title="Text Summarization", description="Enter text and the maximum length of summary").launch()
|