jessieren / DeepVirFinder

Identifying viruses from metagenomic data by deep learning
Other
116 stars 32 forks source link

Test module falling after installation #38

Open geboro opened 2 years ago

geboro commented 2 years ago

DeepVirFinder isn't working in Ubuntu 20.04 after installing dependencies succesfully...

(dvf)$ python dvf.py -i ./test/crAssphage.fa -o ./test/ -l 300
Using Theano backend.
WARNING (theano.configdefaults): install mkl with `conda install mkl-service`: No module named 'mkl'
1. Loading Models.
   model directory /raw_data/DeepVirFinder/models
Traceback (most recent call last):
  File "dvf.py", line 131, in <module>
    modDict[contigLengthk] = load_model(os.path.join(modDir, modName))
  File "/opt/anaconda/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 419, in load_model
    model = _deserialize_model(f, custom_objects, compile)
  File "/opt/anaconda/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 224, in _deserialize_model
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

and after installing mkl-service...

(dvf) $ conda install mkl-service
(dvf) $ python3.6 dvf.py -i ./test/crAssphage.fa -o ./test/ -l 300
Using Theano backend.
1. Loading Models.
   model directory /soft/DeepVirFinder/models
Traceback (most recent call last):
  File "dvf.py", line 131, in <module>
    modDict[contigLengthk] = load_model(os.path.join(modDir, modName))
  File "/opt/anaconda/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 419, in load_model
    model = _deserialize_model(f, custom_objects, compile)
  File "/opt/anaconda/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 224, in _deserialize_model
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

Any idea of what's going on here?

dnolin13 commented 2 years ago

I am having the same issue!

(dvf) delaney@ada:~/software/DeepVirFinder$ ls dvf.py encode.py licence.md models README.md supplementary_tables test train_example training.py (dvf) delaney@ada:~/software/DeepVirFinder$ python dvf.py -i ./test/crAssphage.fa -o ./test/ -l 300 Using Theano backend. WARNING (theano.configdefaults): install mkl withconda install mkl-service`: No module named 'mkl'

  1. Loading Models. model directory /home/delaney/software/DeepVirFinder/models Traceback (most recent call last): File "dvf.py", line 131, in modDict[contigLengthk] = load_model(os.path.join(modDir, modName)) File "/home/delaney/miniconda3/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "/home/delaney/miniconda3/envs/dvf/lib/python3.6/site-packages/keras/engine/saving.py", line 224, in _deserialize_model model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' object has no attribute 'decode' (dvf) delaney@ada:~/software/DeepVirFinder$ `
TomasaSbaffi commented 2 years ago

I also have the same issue, I am trying to install the packages in different orders but with no actual rationale behind. It should be due to issues with dependencies: https://stackoverflow.com/questions/53740577/does-any-one-got-attributeerror-str-object-has-no-attribute-decode-whi

TomasaSbaffi commented 2 years ago

I solved it with the following:

conda activate dvf pip3 uninstall keras pip3 uninstall tensorflow pip3 uninstall h5py

pip3 install 'h5py==2.10.0' --force-reinstall pip3 install 'tensorflow==2.4.1' pip3 install 'keras==2.2.4'

I do believe the real problem for me was the version of TF, the older version installed with the instructions given was not working nor the new versions, but a middle ground version did work. h5py and keras are reinstalled as per instructions so I am not sure if uninstalling them and re installing them actually helped. I still do not know why but this worked fine for me. I hope it helps.

fluhus commented 1 year ago

Thanks @TomasaSbaffi, your response helped me solve the issue. Reinstalling h5py with the version you mentioned was enough in my case.

@jessieren perhaps the instructions for creating the conda env should be updated with h5py=2.10.0?

Edit: I can confirm that when I create the environment with conda create --name dvf numpy theano=1.0.3 keras=2.2.4 scikit-learn Biopython h5py=2.10.0 it works out of the box.