PSPNet-Keras-tensorflow icon indicating copy to clipboard operation
PSPNet-Keras-tensorflow copied to clipboard

from keras.backend import tf as ktf

Open aliericcantona opened this issue 7 years ago • 10 comments

from keras.backend import tf as ktf fails on keras.version = 2.0.8 therefore the interpolation layer gives an error.

Any solution?

aliericcantona avatar Nov 14 '17 22:11 aliericcantona

I have met the same problem. My solution is to not activate tensorflow in the terminal, i.e., not use "source activate tensorflow". Just use "python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg", it will work.

cardwing avatar Nov 26 '17 07:11 cardwing

@cardwing what do you mean activate tf in the terminal? I guess it is to import tf in the python shell? @aliericcantona Can you please provide some logs or error stack, as well as packages version

Vladkryvoruchko avatar Nov 26 '17 10:11 Vladkryvoruchko

@Vladkryvoruchko i am running the same issue as @aliericcantona i install this whole package in amazon EC2 machine, which has Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1022-aws x86_64v)

and in terminal, i put command "source activate tensorflow_p36" to have the TensorFlow(+Keras2) with Python3 (CUDA 8) enviroment.

then i run python pspnet.py -m pspnet101_voc2012 -i example_images/pascal_voc.jpg -o example_results/pascal_voc.jpg

then i get the below error:

/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. /home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6 return f(*args, **kwds) 2018-01-19 07:39:58.963310: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2018-01-19 07:39:59.046386: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-01-19 07:39:59.046732: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235 pciBusID: 0000:00:1e.0 totalMemory: 11.17GiB freeMemory: 11.10GiB 2018-01-19 07:39:59.046769: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7) Namespace(flip=False, id='0', input_path='example_images/pascal_voc.jpg', model='pspnet101_voc2012', multi_scale=False, output_path='our_example_results/pascal_voc.jpg', sliding=False) Keras model & weights found, loading... XXX lineno: 18, opcode: 0 Traceback (most recent call last): File "pspnet.py", line 270, in weights=args.model) File "pspnet.py", line 149, in init input_shape=input_shape, weights=weights) File "pspnet.py", line 41, in init self.model = model_from_json(file_handle.read()) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/models.py", line 349, in model_from_json return layer_module.deserialize(config, custom_objects=custom_objects) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 143, in deserialize_keras_object list(custom_objects.items()))) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 2517, in from_config process_node(layer, node_data) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 2474, in process_node layer(input_tensors[0], **kwargs) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 617, in call output = self.call(inputs, **kwargs) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/layers/core.py", line 663, in call return self.function(inputs, **arguments) File "/media/tatsch/DataSSD1/workspace/PSPNet-Keras-tensorflow/pspnet/layers_builder.py", line 18, in Interp new_height, new_width = shape SystemError: unknown opcode

how can i fix it? Thanks!

qiuyinglin avatar Jan 19 '18 07:01 qiuyinglin

@Vladkryvoruchko , not use tf in the terminal is just not execute "source activate tensorflow". Just use "python file_name.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg" should work.

cardwing avatar Jan 21 '18 13:01 cardwing

Apparently this issue is caused by the marshal serial format having changed a bit between Python 3.5 and 3.6 as discovered in https://github.com/keras-team/keras/issues/9595 . Converting the weights from numpy with python 3.6 should work around it.

jmtatsch avatar Mar 18 '18 09:03 jmtatsch

I have met the same problem. I use python 3.5 and tensorflow-gpu 1.14.0. I don't understand "not use tf in the terminal is just not execute "source activate tensorflow"" from @cardwing. how can i fix it?

shokohigol avatar Aug 27 '19 07:08 shokohigol

Just use "python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg".

cardwing avatar Aug 27 '19 08:08 cardwing

@cardwing Could you please be clearer? The README.md asks us to run the file just the way you have mentioned. What does don't activate tensorflow in terminal mean?

raghuram-kukun avatar Aug 28 '19 12:08 raghuram-kukun

from keras.backend.tensorflow_backend import tf as ktf for keras 2.3.1

nicpho avatar Mar 21 '20 03:03 nicpho

im having the same issue. tensorflow-gpu 2.4 or 2.3 not sure and keras 2.4.3 from keras.backend.tensorflow_backend import tf as ktf doesn't work either ps: tf.keras.backend worked on my system move the tensorflow import to the upper line

mobiiin avatar Feb 21 '21 14:02 mobiiin