Closed lccui closed 3 years ago
Traceback (most recent call last):
File "shortcut_prune_sar_yolov4_csp.py", line 295, in
Traceback (most recent call last):
File "shortcut_prune_sar_yolov4_csp.py", line 437, in
请问,这都是为什么
loaded weights from weights/converted.weights
let's test the original model first: Class Images Targets P R mAP F1: 0%| | 0/174 [00:00<?, ?it/s] 转换出来的.weights不能测试,这是为什么
该项目没有使用weights模型
Traceback (most recent call last): File "shortcut_prune_sar_yolov4_csp.py", line 295, in percent_limit = (sorted_bn==highest_thre).nonzero().item()/len(bn_weights) ValueError: only one element tensors can be converted to Python scalars 通道剪枝时,会发生上述错误
稀疏度不够,最高点有多个
Traceback (most recent call last): File "shortcut_prune_sar_yolov4_csp.py", line 437, in init_weights_from_loose_model(compact_model, pruned_model, CBL_idx, Conv_idx, CBLidx2mask) File "E:\detect\yolov5_prune-main\utils\prune_utils.py", line 370, in init_weights_from_loose_model input_mask = get_input_mask(loose_model.module_defs, idx, CBLidx2mask) File "E:\detect\yolov5_prune-main\utils\prune_utils.py", line 267, in get_input_mask mask = CBLidx2mask[route_in_idxs[0]] KeyError: 108 也会发生这个错误
这个错误没碰到过,请提供具体的能复现该现象的步骤
根据您写的copy_weights.py函数,我写了yolov4-csp的函数,然后使用自己的数据和yolov4-csp.cfg和yolov4-csp.yaml训练,完了稀疏训练,参数为默认值,使用稀疏后的模型进行shortcut_prune.py会发生KeyError
将prune_utils.py中的get_input_mask()函数中有关spp的mask=CBLidx2mask[route_in_idxs[0]]改为mask=CBLidx2mask[route_in_idxs[-1]]上面的keyerror错误消失了,但是出现了新的错误 shortprune*.py中compact_forward_time, compact_output = obtainavg...()会报错, runtimeError:Given groups=1,weight of size[64, 12, 3, 3],expected input[1,20,256,256]to have 12 channels,but got 20channels instead
注意类别数和通道数
嗯,感谢,剪枝完模型的通道数不匹配了
文件配置或者代码配置设定的类别数不对,可以debug跟一下
loaded weights from weights/converted.weights
let's test the original model first: Class Images Targets P R mAP F1: 0%| | 0/174 [00:00<?, ?it/s] 转换出来的.weights不能测试,这是为什么