Update Predict.py
Browse files- Predict.py +3 -5
Predict.py
CHANGED
@@ -5,16 +5,14 @@ from PIL import Image
|
|
5 |
from torchvision import transforms as T
|
6 |
import torch
|
7 |
|
8 |
-
|
9 |
-
checkpoint = torch.load('last_checkpoint.pt')
|
10 |
with open('answer.json', 'r', encoding = 'utf8') as f:
|
11 |
answer_space = json.load(f)
|
12 |
swap_space = {v : k for k, v in answer_space.items()}
|
13 |
|
14 |
-
|
15 |
-
device = torch.device('cpu')
|
16 |
model = BaseModel().to(device)
|
17 |
-
model.load_state_dict(checkpoint['model_state_dict']
|
18 |
|
19 |
def generate_caption(image, question):
|
20 |
if isinstance(image, np.ndarray):
|
|
|
5 |
from torchvision import transforms as T
|
6 |
import torch
|
7 |
|
8 |
+
device = torch.device('cpu')
|
9 |
+
checkpoint = torch.load('last_checkpoint.pt', map_location = device)
|
10 |
with open('answer.json', 'r', encoding = 'utf8') as f:
|
11 |
answer_space = json.load(f)
|
12 |
swap_space = {v : k for k, v in answer_space.items()}
|
13 |
|
|
|
|
|
14 |
model = BaseModel().to(device)
|
15 |
+
model.load_state_dict(checkpoint['model_state_dict'])
|
16 |
|
17 |
def generate_caption(image, question):
|
18 |
if isinstance(image, np.ndarray):
|