drlon commited on
Commit
2dad144
·
1 Parent(s): c6ba3e6

.to(torch.bfloat16) # Add .to(torch.bfloat16) here for explicit casting

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -94,7 +94,7 @@ def get_som_response(instruction, image_som):
94
  )
95
 
96
  inputs = magma_processor(images=[image_som], texts=prompt, return_tensors="pt")
97
- inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
98
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
99
  # inputs = inputs.to("cuda")
100
  inputs = inputs.to("cuda", dtype=torch.bfloat16)
@@ -133,7 +133,7 @@ def get_qa_response(instruction, image):
133
  )
134
 
135
  inputs = magma_processor(images=[image], texts=prompt, return_tensors="pt")
136
- inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
137
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
138
  # inputs = inputs.to("cuda")
139
  inputs = inputs.to("cuda", dtype=torch.bfloat16)
 
94
  )
95
 
96
  inputs = magma_processor(images=[image_som], texts=prompt, return_tensors="pt")
97
+ inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0).to(torch.bfloat16) # Add .to(torch.bfloat16) here for explicit casting
98
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
99
  # inputs = inputs.to("cuda")
100
  inputs = inputs.to("cuda", dtype=torch.bfloat16)
 
133
  )
134
 
135
  inputs = magma_processor(images=[image], texts=prompt, return_tensors="pt")
136
+ inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0).to(torch.bfloat16) # Add .to(torch.bfloat16) here for explicit casting
137
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
138
  # inputs = inputs.to("cuda")
139
  inputs = inputs.to("cuda", dtype=torch.bfloat16)