在pyinstaller包中包含caffee prototxt文件

2024-05-15 17:22:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pyinstaller为深入学习的python应用程序创建一个可执行文件

该应用程序在虚拟环境中运行,并使用tensorflow和opencv,我解决了其中的一些问题,但现在我被卡住了。似乎无法读取程序使用的deploy.prototxt文件

错误是:

cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "face_detector\deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'

我在spec文件中包含了该文件路径,但没有成功。 我的等级库文件是:

    block_cipher = None


a = Analysis(['detect_mask_video.py'],
             pathex=['C:\\Users\\Alexandru\\Envs\\deeplearning_covmask\\Lib\\site-packages', 'E:\\deeplearning\\apps\\face-mask-detector\\face-mask-detector'],
             binaries=[],
             datas=[('C:\\Users\\Alexandru\\Envs\\deeplearning_covmask\\Lib\\site-packages\\astor\\VERSION', 'astor\\VERSION' ),
             ('E:\\deeplearning\\apps\\face-mask-detector\\face-mask-detector\\face_detector\\deploy.prototxt','face_detector\\deploy.prototxt' )],
             hiddenimports=['tensorflow'],
             hookspath=['hooks'],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='detect_mask_video',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True )

如何在生成的exe中包含proto文件


Tags: 文件false应用程序tensorflowmaskerrorblockdetector
1条回答
网友
1楼 · 发布于 2024-05-15 17:22:30

文档中不清楚,但根据我使用pyinstaller的经验,目标必须是文件夹。在等级库文件中,替换:

('E:\\deeplearning\\apps\\face-mask-detector\\face-mask-detector\\face_detector\\deploy.prototxt','face_detector\\deploy.prototxt' )

('E:\\deeplearning\\apps\\face-mask-detector\\face-mask-detector\\face_detector\\deploy.prototxt','face_detector' )

相关问题 更多 >