Skip to content

Pickling errors for preprocess_input due to functools.wraps #154

Description

@ORippler

Hey,

executing the below minimum working example will error

import pickle

from efficientnet.keras import preprocess_input

with open("test.pkl", "wb") as fh:
    pickle.dump(preprocess_input, fh)

with
_pickle.PicklingError: Can't pickle <function preprocess_input at 0x7f1c565d94d0>: it's not the same object as efficientnet.model.preprocess_input.

Reason for this is that functools.wraps used to inject the preprocessing here per default updates the __module__ etc. of the wrapper function to look like the wrapped function, see here.
Quick and dirty solution is to set the __module__ property explicitly, but that is certainly not very elegant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions