请教下我用yolov5剪枝后微调后,需要检测一下效果好坏,但是现在出现了权重文件无法导入的情况,不知道问题出在了什么地方?下面是出问题的代码部分,请帮我看看问题在什么地方?
model = DetectPrunedMultiBackend(weights, device=device, dnn=dnn) # 这是模型导入和重构的类
model = attempt_load_pruned(weights if isinstance(weights, list) else w, map_location='cpu') 在这个类内用attempt_load_pruned()来导入权重
ckpt = torch.load(attempt_download(w), map_location=map_location) # 问题出在了这个地方
显示的错误是这样的
File "D:\anaconda\envs\mmyolo\lib\site-packages\torch\serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'yolo_pruned'
显示找不到这个模块。我在netron中也能导入权重可视化。
class UnpicklerWrapper(pickle_module.Unpickler): # type: ignore[name-defined]
# from https://stackoverflow.com/questions/13398462/unpickling-python-objects-with-a-changed-module-path/13405732
# Lets us override the imports that pickle uses when unpickling an object.
# This is useful for maintaining BC if we change a module path that tensor instantiation relies on.
def find_class(self, mod_name, name):
mod_name = load_module_mapping.get(mod_name, mod_name)
return super().find_class(mod_name, name)
我用1.10版本和1.13版本都测试了,不行。显示同样的错误。