Przemyslaw2115 commited on
Commit
1bb8f75
·
verified ·
1 Parent(s): 99530d4

Update MagicQuill/llava_new.py

Browse files
Files changed (1) hide show
  1. MagicQuill/llava_new.py +13 -6
MagicQuill/llava_new.py CHANGED
@@ -48,12 +48,19 @@ class LLaVAModel:
48
  image_sizes = []
49
  to_pil = transforms.ToPILImage()
50
  for image in images:
51
- image = image.clone().permute(2, 0, 1).cpu()
52
- image = to_pil(image)
53
- image_sizes.append(image.size)
54
- image = expand2square(image, tuple(int(x) for x in self.image_processor.image_mean))
55
- image = self.image_processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
56
- images_tensor.append(image.half())
 
 
 
 
 
 
 
57
 
58
  conv = conv_templates["llava_v1"].copy()
59
  conv.append_message(conv.roles[0], qs)
 
48
  image_sizes = []
49
  to_pil = transforms.ToPILImage()
50
  for image in images:
51
+ image = image.clone().permute(2, 0, 1).cpu()
52
+ image = to_pil(image)
53
+ image_sizes.append(image.size)
54
+ image = expand2square(image, tuple(int(x) for x in self.image_processor.image_mean))
55
+ image = self.image_processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
56
+
57
+ # ✅ Rzutowanie na float32 lub float16 zależnie od dostępności CUDA
58
+ if torch.cuda.is_available():
59
+ image = image.half()
60
+ else:
61
+ image = image.float()
62
+
63
+ images_tensor.append(image)
64
 
65
  conv = conv_templates["llava_v1"].copy()
66
  conv.append_message(conv.roles[0], qs)