Comments (3)
Hey Guys,
I found a solution for this. As I found out, the name of the keys from the downloaded torchvision model and the trained Places365 model just don't match. I'm not the biggest python pro, so I came up with a pretty simple and barbaric solution (feel free to refactor it!).
model = models.__dict__[arch](num_classes=365)
checkpoint = torch.load(model_file, map_location=lambda storage, loc: storage)
state_dict = {str.replace(k,'module.',''): v for k,v in checkpoint['state_dict'].items()}
state_dict = {str.replace(k,'norm.','norm'): v for k,v in state_dict.items()}
state_dict = {str.replace(k,'conv.','conv'): v for k,v in state_dict.items()}
state_dict = {str.replace(k,'normweight','norm.weight'): v for k,v in state_dict.items()}
state_dict = {str.replace(k,'normrunning','norm.running'): v for k,v in state_dict.items()}
state_dict = {str.replace(k,'normbias','norm.bias'): v for k,v in state_dict.items()}
state_dict = {str.replace(k,'convweight','conv.weight'): v for k,v in state_dict.items()}
I am basically just replacing the key names of the Places365 model with the key names of the model downloaded from the torchvision.models package. I tested the model, and for me it works :)
@RiSaMa strict=False
ignores all not matching keys. So the initial model keeps his initial weights when no matching key is found in the new state_dict (in our case i think it's all of them). As you most likely are loading an untrained model from the torchvision.models package this results in random performance.
from places365.
Due to the upgrading of pytorch0.4, the densenet model structure is also updated, thus the old model cannot be loaded properly. I don't have solution for that yet.
from places365.
Same problem here... any solution?
I have been able to load the model as follows:
model = models.__dict__[arch](num_classes=365)
checkpoint = torch.load(model_file, map_location=lambda storage, loc: storage)
state_dict = {str.replace(k,'module.',''): v for k,v in checkpoint['state_dict'].items()}
model.load_state_dict(state_dict,strict=False) #NOTICE THE strict=False
model.cuda()
model.eval()
But the performance is almost random...
Any idea?
from places365.
Related Issues (20)
- AlexNet PyTorch weights are corrupt
- Image Dimensions
- Cannot download the dataset now HOT 12
- Where is the 'W_sceneattribute_wideresnet18.npy' file? HOT 2
- 504 Gateway Time-out response from dataset download server
- Attribute prediction weights for Hybrid1365 models HOT 1
- running in windows cmd platform HOT 1
- About confusions in run_placesCNN_unified.py
- The domain http://places2.csail.mit.edu is down HOT 4
- Demo website is down HOT 1
- Is there anywhere to obtain the dataset anymore? HOT 6
- model can not download HOT 1
- Generate Heatmap for categories that is not the top1
- wideresnet18_places365.pth.tar file not found HOT 6
- Resnet50_places365.t7 Issues!
- vgg16_hybrid1365 model output shape error
- Where can I download the Places365 Dataset? HOT 1
- python run_placesCNN_basic.py stopped working - cant download model tar file HOT 1
- Link to Pretrained model weights are broken. HOT 1
- The labels in the website and the labels in the dataset are different.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from places365.