Comments (3)
I dowload the pretrained model from https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar
from moganet.
Hi, @Cxz-dev, thanks for using MogaNet. Could you please describe your usage in detail? The RuntimeError you met is caused by no classification head in the built model. I provide two situations of loading pre-trained models and hope these will be helpful to you.
-
In image classification tasks, you can build MogaNet-Base and load pre-training without any errors:
import models from timm.models import create_model cnn = create_model('moganet_base', pretrained=True) # build by timm cnn = models.moganet.moganet_base(pretrained=True) # or call the model directly
-
For downstream tasks, you will get
RuntimeError: Error(s) in loading state_dict for MogaNet
if you build the model like this. Sincefork_feat=True
will remove the classification head in MogaNet and the pre-trained models in moganet-in1k-weights contain parameters of the head, it will raise the error usingmodel.load_state_dict(checkpoint["state_dict"])
, wherestrict
defaults to True.import models from timm.models import create_model cnn = create_model('moganet_base', pretrained=True, fork_feat=True) # fork_feat=True for dense predictions
Therefore, I suggest you load the model as follows or directly perform dense prediction tasks by our implementations in MogaNet/detection, MogaNet/segmentation, and MogaNet/pose_estimation.
import torch import models from timm.models import create_model cnn = create_model('moganet_base', fork_feat=True) checkpoint = torch.hub.load_state_dict_from_url(url='https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar', map_location="cpu", check_hash=True) cnn.load_state_dict(checkpoint["state_dict"], strict=False) # allow unexpected keys
from moganet.
Thanks for your question. I will close this issue if you have no more questions. Please feel free to open a new issue when new problems occur.
from moganet.
Related Issues (14)
- About pretrain models. HOT 4
- network name
- Unable to train model HOT 2
- Inquiry for code to train baseline HOT 2
- cooldown epochs HOT 1
- Cascade Mask RCNN Configuration HOT 1
- Is channel aggregation block stronger than SE block? HOT 2
- Could you share the code for drawing multi-order interactions that shown in Fig. 3 of your paper? HOT 2
- Code Issue about MultiOrderGatedAggregation HOT 3
- Some Questions about the paper HOT 2
- Some small issues about detection and segmentation HOT 1
- What is "trivial interactions" mentioned in the paper? HOT 7
- How do I create an interference code HOT 2
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 moganet.