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

TypeError: inner() got an unexpected keyword argument 'image_context' #118

Closed
lizdotsh opened this issue Feb 17, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@lizdotsh
Copy link

Hello! Recently encountered an issue when trying to use Google's OCR when running ocr_agent.detect

Running this:

image = cv2.imread("/Users/liz/Documents/Projects/LayoutParser/test2.png")
ocr_agent = lp.GCVAgent.with_credential("/Users/liz/Documents/Projects/Keys/GoogleCloud/vision-341523-e3cbd0df8d19.json",languages = ['en'])
res = ocr_agent.detect(image, return_response=True)

Gives me the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-9-76614ef6a3e8> in <module>
      1 image = cv2.imread("/Users/liz/Documents/Projects/LayoutParser/test2.png")
      2 ocr_agent = lp.GCVAgent.with_credential("/Users/liz/Documents/Projects/Keys/GoogleCloud/vision-341523-e3cbd0df8d19.json",languages = ['en'])
----> 3 res = ocr_agent.detect(image, return_response=True)
      4 
      5 #layout = ocr_agent.gather_full_text_annotation(res, agg_level=lp.GCVFeatureType.WORD)

/opt/homebrew/Caskroom/miniforge/base/envs/data310/lib/python3.9/site-packages/layoutparser/ocr.py in detect(self, image, return_response, return_only_text, agg_output_level)
    222                 img_content = image_file.read()
    223 
--> 224         res = self._detect(img_content)
    225 
    226         if return_response:

/opt/homebrew/Caskroom/miniforge/base/envs/data310/lib/python3.9/site-packages/layoutparser/ocr.py in _detect(self, img_content)
    188     def _detect(self, img_content):
    189         img_content = self._vision.types.Image(content=img_content)
--> 190         response = self._client.document_text_detection(
    191             image=img_content, image_context=self._context
    192         )

TypeError: inner() got an unexpected keyword argument 'image_context'

Not sure what it is caused by, might be user error but I haven't been able to find anything else about it and I've tried everything I can think of (all the packages are up to date (or in google cloud vision's case, downgraded to stay on the old API). Thanks!

@lizdotsh lizdotsh added the bug Something isn't working label Feb 17, 2022
@lolipopshock
Copy link
Member

Sorry for taking a bit longer than usual to get back to your issue. Could you share the versions of the google cloud dependencies? You can try pip list | grep "google" and paste the results here. Thanks!

@lizdotsh
Copy link
Author

Sorry for taking a bit longer than usual to get back to your issue. Could you share the versions of the google cloud dependencies? You can try pip list | grep "google" and paste the results here. Thanks!

Sorry I'm not really sure exactly what I did differently but I ended up just making a new venv and it worked now. Was a while ago so not sure what I changed but ended up working fine and forgot to close the issue. If you want I can try and reproduce it again but the issue is resolved on my system at least. Thanks!

@lolipopshock
Copy link
Member

Sorry for taking a bit longer than usual to get back to your issue. Could you share the versions of the google cloud dependencies? You can try pip list | grep "google" and paste the results here. Thanks!

Sorry I'm not really sure exactly what I did differently but I ended up just making a new venv and it worked now. Was a while ago so not sure what I changed but ended up working fine and forgot to close the issue. If you want I can try and reproduce it again but the issue is resolved on my system at least. Thanks!

Great to know the issue is resolved! I suspect it's some google-library version issues but if you see that again feel free to re-open this issue and share the details here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants