Skip to content

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

@hiyamgh

Description

@hiyamgh

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions