Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
-
from transformers import
|
4 |
|
5 |
-
# Define the
|
6 |
-
MODEL_NAME = 'VishnuPottabatthini/
|
7 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
|
9 |
# Load the tokenizer and model
|
10 |
-
tokenizer =
|
11 |
-
model =
|
12 |
|
13 |
# Define the summarization function
|
14 |
def summarize(text, state):
|
@@ -53,7 +53,7 @@ mf_summarize = gr.Interface(
|
|
53 |
title="Article Summarization",
|
54 |
live=True,
|
55 |
description=(
|
56 |
-
"Enter a long piece of text to generate a concise summary using a
|
57 |
"This demo uses a custom PEGASUS model from 🤗 Transformers."
|
58 |
)
|
59 |
)
|
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
+
from transformers import PegasusTokenizer, PegasusForConditionalGeneration
|
4 |
|
5 |
+
# Define the PEGASUS model and tokenizer
|
6 |
+
MODEL_NAME = 'VishnuPottabatthini/PEGASUS_Large' # Change this to the PEGASUS model
|
7 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
|
9 |
# Load the tokenizer and model
|
10 |
+
tokenizer = PegasusTokenizer.from_pretrained(MODEL_NAME)
|
11 |
+
model = PegasusForConditionalGeneration.from_pretrained(MODEL_NAME).to(device)
|
12 |
|
13 |
# Define the summarization function
|
14 |
def summarize(text, state):
|
|
|
53 |
title="Article Summarization",
|
54 |
live=True,
|
55 |
description=(
|
56 |
+
"Enter a long piece of text to generate a concise summary using a PEGASUS model. "
|
57 |
"This demo uses a custom PEGASUS model from 🤗 Transformers."
|
58 |
)
|
59 |
)
|