I've created program that uses lib rembg with included u2net.onnx(u2net.onnx in rembg library) to delete backgrounds. I can compile program without problems with PyInstaller, but with Nuitka there a lot of problems. I am using this command:
nuitka --standalone --onefile --follow-imports --enable-plugin=tk-inter --include-plugin-directory="myenv\Lib\site-packages\rembg\u2net.onnx" --windows-icon-from-ico=icon.ico main.py
After running program and choosing files to remove backgrounds it gives me this error: Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\tkinter\__init__.py", line 1921, in __call__
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\main.py", line 57, in remove_background
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\rembg\bg.py", line 132, in remove
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\rembg\session_factory.py", line 35, in new_session
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\onnxruntime\capi\onnxruntime_inference_collection.py", line 347, in __init__
File "C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\onnxruntime\capi\onnxruntime_inference_collection.py", line 384, in _create_inference_session
onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [ONNXRuntimeError] : 3 : NO_SUCHFILE : Load model from C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\rembg\u2net.onnx failed:Load model C:\Users\roka\Desktop\pythob\PYTHON~1\MAIN~1.DIS\rembg\u2net.onnx failed. File doesn't exist
I've tried using --include-plugin-directory="myenv\Lib\site-packages\rembg\u2net.onnx" , --include-data-dir(gives error that I can't use that for some reason), using PyInstaller(worked well, but I need to use Nuitka), moving u2net.onnx to the file compilated directory
I've solve this problem myself, so rembg have some files that unnable to fully compile using nuitka or pyinstaller. To solve this I have downloaded rembg avg-lambda(it contains u2net.onnx that was needed to work) and used --include-data-dir to go directly to rembg folder and just copy all of it.