noamrot commited on
Commit
6a946c6
·
1 Parent(s): e5eee6e

fix model weights names

Browse files
Files changed (2) hide show
  1. pytorch_model.bin +2 -2
  2. tmp.py +18 -0
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:43163604e325318c98c881ba0d30662dbc7dffb8acb47824a552960ecacfac08
3
- size 896088017
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34e7263f3e2652f4442fcc014c771d2f775d6d709866a887a82edc8d0703ce84
3
+ size 896058079
tmp.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+
3
+ # Load old model weights
4
+ old_weights = torch.load('/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model.bin', map_location=torch.device('cpu'))
5
+
6
+ # Prepare a dictionary to hold the new weights
7
+ new_weights = {}
8
+
9
+ # Loop over the items in old_weights
10
+ for name, weight in old_weights.items():
11
+ # Replace the old model's layer names with the new model's layer names
12
+ new_name = name.replace('vision_model.encoder.layers', 'visual_encoder.blocks')
13
+
14
+ # Add the modified name and associated weight to new_weights
15
+ new_weights[new_name] = weight
16
+
17
+ # Save the new weights
18
+ torch.save(new_weights, '/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model_new.bin')