pranavajay commited on
Commit
07d0465
·
verified ·
1 Parent(s): ef0fdf3

Update sh.py

Browse files
Files changed (1) hide show
  1. sh.py +18 -14
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
- # Iterate through the tensor names and shapes
11
- for name in model1.keys():
12
- if name in model2:
13
- shape1 = model1[name].shape
14
- shape2 = model2[name].shape
15
- if shape1 != shape2:
16
- print(f"Tensor '{name}' has different shapes: Model 1: {shape1}, Model 2: {shape2}")
17
- else:
18
- print(f"Tensor '{name}' is not present in model 2.")
 
 
 
 
 
 
 
 
19
 
20
- for name in model2.keys():
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.")