Spaces:
Runtime error
Runtime error
FoodDesert
commited on
Commit
•
80f1d22
1
Parent(s):
72d9282
Update app.py
Browse files
app.py
CHANGED
@@ -6,17 +6,45 @@ import os
|
|
6 |
def convert_embedding(sd15_embedding):
|
7 |
output_path = "embedding.safetensors"
|
8 |
|
|
|
|
|
9 |
sd15_embedding = torch.load(sd15_embedding.name, weights_only=True)
|
|
|
|
|
|
|
|
|
|
|
10 |
sd15_tensor = sd15_embedding['string_to_param']['*']
|
|
|
|
|
|
|
|
|
11 |
|
12 |
num_vectors = sd15_tensor.shape[0]
|
13 |
clip_g_shape = (num_vectors, 1280)
|
14 |
clip_l_shape = (num_vectors, 768)
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
clip_g = torch.zeros(clip_g_shape, dtype=torch.float16)
|
16 |
clip_l = torch.zeros(clip_l_shape, dtype=torch.float16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
clip_l[:sd15_tensor.shape[0], :sd15_tensor.shape[1]] = sd15_tensor.to(dtype=torch.float16)
|
18 |
save_file({"clip_g": clip_g, "clip_l": clip_l}, output_path)
|
19 |
|
|
|
|
|
|
|
20 |
# Return the path to the converted file for download
|
21 |
return output_path
|
22 |
|
|
|
6 |
def convert_embedding(sd15_embedding):
|
7 |
output_path = "embedding.safetensors"
|
8 |
|
9 |
+
print("got here 1")
|
10 |
+
|
11 |
sd15_embedding = torch.load(sd15_embedding.name, weights_only=True)
|
12 |
+
|
13 |
+
|
14 |
+
print("got here 2")
|
15 |
+
|
16 |
+
|
17 |
sd15_tensor = sd15_embedding['string_to_param']['*']
|
18 |
+
|
19 |
+
|
20 |
+
print("got here 3")
|
21 |
+
|
22 |
|
23 |
num_vectors = sd15_tensor.shape[0]
|
24 |
clip_g_shape = (num_vectors, 1280)
|
25 |
clip_l_shape = (num_vectors, 768)
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
print("got here 4")
|
30 |
+
|
31 |
+
|
32 |
clip_g = torch.zeros(clip_g_shape, dtype=torch.float16)
|
33 |
clip_l = torch.zeros(clip_l_shape, dtype=torch.float16)
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
print("got here 5")
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
clip_l[:sd15_tensor.shape[0], :sd15_tensor.shape[1]] = sd15_tensor.to(dtype=torch.float16)
|
43 |
save_file({"clip_g": clip_g, "clip_l": clip_l}, output_path)
|
44 |
|
45 |
+
print("got here 6")
|
46 |
+
|
47 |
+
|
48 |
# Return the path to the converted file for download
|
49 |
return output_path
|
50 |
|