File size: 728 Bytes
6a946c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import torch

# Load old model weights
old_weights = torch.load('/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model.bin', map_location=torch.device('cpu'))

# Prepare a dictionary to hold the new weights
new_weights = {}

# Loop over the items in old_weights
for name, weight in old_weights.items():
    # Replace the old model's layer names with the new model's layer names
    new_name = name.replace('vision_model.encoder.layers', 'visual_encoder.blocks')
    
    # Add the modified name and associated weight to new_weights
    new_weights[new_name] = weight

# Save the new weights
torch.save(new_weights, '/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model_new.bin')