timm.create_model loads the model from a specified local path #1941
Replies: 7 comments 2 replies
-
@laogonggong847 functionality was added for this scenario, see my ansewr here #1826 (comment) ... it should work fine with |
Beta Was this translation helpful? Give feedback.
-
Hello @rwightman |
Beta Was this translation helpful? Give feedback.
-
@laogonggong847 that functionality was added in 0.9 to solve this use case that a few people had. There is no way of doing it in 0.6.x other than trying to figure out exactly where the torch cache location for the checkpoint is and putting yours in that location. You can't easily avoid the subfolders or redirect without hacking the code... |
Beta Was this translation helpful? Give feedback.
-
You should try 0.9 though as it's quite likely to work even if there is a 0.6.x dependency, effort was made to allow backwards compatibility for majority of changes and the rest should be minor import module name changes (mentioned at top of README). |
Beta Was this translation helpful? Give feedback.
-
Moving to discussion for future ref |
Beta Was this translation helpful? Give feedback.
-
you can use semantic_model = timm.create_model(
resnet50,
pretrained=True,
features_only=True,
pretrained_cfg={'file': 'path_to_your_local_model'}) |
Beta Was this translation helpful? Give feedback.
-
Better to use pretrained_cfg_overlay to not overwrite other config keys. model = timm.create_model(
model_name,
...,
pretrained_cfg_overlay={'file': 'path_to_your_local_model'}
) |
Beta Was this translation helpful? Give feedback.
-
hello @rwightman,
Thank you for all the work you've done, and now I have a question.
Where
backbone: str = "wide_resnet_50_2"
, This code will tell the program to look for the model in question under myC:\Users\user\.cache\torch\hub\checkpoints
(which is the path under windows) and if it doesn't exist then download it from the web.I set the following two parameters in create_model
pretrained=True, features_only=True,
Since
"features_only=True"
, I can't change the program topretrained=Fasle
, and I can't addcheckpoint_path = "my_model_path"
for the program to go to the folder I specified to find the corresponding model.So I chose to change OS["TORCH_HOME"] = "New_path"
But I found that when I made this change, the path where timm ends up looking for the model becomes
"New_path/hub/checkpoints"
.How should I get timm to go to the folder path I specified to find the corresponding model with
pretrained=True, features_only=True
. And make sure that the timm is looking exactly at the path I provide it with, and not adding subfolders to the path I provide as it would if I were modifying OS["TORCH_HOME"]!Very much looking forward to your reply, thanks!
Beta Was this translation helpful? Give feedback.
All reactions