windy2612 commited on
Commit
10439c7
1 Parent(s): d3ead56

Update Predict.py

Browse files
Files changed (1) hide show
  1. 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'], map_locaption = device)
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):