added demo
Browse files
app.py
CHANGED
@@ -1,13 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
def summarize_text(
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the text summarization pipeline
|
5 |
+
summarizer = pipeline("summarization", model="EleutherAI/gpt-j-6B")
|
6 |
|
7 |
+
def summarize_text(input_text):
|
8 |
+
# Use the summarization pipeline to generate a summary
|
9 |
+
summary = summarizer(input_text, max_length=100, min_length=30, do_sample=False)
|
10 |
+
return summary[0]['summary_text']
|
11 |
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(fn=summarize_text,
|
14 |
+
inputs="text",
|
15 |
+
outputs="text",
|
16 |
+
title="Text Summarization",
|
17 |
+
description="Enter some text and get a summary of it.")
|
18 |
+
|
19 |
+
iface.launch()
|