Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
Investigation Division. Seven of the men are from so-called "red-flagged" countries, including Egypt, Turkey, Georgia, Pakistan and Mali.
|
| 20 |
-
Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force.
|
| 21 |
-
If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18.
|
| 22 |
-
"""
|
| 23 |
-
print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False))
|
|
|
|
| 1 |
+
# Import libraries
|
| 2 |
+
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Create a summarization pipeline
|
| 6 |
+
summarizer = pipeline("summarization")
|
| 7 |
|
| 8 |
+
# Define a function that takes a text and returns a summary
|
| 9 |
+
def summarize(text):
|
| 10 |
+
summary = summarizer(text, max_length=150, min_length=40, do_sample=False)[0]
|
| 11 |
+
return summary["summary_text"]
|
| 12 |
+
|
| 13 |
+
# Create a Gradio interface
|
| 14 |
+
interface = gr.Interface(
|
| 15 |
+
fn=summarize, # the function to wrap
|
| 16 |
+
inputs=gr.Textbox(lines=10, label="Input Text"), # the input component
|
| 17 |
+
outputs=gr.Textbox(label="Summary") # the output component
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Launch the interface
|
| 21 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|