JaidedAI / EasyOCR

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://www.jaided.ai
Apache License 2.0
23.72k stars 3.11k forks source link

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

Closed chat9780 closed 4 years ago

chat9780 commented 4 years ago

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 commented 4 years ago

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

rkcosmos commented 4 years ago

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.

chat9780 commented 4 years ago

Got it now. THANKS!