Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
a6b901d
1
Parent(s):
88b5781
HF needs all model downloads to a special read-write cache dir, also affects encoder.py
Browse files
vit_captioning/models/encoder.py
CHANGED
|
@@ -12,7 +12,10 @@ class ViTEncoder(nn.Module):
|
|
| 12 |
super(ViTEncoder, self).__init__()
|
| 13 |
|
| 14 |
#weights = ViT_B_16_Weights.DEFAULT
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def forward(self, pixel_values):
|
| 18 |
|
|
@@ -30,7 +33,9 @@ from transformers import CLIPModel
|
|
| 30 |
class CLIPEncoder(nn.Module):
|
| 31 |
def __init__(self):
|
| 32 |
super(CLIPEncoder, self).__init__()
|
| 33 |
-
self.clip = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
|
|
|
|
|
|
| 34 |
|
| 35 |
def forward(self, pixel_values):
|
| 36 |
# ✅ Directly get the pooled image features (already the final representation)
|
|
|
|
| 12 |
super(ViTEncoder, self).__init__()
|
| 13 |
|
| 14 |
#weights = ViT_B_16_Weights.DEFAULT
|
| 15 |
+
|
| 16 |
+
#self.vit = ViTModel.from_pretrained('google/vit-base-patch16-224-in21k')
|
| 17 |
+
#HF needs all model downloads to a special read-write cache dir
|
| 18 |
+
self.vit = ViTModel.from_pretrained('google/vit-base-patch16-224-in21k', cache_dir="/tmp")
|
| 19 |
|
| 20 |
def forward(self, pixel_values):
|
| 21 |
|
|
|
|
| 33 |
class CLIPEncoder(nn.Module):
|
| 34 |
def __init__(self):
|
| 35 |
super(CLIPEncoder, self).__init__()
|
| 36 |
+
#self.clip = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
| 37 |
+
#HF needs all model downloads to a special read-write cache dir
|
| 38 |
+
self.clip = CLIPModel.from_pretrained("openai/clip-vit-base-patch32", cache_dir="/tmp")
|
| 39 |
|
| 40 |
def forward(self, pixel_values):
|
| 41 |
# ✅ Directly get the pooled image features (already the final representation)
|