Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
78fa07f
1
Parent(s):
fc86d43
Removed tensor.
Browse files
app.py
CHANGED
@@ -7,22 +7,17 @@ import spaces
|
|
7 |
from sumy.nlp.tokenizers import Tokenizer
|
8 |
from sumy.parsers.plaintext import PlaintextParser
|
9 |
from sumy.summarizers.text_rank import TextRankSummarizer
|
10 |
-
import torch
|
11 |
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
|
12 |
|
13 |
nltk.download('punkt_tab')
|
14 |
|
15 |
|
16 |
-
zero = torch.Tensor([0]).cuda()
|
17 |
-
print(zero.device)
|
18 |
-
|
19 |
class ModelLoader:
|
20 |
def __init__(self):
|
21 |
self.model_checkpoint = 'AryehRotberg/Pegasus-Large-Privacy-Policy-Summarization-V2'
|
22 |
self.model = PegasusForConditionalGeneration.from_pretrained(self.model_checkpoint).to('cuda')
|
23 |
self.tokenizer = PegasusTokenizer.from_pretrained(self.model_checkpoint)
|
24 |
|
25 |
-
@spaces.GPU
|
26 |
def predict(self, text):
|
27 |
inputs = self.tokenizer(
|
28 |
f'Summarize the following document: {text}\nSummary: ',
|
|
|
7 |
from sumy.nlp.tokenizers import Tokenizer
|
8 |
from sumy.parsers.plaintext import PlaintextParser
|
9 |
from sumy.summarizers.text_rank import TextRankSummarizer
|
|
|
10 |
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
|
11 |
|
12 |
nltk.download('punkt_tab')
|
13 |
|
14 |
|
|
|
|
|
|
|
15 |
class ModelLoader:
|
16 |
def __init__(self):
|
17 |
self.model_checkpoint = 'AryehRotberg/Pegasus-Large-Privacy-Policy-Summarization-V2'
|
18 |
self.model = PegasusForConditionalGeneration.from_pretrained(self.model_checkpoint).to('cuda')
|
19 |
self.tokenizer = PegasusTokenizer.from_pretrained(self.model_checkpoint)
|
20 |
|
|
|
21 |
def predict(self, text):
|
22 |
inputs = self.tokenizer(
|
23 |
f'Summarize the following document: {text}\nSummary: ',
|