Create exe file

Can I collapse my neural network into an exe file and run it as a separate process?

1 Like

What do you mean by that? Do you want to pack your net into .exe file that takes i.e. a path to an image and as an output gives the prediction?

Is this really possible?

Yes, try using PyInstaller.

You can try to do this yourself, and if something won’t work, you can learn from my mistakes:

  1. To use it with conda, you have to have pytorch installed from pip under conda, not pure conda
  2. If you are using jsonschema package, use v. 2.6.0, not later
  3. For me it only worked with additional import to PyInstaller:
pyinstaller --hiddenimport pywt._extensions._cwt
  1. Also I had to make additional hook for skimage (idk, if you are using that package, if you do, this will help you):
    3.1 - make folder hooks in folder containing your script
    3.2 - make script in that folder that contains:
from PyInstaller.utils.hooks import collect_data_files, collect_submodules

datas = collect_data_files("")
hiddenimports = collect_submodules('')

3.3 add the folder to the command:

pyinstaller --hiddenimport pywt._extensions._cwt --additional-hooks-dir=./hooks

3 You can also exclude large unused packages to reduce .exe file size:

pyinstaller --hiddenimport pywt._extensions._cwt --additional-hooks-dir=./hooks --exclude-module matplotlib --exclude-module PyQt5
  1. If you want to make it really one file you can add --onefile to the command

HI mmisiur,

I have been trying to run pytorch as well as an exe and the executable gives me the following error:

File “site-packages\flask\”, line 2447, in wsgi_app
File “site-packages\flask\”, line 1952, in full_dispatch_request
File “site-packages\flask\”, line 1821, in handle_user_exception
File “site-packages\”, line 39, in reraise
File “site-packages\flask\”, line 1950, in full_dispatch_request
File “site-packages\flask\”, line 1936, in dispatch_request
File “pytorchVizTool\flaskr\”, line 95, in GeneratePredsForFile
File “pytorchVizTool\flaskr\”, line 95, in
File “pytorchVizTool\flaskr\”, line 100, in predict
File “pytorchVizTool\flaskr\”, line 142, in get_bounding_box_prediction
File “site-packages\torch\nn\modules\”, line 550, in call
File “site-packages\torchvision\models\detection\”, line 70, in forward
File “site-packages\torch\nn\modules\”, line 550, in call
File “site-packages\torchvision\models\detection\”, line 488, in forward
File “site-packages\torchvision\models\detection\”, line 410, in filter_proposals
File “site-packages\torchvision\ops\”, line 75, in batched_nms
File “site-packages\torchvision\ops\”, line 35, in nms
File “site-packages\”, line 61, in getattr
RuntimeError: No such operator torchvision::nms

do you have any idea how i could fix this