Update sh.py
Browse files
sh.py
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
-
|
2 |
import torch
|
3 |
from safetensors.torch import load_file
|
4 |
|
5 |
-
|
6 |
# Load both models
|
7 |
model1 = load_file('merged_model_016.safetensors')
|
8 |
model2 = load_file('diffusion_pytorch_model-00001-of-00003.safetensors')
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
if
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
if name not in model1:
|
22 |
-
print(f"Tensor '{name}' is not present in model 1.")
|
|
|
|
|
1 |
import torch
|
2 |
from safetensors.torch import load_file
|
3 |
|
|
|
4 |
# Load both models
|
5 |
model1 = load_file('merged_model_016.safetensors')
|
6 |
model2 = load_file('diffusion_pytorch_model-00001-of-00003.safetensors')
|
7 |
|
8 |
+
# Open log.txt for writing the output
|
9 |
+
with open('log.txt', 'w') as log_file:
|
10 |
+
|
11 |
+
# Iterate through the tensor names and shapes of model1
|
12 |
+
for name in model1.keys():
|
13 |
+
if name in model2:
|
14 |
+
shape1 = model1[name].shape
|
15 |
+
shape2 = model2[name].shape
|
16 |
+
if shape1 != shape2:
|
17 |
+
log_file.write(f"Tensor '{name}' has different shapes: Model 1: {shape1}, Model 2: {shape2}\n")
|
18 |
+
else:
|
19 |
+
log_file.write(f"Tensor '{name}' is not present in model 2.\n")
|
20 |
+
|
21 |
+
# Iterate through the tensor names and shapes of model2 to find ones not in model1
|
22 |
+
for name in model2.keys():
|
23 |
+
if name not in model1:
|
24 |
+
log_file.write(f"Tensor '{name}' is not present in model 1.\n")
|
25 |
|
26 |
+
print("Comparison complete. Check log.txt for details.")
|
|
|
|