-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Feature] Support getting model from the name defined in the model-index file. #1236
Conversation
Codecov ReportBase: 0.02% // Head: 89.17% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev-1.x #1236 +/- ##
============================================
+ Coverage 0.02% 89.17% +89.15%
============================================
Files 121 150 +29
Lines 8217 11543 +3326
Branches 1368 1848 +480
============================================
+ Hits 2 10294 +10292
+ Misses 8215 967 -7248
- Partials 0 282 +282
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I think it is good if I use inference of classification, but if I use it for detection, I would like to call the same for 21k models where no config exists, as shown below.
Some users may want to use it like timm.
A function like reset_classifier may be useful if I use such a call.
or
The scope of support in this area will depend on how you expect your users to use the system. |
This first problem can be avoided by adding missing config files. from mmcls import get_model
model = get_model('resnet50_8xb32_in1k', pretrained=True, head=dict(num_classes=10)) Do you think we need to implement the |
@mzr1996 It looks good. No need to add reset_classifier. |
Suppose a user doesn't know the concepts of Maybe, we can simplify this by the following:
|
Yes, but by now, users can only register their own config files by from mmcls.apis import ModelHub
ModelHub.register_model_index('my_metafile.yml') And I want to design some other methods to register new models like timm-style. I think it's better to add this documentation later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Motivation
Previously, if we want to use a pre-defined model in MMClassification, we have to clone the MMClassification and specify the config path to build a model.
This PR simplified the process. And we can get a model from the name defined in the model-index file.
Modification
get_model
andlist_models
API.apis
package into the top-level package.init_model
tommcls/apis/hub.py
.options
argument ininit_model
and consider all other keyword arguments as the config options of model. (BC-breaking)Use cases (Optional)
Get a ResNet-50 model and extract images feature:
Get Swin-Transformer model with pre-trained weights and inference:
List all models:
List ResNet-50 models on ImageNet-1k dataset:
Checklist
Before PR:
After PR: