Update modelling_magiv2.py
Browse files- modelling_magiv2.py +1 -2
modelling_magiv2.py
CHANGED
|
@@ -30,12 +30,11 @@ class Magiv2Model(PreTrainedModel):
|
|
| 30 |
return move_to_device(input, self.device)
|
| 31 |
|
| 32 |
def forward(self, images, move_to_device_fn=None, mask_ratio=0.0, batch_size=256):
|
|
|
|
| 33 |
if len(images) == 0:
|
| 34 |
return move_to_device_fn(torch.zeros(len(images), self.config.crop_embedding_model_config.hidden_size))
|
| 35 |
|
| 36 |
assert all(isinstance(image, PIL.Image.Image) for image in images), "please provide a list of PIL images"
|
| 37 |
-
|
| 38 |
-
move_to_device_fn = self.move_to_device if move_to_device_fn is None else move_to_device_fn
|
| 39 |
images = [np.array(image.convert("L").convert("RGB")) for image in images]
|
| 40 |
images = self.processor(images, return_tensors="pt").pixel_values
|
| 41 |
images = move_to_device_fn(images)
|
|
|
|
| 30 |
return move_to_device(input, self.device)
|
| 31 |
|
| 32 |
def forward(self, images, move_to_device_fn=None, mask_ratio=0.0, batch_size=256):
|
| 33 |
+
move_to_device_fn = self.move_to_device if move_to_device_fn is None else move_to_device_fn
|
| 34 |
if len(images) == 0:
|
| 35 |
return move_to_device_fn(torch.zeros(len(images), self.config.crop_embedding_model_config.hidden_size))
|
| 36 |
|
| 37 |
assert all(isinstance(image, PIL.Image.Image) for image in images), "please provide a list of PIL images"
|
|
|
|
|
|
|
| 38 |
images = [np.array(image.convert("L").convert("RGB")) for image in images]
|
| 39 |
images = self.processor(images, return_tensors="pt").pixel_values
|
| 40 |
images = move_to_device_fn(images)
|