pyinstaller 打包yolov7目标检测程序报错经验

pyinstaller 打包yolov7目标检测程序报错经验

1、pyinstaller版本会与python-opencv包冲突,建议提前修改opencv-python==4.5.3.56
2、根据报错信息去找原文件 添加到打包的文件里。(有相同名称的py可直接改成pyc添加到创建或已有的目录下)
3、出现以下报错信息:

// An highlighted block
Traceback (most recent call last):
  File "detect_image.py", line 405, in <module>
  File "detect_image.py", line 365, in main
  File "detect_image.py", line 293, in detection_alertarea
  File "detect_image.py", line 79, in __init__
  File "models\experimental.py", line 137, in attempt_load
  File "torch\serialization.py", line 594, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "torch\serialization.py", line 853, in _load
    result = unpickler.load()
ModuleNotFoundError: No module named 'models.yolo'
[12976] Failed to execute script detect_image

使用pyinstaller --hiddenimport=models.yolo detect.py 从新执行打包程序即可解决问题。

使用方式:
把detect文件夹从dist文件夹下转移到detect.py同级目录下,进入 detect文件内,./detect 即可运行测试能否使用

PS:我这里没有把模型打包成exe程序,仅作为一个可执行包来用

你可能感兴趣的:(报错集锦,python,开发语言)