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

Fix text-search model unpickling. #460

Open
stepan-anokhin opened this issue Feb 10, 2022 · 0 comments
Open

Fix text-search model unpickling. #460

stepan-anokhin opened this issue Feb 10, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@stepan-anokhin
Copy link
Collaborator

stepan-anokhin commented Feb 10, 2022

The Problem

When loading text-search model from winnow/text_search/models/model_best.pth.tar the following error occurs:

Traceback (most recent call last):
  File "/home/stepan/work/benetech/programs/anaconda/envs/winnow/lib/python3.6/site-packages/torch/serialization.py", line 608, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/stepan/work/benetech/programs/anaconda/envs/winnow/lib/python3.6/site-packages/torch/serialization.py", line 787, in _legacy_load
    result = unpickler.load()
ModuleNotFoundError: No module named 'configs'

Root Cause

The model is saved using pickle with different import paths (e.g. import configs instead of import winnow.text_search.configs). According to the pickle documentation:

pickle can save and restore class instances transparently, however the class definition must be importable and live in the same module as when the object was stored.

Possible Fix

See the following answer on StackOverflow: https://stackoverflow.com/a/2121918

@stepan-anokhin stepan-anokhin added bug Something isn't working python Pull requests that update Python code and removed python Pull requests that update Python code labels Feb 10, 2022
stepan-anokhin added a commit to stepan-anokhin/VideoDeduplication that referenced this issue Feb 10, 2022
The model is saved using pickle with different import paths
(e.g. `import configs` instead of import `winnow.text_search.configs`).
See benetech#460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant