Upload calculate-vith.py
Browse files- openclip/calculate-vith.py +15 -5
openclip/calculate-vith.py
CHANGED
@@ -11,6 +11,18 @@ Plan:
|
|
11 |
|
12 |
|
13 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
import torch
|
15 |
import open_clip
|
16 |
|
@@ -20,16 +32,14 @@ from safetensors import safe_open
|
|
20 |
|
21 |
device=torch.device("cuda")
|
22 |
|
23 |
-
|
24 |
-
mname='laion2b_s32b_b79k'
|
25 |
-
|
26 |
-
print("Loading",mtype,mname)
|
27 |
|
28 |
cmodel, _, preprocess = open_clip.create_model_and_transforms(mtype,
|
29 |
pretrained=mname)
|
30 |
tokenizer = open_clip.get_tokenizer(mtype)
|
31 |
|
32 |
-
|
|
|
33 |
|
34 |
|
35 |
#embed_file="embeddings.safetensors"
|
|
|
11 |
|
12 |
|
13 |
import sys
|
14 |
+
|
15 |
+
mtype='ViT-H-14'
|
16 |
+
mname='laion2B-s32B-b79K'
|
17 |
+
|
18 |
+
print(f"Configured for {mtype}, {mname}")
|
19 |
+
|
20 |
+
if len(sys.argv) < 3:
|
21 |
+
print("Error: need embeddings file and dictionary name")
|
22 |
+
sys.exit(1)
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
import torch
|
27 |
import open_clip
|
28 |
|
|
|
32 |
|
33 |
device=torch.device("cuda")
|
34 |
|
35 |
+
print("Loading model")
|
|
|
|
|
|
|
36 |
|
37 |
cmodel, _, preprocess = open_clip.create_model_and_transforms(mtype,
|
38 |
pretrained=mname)
|
39 |
tokenizer = open_clip.get_tokenizer(mtype)
|
40 |
|
41 |
+
print("Moving model to cuda")
|
42 |
+
cmodel.to(device)
|
43 |
|
44 |
|
45 |
#embed_file="embeddings.safetensors"
|