expired pytorch hub cache bug fix #365

This commit is contained in:
Glenn Jocher committed 2020-07-11 15:03:12 -07:00
1 parent f7a6d6c8d4
commit 6e3c3b62b2
1 file changed
+4
+4
View File
@@ -27,6 +27,7 @@ def create(name, pretrained, channels, classes):
Returns: Returns:
pytorch model pytorch model
""" """
try:
config = os.path.join(os.path.dirname(__file__), 'models', '%s.yaml' % name) # model.yaml path config = os.path.join(os.path.dirname(__file__), 'models', '%s.yaml' % name) # model.yaml path
model = Model(config, channels, classes) model = Model(config, channels, classes)
if pretrained: if pretrained:
@@ -36,6 +37,9 @@ def create(name, pretrained, channels, classes):
state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].shape == v.shape} # filter state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].shape == v.shape} # filter
model.load_state_dict(state_dict, strict=False) # load model.load_state_dict(state_dict, strict=False) # load
return model return model
except Exception as e:
help_url = 'https://github.com/ultralytics/yolov5/issues/36'
print('%s\nCache is out of date. Delete cache and retry. See %s for help.' % (e, help_url))
def yolov5s(pretrained=False, channels=3, classes=80): def yolov5s(pretrained=False, channels=3, classes=80):