Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the text summarization pipeline
|
| 5 |
+
summarizer = pipeline("summarization", model="astro21/Llama-2-7b-chat-hf")
|
| 6 |
+
|
| 7 |
+
def summarize_text(input_text):
|
| 8 |
+
# Use the summarization pipeline to generate a summary
|
| 9 |
+
summarized_text = summarizer(input_text, max_length=128, min_length=64, do_sample=False , wait_for_model = True)
|
| 10 |
+
return summarized_text[0]['summary_text']
|
| 11 |
+
|
| 12 |
+
gr.Interface(
|
| 13 |
+
fn=summarize_text,
|
| 14 |
+
inputs=gr.inputs.Textbox(label="Enter the text to summarize"),
|
| 15 |
+
outputs=gr.outputs.Textbox(label="Summarized Text"),
|
| 16 |
+
title="Text Summarizer",
|
| 17 |
+
).launch()
|