conscienceli / SeqNet

Joint Learning of Vessel Segmentation and Artery/Vein Classification
https://www.liangzhili.com/publication/li-2020-joint/
MIT License
60 stars 22 forks source link

ValueError: Graph disconnected: cannot obtain value for tensor #4

Open kestrel614 opened 4 years ago

kestrel614 commented 4 years ago

Hi,

I tried to perform prediction by giving the command (the test image was under ./data/test_images/):

python predict.py -i ./data/test_images/ -o ./output/

And encountered the following error message:

Traceback (most recent call last):
  File "predict.py", line 136, in <module>
    predict(batch_size=24, epochs=200, iteration=3, stride_size=3, crop_size=128, 
  File "predict.py", line 36, in predict
    model = define_model.get_unet(minimum_kernel=minimum_kernel, do=dropout, activation=activation, iteration=iteration)
  File "/.../SeqNet-master/utils/define_model.py", line 379, in get_unet
    model = Model(inputs=[inputs], outputs=outs)
  File "/.../opt/anaconda3/envs/opencv4/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 167, in __init__
    super(Model, self).__init__(*args, **kwargs)
  File "/.../opt/anaconda3/envs/opencv4/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 173, in __init__
    self._init_graph_network(*args, **kwargs)
  File "/.../opt/anaconda3/envs/opencv4/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 456, in _method_wrapper
    result = method(self, *args, **kwargs)
  File "/.../opt/anaconda3/envs/opencv4/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 306, in _init_graph_network
    nodes, nodes_by_depth, layers, _ = _map_graph_network(
  File "/.../opt/anaconda3/envs/opencv4/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 1787, in _map_graph_network
    raise ValueError('Graph disconnected: '
ValueError: Graph disconnected: cannot obtain value for tensor Tensor("dropout_19_1/Identity:0", shape=(None, None, None, 32), dtype=float32) at layer "concatenate_4". The following previous layers were accessed without issue: ['input_1', 'conv2d', 're_lu', 'dropout', 'conv2d_1', 're_lu_1', 'dropout_1', 'max_pooling2d', 'conv2d_2', 're_lu_2', 'dropout_2', 'conv2d_3', 're_lu_3', 'dropout_3', 'max_pooling2d_1', 'conv2d_4', 're_lu_4', 'dropout_4', 'conv2d_5', 're_lu_5', 'dropout_5', 'max_pooling2d_2', 'conv2d_6', 're_lu_6', 'dropout_6', 'conv2d_7', 're_lu_7', 'dropout_7', 'max_pooling2d_3', 'conv2d_8', 're_lu_8', 'dropout_8', 'conv2d_9', 're_lu_9', 'dropout_9', 'conv2d_transpose', 'concatenate', 'conv2d_10', 're_lu_10', 'dropout_10', 'conv2d_11', 're_lu_11', 'dropout_11', 'conv2d_transpose_1', 'concatenate_1', 'conv2d_12', 're_lu_12', 'dropout_12', 'conv2d_13', 're_lu_13', 'dropout_13', 'conv2d_transpose_2', 'concatenate_2', 'conv2d_14', 're_lu_14', 'dropout_14', 'conv2d_15', 're_lu_15', 'dropout_15', 'conv2d_transpose_3', 'concatenate_3', 'conv2d_16', 're_lu_16', 'dropout_16', 'conv2d_17', 're_lu_17', 'dropout_17', 'conv2d_18', 're_lu_18', 'dropout_18', 'conv2d_19', 're_lu_19', 'dropout_19']

I had to modify certain lines in predict.py like config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True)) due to compatibility issues but I guess that is irrelevant to the error. Apart from that all the codes stayed the same.

Could you please look into this? Thank you in advance for your help.

puyiwen commented 4 years ago

hi, did you run through this code?

kestrel614 commented 4 years ago

Yes the error messages were returned when I ran python predict.py -i ./data/test_images/ -o ./output/. I only replaced my machine name in the paths.

I modified certain lines in predict.py to circumvent compatibility issues:

5c5
< # from keras.backend import tensorflow_backend
---
> from keras.backend import tensorflow_backend
104,107c104,107
<     config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True))
<     session = tf.compat.v1.Session(config=config)
<     tf.compat.v1.keras.backend.set_session(session)
<     # tensorflow_backend.set_session(session)
---
>     config = tf.ConfigProto(gpu_options=tf.GPUOptions(allow_growth=True))
>     session = tf.Session(config=config)
>     tensorflow_backend.set_session(session)
> 

And all the other codes stayed the same.

puyiwen commented 4 years ago

May I know how you merged these three data sets?Thank you!!

kestrel614 commented 4 years ago

Thank you for your reply. I tried to perform a prediction on an image (./data/test_images/test.jpg) using your pre-trained weights (I downloaded it and put it under ./trained_model/ALL/). I did not re-train a model so I guess the three data sets are not involved?

I think the error occurred at define_model.get_unet, which was regarding the definition of CNN layers, and before loading weights and input images.

puyiwen commented 4 years ago

I got it ,and thank you once again

kestrel614 commented 4 years ago

You are welcome -- it should be me thanking you lol. Please let me know if this problem could be fixed. Thanks again!

conscienceli commented 4 years ago

Hi! I am one of the authors of the SeqNet. I think this problem may be caused by compatibility issues. In our server, we are using keras=2.3.1 and tensorflow=1.15.0. And please check the requirements file for the version of other packages. If this cannot fix this problem, please let me know. Thanks!