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

Cannot run sample code - TypeError: 'bool' object is not callable #26

Closed
chat9780 opened this issue Jul 3, 2020 · 3 comments
Closed

Comments

@chat9780
Copy link

chat9780 commented Jul 3, 2020

Code

import easyocr
reader = easyocr.Reader(['th','en'])
text = reader.readtext('abc.jpg')
print(text)

Console Output

% python3 mytest.py
Traceback (most recent call last):
  File "mytest.py", line 2, in <module>
    reader = easyocr.Reader(['th','en'])
  File "/usr/local/lib/python3.7/site-packages/easyocr/easyocr.py", line 166, in __init__
    self.detector = get_detector(DETECTOR_PATH, self.device)
  File "/usr/local/lib/python3.7/site-packages/easyocr/detection.py", line 61, in get_detector
    net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device)))
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 773, in _legacy_load
    result = unpickler.load()
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 729, in persistent_load
    deserialized_objects[root_key] = restore_location(obj, location)
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 814, in restore_location
    result = map_location(storage, location)
TypeError: 'bool' object is not callable
@turtle0x1
Copy link

Add a GPU or disable GPU (in read me) it would appear fixes this!

@rkcosmos
Copy link
Contributor

rkcosmos commented Jul 3, 2020

I guess you are running a computer without GPU. Try

reader = easyocr.Reader(['th','en'], gpu = False)

I just accept a PR to fix this. If you update to current version, the library will automatically use CPU when you don't have GPU.

@rkcosmos rkcosmos closed this as completed Jul 3, 2020
@chat9780
Copy link
Author

chat9780 commented Jul 3, 2020

Got it now. THANKS!

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

3 participants