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

Pickling errors for preprocess_input due to functools.wraps #154

Open
ORippler opened this issue Jan 17, 2023 · 0 comments
Open

Pickling errors for preprocess_input due to functools.wraps #154

ORippler opened this issue Jan 17, 2023 · 0 comments

Comments

@ORippler
Copy link

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.

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

1 participant