For context, I am running an apple silicon mac and have used the rosetta terminal + miniconda to create a venv that runs python 3.7.
Here is the code I am trying to run.
from pixellib.instance import instance_segmentation
segment_image = instance_segmentation()
segment_image.load_model("mask_rcnn_coco.h5")
And this is the error below. I think it may be due to issues with the access to the GPU but I cannot be sure. Have been working on it for a few days.
If using Keras pass *_constraint arguments to layers.
Traceback (most recent call last):
File "/Users/USERNAME/PycharmProjects/test/main.py", line 16, in <module>
segment_image.load_model("mask_rcnn_coco.h5")
File "/Users/USERNAME/miniconda3/envs/cowsUpdate/lib/python3.7/site-packages/pixellib/instance/__init__.py", line 65, in load_model
self.model.load_weights(model_path, by_name= True)
File "/Users/USERNAME/miniconda3/envs/cowsUpdate/lib/python3.7/site-packages/pixellib/instance/mask_rcnn.py", line 2110, in load_weights
hdf5_format.load_weights_from_hdf5_group_by_name(f, layers)
File "/Users/USERNAME/miniconda3/envs/cowsUpdate/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 718, in load_weights_from_hdf5_group_by_name
original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'
I encountered similar issue when using tf.keras.models.load_weights(), and I downgrade h5py from 2.10 to 2.8.0 in tensorflow 2.0.0, then it works, maybe you can have a try.
Related
I will try to be as much help as I can, but this is certainly a bit out of my depth.
I am trying to run the metagenomics package 'DeepVirFinder' on my fasta file 'my_seqs.fa' within terminal on my Mac. I have followed the GitHub repository instructions (as found here https://github.com/jessieren/DeepVirFinder). I have created a conda environment with all the necessary packages.
Into my terminal I have inputted
python dvf.py -i ~/Documents/PairwiseANI/my_seqs.fna -o ~/Documents/DeepVirFinder/ -l 1000 -c 2
this receives an output error of
Using Theano backend.
1. Loading Models.
model directory /data2/joshcole/DeepVirFinder/models
Traceback (most recent call last):
File "dvf.py", line 131, in <module>
modDict[contigLengthk] = load_model(os.path.join(modDir, modName))
File "/home/ggb_joshcole/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/ggb_joshcole/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'
From the GitHub repository, what it should return upon a successful run (using example template names) is as follows:
Using Theano backend.
1. Loading Models.
model directory /auto/cmb-panasas2/renj/software/DeepVirFinder/models
2. Encoding and Predicting Sequences.
processing line 1
processing line 1389
3. Done. Thank you for using DeepVirFinder.
output in ./test/crAssphage.fa_gt300bp_dvfpred.txt
Any help for how to fix this error would be greatly appreciated. I have tried to download and jig around with potential conda fixes, but it doesn't appear to be a problem with any dependancies + python is fully up to date.
Thank you for reading
Apologies - I found out it was an error between h5py and tensorflow. Had to downgrade h5py to 2.10.0.
I'm trying to train an object detection model in Tensorflow 2. But since I went over to tensorflow 2 from 1 I seem to have problems. Whenever I start training. I get the same error shown in the following github thread https://github.com/tensorflow/models/issues/9706:
I have the same error if I use numpy 1.20.0 NotImplementedError:
Cannot convert a symbolic Tensor (cond_2/strided_slice:0) to a numpy
array.
if I use numpy 1.19.5 I get ValueError: numpy.ndarray size changed,
may indicate binary incompatibility. Expected 88 from C header, got 80
from PyObject
Tried with TF 2.2.2 as well in both cases same errors
The only difference is that when I change python to 3.6 I get the same output as the last error message(I'm also using anaconda):
Traceback (most recent call last): File "model_main_tf2.py", line 31,
in import tensorflow.compat.v2 as tf File
"D:\Maurice_Doc\AI\anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init_.py",
line 41, in from tensorflow.python.tools import module_util as
module_util File
"D:\Maurice_Doc\AI\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python_init.py",
line 39, in from tensorflow.python import pywrap_tensorflow as
_pywrap_tensorflow File "D:\Maurice_Doc\AI\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 83, in raise ImportError(msg) ImportError: Traceback (most recent
call last): File
"D:\Maurice_Doc\AI\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 64, in from tensorflow.python._pywrap_tensorflow_internal import
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I've followed the tutorial at:
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html
from start to finish and it worked when I was following the TensorFlow 1x tutorial but for some reason, since they switched to Tensorflow 2x I get a lot of issues.
Does anybody know how to fix this issue?
Please try using Python 3.6.
This fixed it for other users reporting the same Problem.
I followed these instructions
Specifically, I want to run a downloaded Tensorflow model from Github. I only have an Intel GPU on my computer, so I want to execute the Tensorflow model on my CPU. As described here on GitHub, it should be possible by setting the use-gpu parameter to false. So I run this command:
python test_model.py model=iphone_orig dped_dir=dped/ test_subset=full iteration=all resolution=orig use_gpu=false
However, I get the following error, the last two lines indicate that tensorflow tries to run on the GPU, this is the console window:
C:\Users\username\Downloads\DPED-master\DPED-master>python test_model.py model=iphone_orig dped_dir=dped/ test_subset=full iteration=all resolution=orig use_gpu=false
Traceback (most recent call last):
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\platform\self_check.py", line 62, in preload_check
ctypes.WinDLL(build_info.nvcuda_dll_name)
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Das angegebene Modul wurde nicht gefunden
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_model.py", line 5, in <module>
import tensorflow as tf
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
self_check.preload_check()
File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\platform\self_check.py", line 70, in preload_check
% build_info.nvcuda_dll_name)
ImportError: Could not find 'nvcuda.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Typically it is installed in 'C:\Windows\System32'. If it is not present, ensure that you have a CUDA-capable GPU with the correct driver installed.
You find the relevant test_model.py file here
I Tried several executions, with and without GPU setting. What can I do to fix it?
there are two module of tensorlfow:'tensorflow','tensorflow-gpu'
on cpu you need to install tensorlfow with pip install tensorflow or on conda conda install tensorflow
EDIT for second question:
If a TensorFlow operation is placed on the GPU, then the execution engine must have the GPU implementation of that operation, known as the kernel.
If the kernel is not present, then the placement results in a runtime error. Also, if the requested GPU device does not exist, then a runtime error is raised.
The best way to handle is to allow the operation to be placed on the CPU if requesting the GPU device results in an error.
One answer would be to remove all GPU configs and second would be soft placement if GPU is not found as explained above use config.allow_soft_placement = True
I am trying to go through a Tensorflow tutorial that uses tf.feature_column, however when running it I am encountered with this error.
I have tensorflow=1.12.0 installed. I am running it on Python 3.6.8.
This looks to be the most recent stable package of tensorflow and the docs say that Python 3.6 is supported. I have also checked the tensorflow package files and found that feature_column is included.
Any idea why this error is still persisting?
Full error:
Traceback (most recent call last):
File "tensorflow.py", line 1, in <module>
import tensorflow as tf
File "/Users/blakecarroll/SFInsuretech/virtEnv1/tensorflow.py", line 50, in <module>
categorical_object_feat_cols = [tf.feature_column.embedding_column(tf.feature_column.categorical_column_with_hash_bucket(key=col,hash_bucket_size=1000), dimension = len(df[col].unique())) for col in categorical_columns if df[col].dtype=='O']
File "/Users/blakecarroll/SFInsuretech/virtEnv1/tensorflow.py", line 50, in <listcomp>
categorical_object_feat_cols = [tf.feature_column.embedding_column(tf.feature_column.categorical_column_with_hash_bucket(key=col,hash_bucket_size=1000), dimension = len(df[col].unique())) for col in categorical_columns if df[col].dtype=='O']
AttributeError: module 'tensorflow' has no attribute 'feature_column'
This is happening because the name of your script is tensorflow.py, which makes import tensorflow as tf import your script itself. Rename your script into something else and this should be resolved.
i have recently been playing around with tensorflow object detection with GPU processor, and i have encountered an error when trying to train my model with custom images.The error tracestack is as follows:
WARNING:tensorflow:From C:\tensorflow1\models\research\object_detection\trainer.py:260: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
WARNING:tensorflow:num_readers has been reduced to 1 to match input file shards.
Traceback (most recent call last):
File "train.py", line 184, in <module>
tf.app.run()
File "C:\Users\Dan\AppData\Local\conda\conda\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
_sys.exit(main(argv))
File "train.py", line 180, in main
graph_hook_fn=graph_rewriter_fn)
File "C:\tensorflow1\models\research\object_detection\trainer.py", line 274, in train
train_config.prefetch_queue_capacity, data_augmentation_options)
File "C:\tensorflow1\models\research\object_detection\trainer.py", line 80, in create_input_queue
include_keypoints=include_keypoints))
File "C:\tensorflow1\models\research\object_detection\core\preprocessor.py", line 3147, in preprocess
(func.__name__))
ValueError: The function random_horizontal_flip does not exist in func_arg_map
I am using an Anaconda interpreter with Python 3.6, tio reproduce this error i followed all the steps in the link https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 .
The command which gave me this error was:
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
it is important to note i did not encounter any issues before training the model. I would be greatfull if someone could explain this error to me and even help me fix it, thanks in advance :-)
You might forget to add the below line to ~/.bashrc:
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim