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

Downloading weights library in real time #21

Closed
utkarsh-vijay opened this issue Mar 11, 2024 · 5 comments
Closed

Downloading weights library in real time #21

utkarsh-vijay opened this issue Mar 11, 2024 · 5 comments

Comments

@utkarsh-vijay
Copy link

This is a issue while using AWS lambda as it doesn't allow write permissions on /var/lang/lib/python3.11/site-packages/qrdet/.model'. Can we change the directory of download to a custom path? Like i want to change it to /tmp
[Errno 30] Read-only file system: '/var/lang/lib/python3.11/site-packages/qrdet/.model'

@sam-30
Copy link

sam-30 commented May 9, 2024

This issue will have to be fixed in qrdet. I believe it's an easy fix. I'll spin up a pull request on that repository.

@sam-30
Copy link

sam-30 commented May 9, 2024

Issue in qrdet. Comments welcomed on my proposed solution there.

@Eric-Canas
Copy link
Owner

Hi @sam-30 !

Thanks a lot! Answered there!

@pibahamondesw
Copy link

pibahamondesw commented Jun 7, 2024

I'm having the same issue in case you came up with a solution, I figured I could run a short test like this one to make sure that my image downloaded the weights first:

test_qreader.py

import cv2 as cv
from qreader import QReader

def test_qreader():
    qreader = QReader()
    image = "test.png"
    image = cv.imread(image)
    decoded_text = qreader.detect_and_decode(image=image)
    assert decoded_text[0] == "https://www.example.com"

if __name__ == "__main__":
    test_qreader()

Dockerfile

FROM public.ecr.aws/...
#####
# All my code to prepare the lambda function
#####

# Predownload weights for model
ADD test.png /tmp/test.png
ADD test_qreader.py /tmp/test_qreader.py
RUN cd /tmp && python /tmp/test_qreader.py
RUN rm /tmp/test.png /tmp/test_qreader.py

CMD [ "lambda_function.handler" ]

By the way, test.png is just a QRCode I generated with the URL "https://www.example.com".

Let me know if you implement a more robust solution!

@Eric-Canas
Copy link
Owner

Hi!

Just solved, now there is a new parameter in the constructor called weights_folder. If you have problems with writing on the default folder, you can instantiate QReader as QReader(weights_folder='/tmp') to make sure the model is downloaded and readed from there.

It should work if you pip install --upgrade qreader

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

4 participants