Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import AutoModel, AutoProcessor
|
| 4 |
import torch
|
|
@@ -13,7 +13,7 @@ model_name = "facebook/bart-large-cnn"
|
|
| 13 |
# Create a summarization pipeline with Facebook Bart
|
| 14 |
summarizer = pipeline("summarization", model=model_name)
|
| 15 |
|
| 16 |
-
# Define a function that takes
|
| 17 |
def summarize(input_text):
|
| 18 |
summary = summarizer(input_text, max_length=100, min_length=10, do_sample=False)
|
| 19 |
return summary[0]["summary_text"]
|
|
@@ -21,8 +21,8 @@ def summarize(input_text):
|
|
| 21 |
# Create a Gradio interface
|
| 22 |
interface = gr.Interface(
|
| 23 |
fn=summarize, # the function to wrap
|
| 24 |
-
inputs=gr.Textbox(lines=10, label="Input Text"),
|
| 25 |
-
outputs=gr.Textbox(label="Summary")
|
| 26 |
)
|
| 27 |
|
| 28 |
# Launch the interface
|
|
|
|
| 1 |
+
# Imports
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import AutoModel, AutoProcessor
|
| 4 |
import torch
|
|
|
|
| 13 |
# Create a summarization pipeline with Facebook Bart
|
| 14 |
summarizer = pipeline("summarization", model=model_name)
|
| 15 |
|
| 16 |
+
# Define a function that takes input and returns summary
|
| 17 |
def summarize(input_text):
|
| 18 |
summary = summarizer(input_text, max_length=100, min_length=10, do_sample=False)
|
| 19 |
return summary[0]["summary_text"]
|
|
|
|
| 21 |
# Create a Gradio interface
|
| 22 |
interface = gr.Interface(
|
| 23 |
fn=summarize, # the function to wrap
|
| 24 |
+
inputs=gr.Textbox(lines=10, label="Input Text"),
|
| 25 |
+
outputs=gr.Textbox(label="Summary")
|
| 26 |
)
|
| 27 |
|
| 28 |
# Launch the interface
|