File size: 992 Bytes
fe19c39
d6a0658
48d31ab
 
c79fe33
 
48d31ab
07d0465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48d31ab
07d0465
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import torch
from safetensors.torch import load_file

# Load both models
model1 = load_file('merged_model.safetensors')
model2 = load_file('diffusion_pytorch_model-00002-of-00003.safetensors')

# Open log.txt for writing the output
with open('log.txt', 'w') as log_file:
    
    # Iterate through the tensor names and shapes of model1
    for name in model1.keys():
        if name in model2:
            shape1 = model1[name].shape
            shape2 = model2[name].shape
            if shape1 != shape2:
                log_file.write(f"Tensor '{name}' has different shapes: Model 1: {shape1}, Model 2: {shape2}\n")
        else:
            log_file.write(f"Tensor '{name}' is not present in model 2.\n")

    # Iterate through the tensor names and shapes of model2 to find ones not in model1
    for name in model2.keys():
        if name not in model1:
            log_file.write(f"Tensor '{name}' is not present in model 1.\n")

print("Comparison complete. Check log.txt for details.")