diff --git a/models/common.py b/models/common.py index 30202ca1abd7..4f93887c55e0 100644 --- a/models/common.py +++ b/models/common.py @@ -337,8 +337,10 @@ def __init__(self, weights='yolov5s.pt', device=torch.device('cpu'), dnn=False, extra_files = {'config.txt': ''} # model metadata model = torch.jit.load(w, _extra_files=extra_files) model.half() if fp16 else model.float() - if extra_files['config.txt']: - d = json.loads(extra_files['config.txt']) # extra_files dict + if extra_files['config.txt']: # load metadata dict + d = json.loads(extra_files['config.txt'], + object_hook=lambda d: {int(k) if k.isdigit() else k: v + for k, v in d.items()}) stride, names = int(d['stride']), d['names'] elif dnn: # ONNX OpenCV DNN LOGGER.info(f'Loading {w} for ONNX OpenCV DNN inference...')