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

Could not load meta information for optimum pipe #5

Open
ljollans opened this issue May 5, 2020 · 8 comments
Open

Could not load meta information for optimum pipe #5

ljollans opened this issue May 5, 2020 · 8 comments

Comments

@ljollans
Copy link

ljollans commented May 5, 2020

I am trying to use a model I was given by a colleague but keep coming up against an error finding base.PhotonBase.

Here is the code I ran:

from photonai.base import Hyperpipe
best_model_file = 'mymodel.photon'
my_model = Hyperpipe.load_optimum_pipe(best_model_file)

where mymodel.photon sits in a folder that also includes a "photon_best_model" folder with __optimum_pipe_0_SimpleImputer.pkl, _optimum_pipe_1_StandardScaler.pkl, _optimum_pipe_2_Ridge.pkl, and optimum_pipe_blueprint.pkl'
I requested these files from my colleague because the errors I was getting indicated they needed to be there to load the model.

Running this I get the following error:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. defaults = yaml.load(f) /Users/lee_jollans/anaconda3/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+. warnings.warn(msg, category=FutureWarning) Could not load meta information for optimum pipe Traceback (most recent call last): File "tryphoton.py", line 10, in <module> my_model = Hyperpipe.load_optimum_pipe(best_model_file) File "/Users/lee_jollans/anaconda3/lib/python3.7/site-packages/photonai/base/hyperpipe.py", line 1105, in load_optimum_pipe return PhotonModelPersistor.load_optimum_pipe(file, password) File "/Users/lee_jollans/anaconda3/lib/python3.7/site-packages/photonai/base/hyperpipe.py", line 1444, in load_optimum_pipe element_list = PhotonModelPersistor.load_elements(folder=load_folder) File "/Users/lee_jollans/anaconda3/lib/python3.7/site-packages/photonai/base/hyperpipe.py", line 1410, in load_elements loaded_pipeline_element = joblib.load(os.path.join(folder, element_info['filename'] + '.pkl')) File "/Users/lee_jollans/anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 605, in load obj = _unpickle(fobj, filename, mmap_mode) File "/Users/lee_jollans/anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 529, in _unpickle obj = unpickler.load() File "/Users/lee_jollans/anaconda3/lib/python3.7/pickle.py", line 1085, in load dispatch[key[0]](self) File "/Users/lee_jollans/anaconda3/lib/python3.7/pickle.py", line 1373, in load_global klass = self.find_class(module, name) File "/Users/lee_jollans/anaconda3/lib/python3.7/pickle.py", line 1423, in find_class __import__(module, level=0) ModuleNotFoundError: No module named 'photonai.base.PhotonBase'

My colleague had originally noted that Hyperpipe is imported using from photonai.base.PhotonBase import Hyperpipe, which also did not work because I got the PhotonBase error.

Note, I am running macOS Mojave and python 3.7.3

Any help is greatly appreciated!

@RLeenings
Copy link
Collaborator

Dear ljollans,

sorry for the inconvencience.
We think this might be a version conflict as we recently put a lot of effort in the maintenance and improvement of PHOTON. It seems you're version is newer than your colleagues. We therefore suggest the following procedure:

Model Recreation

Please ask you're colleague to do

  1. pip uninstall photonai
  2. pip install git+https://www.github.com/photon-team/photon
  3. Retrain the model.
  4. Give you the new .photon file

Model Usage

  1. pip uninstall photonai
  2. pip install git+https://www.github.com/photon-team/photon
    3.Retry: my_model = Hyperpipe.load_optimum_pipe(best_model_file)

Again, sorry for any inconvenience and don't hesitate to write again, so that we can help you solve any issues.
Ramona

@RDoerfel
Copy link

RDoerfel commented Apr 8, 2022

Hi, I'm running into a similar issue. Apparently, I'm running a newer version. However, re-training is definitely not an option. Is there a possibility to downgrade to a specific version?

@RLeenings
Copy link
Collaborator

RLeenings commented Apr 11, 2022

Dear @RDoerfel ,
could you ask your colleagues to run
pip show photonai
The version should be shown in the output. Then you can install the corresponding version (e.g. 2.2.0) by
pip install photonai==2.2.0

@RDoerfel
Copy link

Thank's a lot. Is there also a way to figure out the version a model was build with?

@RLeenings
Copy link
Collaborator

RLeenings commented Apr 13, 2022

Unzip the model file.
Then in a Python Console do:

`import pickle

data = pickle.load(open('/path_to_extracted_model/photon_best_model/_optimum_pipe_meta.pkl', 'rb'))

print(data)`

This should give you the version, e.g. {'photon_version': '2.2.0'}

@RDoerfel
Copy link

Hi @RLeenings, apparently, there is no file named _optimum_pipe_meta. Following files are available:

  • _optimum_pipe_0_SimpleImputer.pkl
  • _optimum_pipe_1_StandardScaler.pkl
  • _optimum_pipe_2_Ridge.pkl
  • _optimum_pipe_blueprint.pkl

@RLeenings
Copy link
Collaborator

Dear @RDoerfel ,
I see, obviously, we added the information about the software version in a later release.
As I know your concern, I am quite confident that the version you are looking for is 2.0.0.

@RDoerfel
Copy link

Thanks a lot @RLeenings, I'll try to use this version as soon as possible and come back if there are any issues. Thank's for the support :)

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

3 participants