Skip to content

How to get input shape for each pretrained model? #1158

Answered by TorbenSDJohansen
JohnG0024 asked this question in Q&A
Discussion options

You must be logged in to vote

To get the default input shape, one way would be to run the following code:

import timm

model_to_input_size = {}

for model in timm.list_models():
    default_cfg = timm.models.registry._model_default_cfgs.get(model, None)
    input_size = default_cfg['input_size'] if default_cfg else None
    model_to_input_size[model] = input_size

Note that very few models do not have a default_cfg. These are, e.g., deprecated models.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TorbenSDJohansen
Comment options

@JohnG0024
Comment options

Answer selected by JohnG0024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants