finalf0 commited on
Commit
b4c82be
1 Parent(s): b02ef23

Fix device for cpu

Browse files
Files changed (1) hide show
  1. modeling_minicpmv.py +3 -3
modeling_minicpmv.py CHANGED
@@ -154,7 +154,7 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
154
  )
155
 
156
  model_input = {}
157
- model_input["input_ids"] = input_ids.unsqueeze(0).cuda()
158
  model_input["image_bound"] = image_bound
159
 
160
  return model_input
@@ -167,7 +167,7 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
167
  input_tensors.append(self._convert_to_tensors(tokenizer, data, max_inp_length))
168
  padded = {}
169
  for key in pad_keys:
170
- padded[key] = pad(input_tensors, key, padding_side="left").cuda()
171
  padded['image_bound'] = [i['image_bound'] for i in input_tensors]
172
  return padded
173
 
@@ -217,7 +217,7 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
217
  for img in img_list[i]:
218
  img_inps.append(self.transform(img))
219
  if img_inps:
220
- pixel_values.append(torch.stack(img_inps).cuda())
221
  else:
222
  pixel_values.append([])
223
  model_inputs['pixel_values'] = pixel_values
 
154
  )
155
 
156
  model_input = {}
157
+ model_input["input_ids"] = input_ids.unsqueeze(0).to(self.device)
158
  model_input["image_bound"] = image_bound
159
 
160
  return model_input
 
167
  input_tensors.append(self._convert_to_tensors(tokenizer, data, max_inp_length))
168
  padded = {}
169
  for key in pad_keys:
170
+ padded[key] = pad(input_tensors, key, padding_side="left").to(self.device)
171
  padded['image_bound'] = [i['image_bound'] for i in input_tensors]
172
  return padded
173
 
 
217
  for img in img_list[i]:
218
  img_inps.append(self.transform(img))
219
  if img_inps:
220
+ pixel_values.append(torch.stack(img_inps).to(self.device))
221
  else:
222
  pixel_values.append([])
223
  model_inputs['pixel_values'] = pixel_values