Spaces:
mashroo
/
Running on Zero

YoussefAnso commited on
Commit
1dfd90b
·
1 Parent(s): 566832c

Ensure input tensor is on the same device as model weights in FrozenOpenCLIPEmbedder. This change improves compatibility and performance by preventing device mismatch during image encoding.

Browse files
imagedream/ldm/modules/encoders/modules.py CHANGED
@@ -243,6 +243,8 @@ class FrozenOpenCLIPEmbedder(AbstractEncoder, nn.Module):
243
 
244
  def encode_image_with_transformer(self, x):
245
  visual = self.model.visual
 
 
246
  x = visual.conv1(x) # shape = [*, width, grid, grid]
247
  x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
248
  x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]
 
243
 
244
  def encode_image_with_transformer(self, x):
245
  visual = self.model.visual
246
+ # Ensure x is on the same device as the model weights
247
+ x = x.to(visual.conv1.weight.device)
248
  x = visual.conv1(x) # shape = [*, width, grid, grid]
249
  x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
250
  x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]