简体   繁体   English

Keras和OpenCV(CV2)是否作为Python可执行文件的依赖项?

[英]Keras and OpenCV (CV2) as dependencies for Python executable?

For a school assignment, I have written a system (in Python 3, on Windows 8.1) that takes in a specific scanned form, recognizes digits, compares it to an answer key, and puts the 'grades' into a csv. 对于学校作业,我编写了一个系统(在Windows 8.1中为Python 3),采用特定的扫描形式,识别数字,将其与答案键进行比较,然后将“成绩”放入CSV。 I have the system working completely based on individual files now (eg I have one file that 'parses' the scanned document, one part that does the recognition, a file that trained the neural net used to recognize, etc) but my instructor is requiring that I turn it into an executable. 我现在使系统完全基于单个文件工作(例如,我有一个“解析”扫描文档的文件,一个进行识别的部分,一个训练了用于识别的神经网络的文件等),但是我的教练要求我把它变成可执行文件。

I learned about pyinstaller recently, and I feel like this does what I want, but I am lost on how dependencies are supposed to work here. 我最近了解了pyinstaller,并且感觉可以满足我的要求,但是我对应该如何使用依赖项感到迷惑。 I believe I should create a 'run script' in Python that imports the individual components and calls functions with arguments in a specified order. 我相信我应该在Python中创建一个“运行脚本”,以导入各个组件并以指定顺序调用带有参数的函数。 I also have a 'template' image that needs to be stored with the executable. 我也有一个“模板”图像,需要与可执行文件一起存储。

For Keras and CV2, in particular, I know there are a very large number of dependencies. 特别是对于Keras和CV2,我知道有很多依赖项。 Do all of these dependencies need to be present in the directory that I install my program or does pyinstaller take them from the pip directory in which they are installed? 所有这些依赖项是否都需要存在于我安装程序的目录中,或者pyinstaller是否从安装它们的pip目录中获取它们? For OpenCV, do I have to figure out how to manage to bring that into the installer as well? 对于OpenCV,我是否还必须弄清楚如何设法将其引入安装程序?

Apologies if this isn't the correct place to ask the question. 抱歉,如果这不是问问题的正确位置。

Pyinstaller uses hooks for each package, you would need to check to ensure that Pyinstaller is compatible with your Keras and OpenCV packages. Pyinstaller对每个软件包使用钩子 ,您需要检查以确保Pyinstaller与您的Keras和OpenCV软件包兼容。 Most packages will work out of the box and you can check here for third-party supported packages. 大多数软件包都是开箱即用的,您可以在此处查看第三方支持的软件包。 I currently use OpenCV v4.0.0 and Pyinstaller v3.4 which works well. 我目前使用的OpenCV v4.0.0和Pyinstaller v3.4都可以正常工作。 From my understanding, Pyinstaller takes them from the pip directory where they are installed so you shouldn't need to worry about having the dependencies present in the same directory. 据我了解,Pyinstaller从安装它们的pip目录中获取它们,因此您不必担心在同一目录中存在依赖项。 Any packages used in your program will be automatically included in the Pyinstaller executable depending on what flags that you use to build the program. 程序中使用的所有软件包都将自动包含在Pyinstaller可执行文件中,具体取决于您用来构建程序的标志。

You can use the --onefile flag for a single file bundled executable. 您可以对单个文件捆绑的可执行文件使用--onefile标志。 Another useful flag is the --windowed flag which allows you to debug the program from the command line. 另一个有用的标志是--windowed标志,它使您可以从命令行调试程序。 You can find more information on flags here . 您可以在此处找到有关标志的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM