Update handler.py
Browse files- handler.py +2 -2
handler.py
CHANGED
@@ -12,7 +12,7 @@ tokenizer.push_to_hub(repo_name="text-summary-gpt2-short", repo_id="Lin0He/text-
|
|
12 |
import torch
|
13 |
import numpy as np
|
14 |
from typing import Dict, List, Any
|
15 |
-
from transformers import pipeline, AutoModelForCausalLM,
|
16 |
|
17 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
18 |
|
@@ -72,7 +72,7 @@ def model_infer(model, tokenizer, review, max_length=300):
|
|
72 |
class EndpointHandler():
|
73 |
def __init__(self, path=""):
|
74 |
# load model and tokenizer from path
|
75 |
-
self.tokenizer =
|
76 |
self.model = AutoModelForCausalLM.from_pretrained("Lin0He/text-summary-gpt2-short")
|
77 |
|
78 |
|
|
|
12 |
import torch
|
13 |
import numpy as np
|
14 |
from typing import Dict, List, Any
|
15 |
+
from transformers import pipeline, AutoModelForCausalLM, GPT2Tokenizer
|
16 |
|
17 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
18 |
|
|
|
72 |
class EndpointHandler():
|
73 |
def __init__(self, path=""):
|
74 |
# load model and tokenizer from path
|
75 |
+
self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
76 |
self.model = AutoModelForCausalLM.from_pretrained("Lin0He/text-summary-gpt2-short")
|
77 |
|
78 |
|