diff --git a/requirements.txt b/requirements.txt index 92f483d5..d5c478ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,8 +10,9 @@ scipy>=1.4.1 tqdm>=4.41.0 addict>=2.4.0 tensorboard>=2.7.0 -pycocotools>=2.0 +pycocotools==2.0.8 onnx>=1.10.0 # ONNX export onnx-simplifier>=0.3.6 # ONNX simplifier +onnxscript>=0.5.4 thop # FLOPs computation # pytorch_quantization>=2.1.1 diff --git a/yolov6/utils/checkpoint.py b/yolov6/utils/checkpoint.py index c2f6239b..6b67e45f 100644 --- a/yolov6/utils/checkpoint.py +++ b/yolov6/utils/checkpoint.py @@ -10,7 +10,7 @@ def load_state_dict(weights, model, map_location=None): """Load weights from checkpoint file, only assign weights those layers' name and shape are match.""" - ckpt = torch.load(weights, map_location=map_location) + ckpt = torch.load(weights, map_location=map_location, weights_only=False) state_dict = ckpt['model'].float().state_dict() model_state_dict = model.state_dict() state_dict = {k: v for k, v in state_dict.items() if k in model_state_dict and v.shape == model_state_dict[k].shape} @@ -22,7 +22,7 @@ def load_state_dict(weights, model, map_location=None): def load_checkpoint(weights, map_location=None, inplace=True, fuse=True): """Load model from checkpoint file.""" LOGGER.info("Loading checkpoint from {}".format(weights)) - ckpt = torch.load(weights, map_location=map_location) # load + ckpt = torch.load(weights, map_location=map_location, weights_only=False) # load model = ckpt['ema' if ckpt.get('ema') else 'model'].float() if fuse: LOGGER.info("\nFusing model...") @@ -49,7 +49,7 @@ def strip_optimizer(ckpt_dir, epoch): ckpt_path = osp.join(ckpt_dir, '{}_ckpt.pt'.format(s)) if not osp.exists(ckpt_path): continue - ckpt = torch.load(ckpt_path, map_location=torch.device('cpu')) + ckpt = torch.load(ckpt_path, map_location=torch.device('cpu'), weights_only=False) if ckpt.get('ema'): ckpt['model'] = ckpt['ema'] # replace model with ema for k in ['optimizer', 'ema', 'updates']: # keys