Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use pyinstaller with QReader #7

Closed
filszyp opened this issue Feb 3, 2023 · 2 comments
Closed

Unable to use pyinstaller with QReader #7

filszyp opened this issue Feb 3, 2023 · 2 comments

Comments

@filszyp
Copy link

filszyp commented Feb 3, 2023

Hi, I found QReader to be the best solution to catch hard to read QR codes, now I can't live without it.
The problem is I tried tu use pyinstaller with it but no success. I use Python 3.9 on Windows 10. My example code is:

main.py


import cv2
import qreader
imgread = cv2.imread('imgqr.png')
det = qreader.QReader().detect_and_decode(image=imgread)
print(det)

It works with no issues inside PyCharm, but when I try to run the exe made with pyinstaller I get this:

C:\Users\Filip\PycharmProjects\testpyinstallqr\dist\main>main.exe
torchvision\io\image.py:13: UserWarning: Failed to load image Python extension:
torch\_jit_internal.py:839: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x000001EEE768F550>.
  warnings.warn(
torch\_jit_internal.py:839: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x000001EEE768F790>.
  warnings.warn(
Downloading weights...: 100%|████████████████████████████████| 74.8M/74.8M [00:08<00:00, 8.94MiB/s]
Traceback (most recent call last):
  File "main.py", line 14, in <module>
  File "qreader.py", line 26, in __init__
  File "qrdet.py", line 27, in __init__
  File "yolov7_package\model_utils.py", line 147, in __init__
  File "yolov7_package\models\experimental.py", line 242, in attempt_load
  File "torch\serialization.py", line 789, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "torch\serialization.py", line 1131, in _load
    result = unpickler.load()
  File "torch\serialization.py", line 1124, in find_class
    return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'models'
[1940] Failed to execute script 'main' due to unhandled exception!

I'm a beginner so every help would be greatly appreciated!

@Eric-Canas
Copy link
Owner

Hi @filszyp!

I have been doing a bit of research and it seems that it seems that there is more people dealing with problems when using Pytorch together with Pyinstaller. (Pytorch is the Deep Learning library that implements the architecture of the YoloV7 model trained to detect QRs). If you google Pytorch with Pyinstaller there are a lot of forums that could offer some help with that problem.

Anyway, I'll make some research on my side and I will let you know if I find something that could help.

Thanks a lot for using QReader! It was a very small project I developed to solve some problems I had when reading difficult QRs, and that's amazing to see people building tools with it! In the following weeks I will try to find and solve that kind of problems that some people are facing when integrating it with different frameworks, and I will probably train a new model to make it more robust against difficult situations.

@filszyp
Copy link
Author

filszyp commented Feb 3, 2023

Thanks for a quick reply!
I found this article which might be useful. yolov5 issue 353
I don't understand half of it but it seems to describe a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants