ZJU-lishuang / yolov5_prune

yolov5 prune,Support V2, V3, V4 and V6 versions of yolov5
Apache License 2.0
556 stars 136 forks source link

The following error occurred testing the pruning model #78

Open wemindful opened 2 years ago

wemindful commented 2 years ago

Traceback (most recent call last): File "prune_val.py", line 360, in main(opt) File "prune_val.py", line 340, in main device=opt.device, save_json=False, plots=False) File "/usr/local/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "prune_val.py", line 124, in run model = attempt_load(weights, map_location=device) # load FP32 model File "/home/yolov5-v6/models/experimental.py", line 96, in attempt_load model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) # FP32 model AttributeError: 'collections.OrderedDict' object has no attribute 'float'

use method:

python prune_val.py --img-size 512 --batch-size 64 --data ./data/PFD.yaml --weights "./weights/prune_0.4_keep_0.01_best.pt" --task speed --verbose --half

I suspect that prune_val.py does not make changes to the pruning model