ocropus-archive / DUP-ocropy

Python-based tools for document analysis and OCR
Apache License 2.0
3.42k stars 591 forks source link

EOF error with cpickle.Unpickler in common.py #335

Open hiyamgh opened 4 years ago

hiyamgh commented 4 years ago

I am trying to run the very basic example found in the README file.

I reached the following line:

./ocropus-rpred -Q 4 -m models/fraktur.pyrnn.gz 'book/0001/010001.bin.png'

But it gives me the following error:

INFO:
INFO:  ########## ./ocropus-rpred -Q 4 -m models/fraktur.pyrnn.gz book/0001/01
INFO:
INFO:  #inputs: 1
# loading object .\.\models/fraktur.pyrnn.gz
Traceback (most recent call last):
  File "./ocropus-rpred", line 120, in <module>
    network = ocrolib.load_object(args.model,verbose=1)
  File "C:\Users\96171\Desktop\ocropy\ocrolib\common.py", line 445, in load_object
    return unpickler.load()
EOFError

The error is appearing in the following function from common.py:

def load_object(fname,zip=0,nofind=0,verbose=0):
    """Loads an object from disk. By default, this handles zipped files
    and searches in the usual places for OCRopus. It also handles some
    class names that have changed."""
    if not nofind:
        fname = ocropus_find_file(fname)
    if verbose:
        print("# loading object", fname)
    if zip==0 and fname.endswith(".gz"):
        zip = 1
    if zip>0:
        # with gzip.GzipFile(fname,"rb") as stream:
        with os.popen("gunzip < '%s'"%fname,"rb") as stream:
            unpickler = cPickle.Unpickler(stream)
            unpickler.find_global = unpickle_find_global
            return unpickler.load()
    else:
        with open(fname,"rb") as stream:
            unpickler = cPickle.Unpickler(stream)
            unpickler.find_global = unpickle_find_global
            return unpickler.load()
kba commented 4 years ago

Assuming models/fraktur.pyrnn.gz is http://tmbdev.net/ocropy/fraktur.pyrnn.gz - could it be corrupt?

sha256sum models/fraktur.pyrnn.gzz

should be 0b79c3486c9060168b9bb6314f04eb7fd541b30a48c21033ad8fc6906cdf9cf2.

lxc1851588 commented 1 year ago

Seems it isn't corrupted. I met the same problem.