codedecde / Luna2016-Lung-Nodule-Detection

Course Project for Bio Medical Imaging: Detecting Lung Nodules from CT Scans
MIT License
49 stars 29 forks source link

Error when training the U-Net model #3

Closed hiroshiperera closed 6 years ago

hiroshiperera commented 6 years ago

Hi I got the following error when trying to implement your code. Do you have any idea on how to solve this. Thanks in advance

Traceback (most recent call last): File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 468, in make_tensor_proto str_values = [compat.as_bytes(x) for x in proto_values] File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 468, in str_values = [compat.as_bytes(x) for x in proto_values] File "C:\Python35\lib\site-packages\tensorflow\python\util\compat.py", line 65, in as_bytes (bytes_or_text,)) TypeError: Expected binary or unicode string, got test

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\hiros\Desktop\u-net\Luna2016-Lung-Nodule-Detection-master\Luna2016-Lung-Nodule-Detection-master\UNET\Code\LUNA_unet.py", line 216, in model = train(False) File "C:\Users\hiros\Desktop\u-net\Luna2016-Lung-Nodule-Detection-master\Luna2016-Lung-Nodule-Detection-master\UNET\Code\LUNA_unet.py", line 203, in train accuracy = Accuracy(copy.deepcopy(imgs_test),copy.deepcopy(imgs_mask_test_true)) File "C:\Users\hiros\Desktop\u-net\Luna2016-Lung-Nodule-Detection-master\Luna2016-Lung-Nodule-Detection-master\UNET\Code\LUNA_unet.py", line 162, in init dc = dice_coef(test,pred) File "C:\Users\hiros\Desktop\u-net\Luna2016-Lung-Nodule-Detection-master\Luna2016-Lung-Nodule-Detection-master\UNET\Code\LUNA_unet.py", line 54, in dice_coef y_true = K.flatten(y_true) File "C:\Python35\lib\site-packages\keras\backend\tensorflow_backend.py", line 2106, in flatten return tf.reshape(x, [-1]) File "C:\Python35\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 3937, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 513, in _apply_op_helper raise err File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper preferred_dtype=default_dtype) File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 926, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 229, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "C:\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 208, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 472, in make_tensor_proto "supported type." % (type(values), values)) TypeError: Failed to convert object of type <class 'theano.tensor.var.TensorVariable'> to Tensor. Contents: test. Consider casting elements to a supported type.

Above that I'm getting the following output

Loading the options .... epochs: 500 batch_size: 2 filter_width: 3 stride: 3 learning rate: 0.001000

Loading and preprocessing train data...


Creating and compiling model...

Namespace(batch_size=2, epochs=500, filter_width=3, load_weights=False, lr=0.001, model_file='', out_dir='C:/Users/hiros/Desktop/u-net/Luna2016-Lung-Nodule-Detection-master/Luna2016-Lung-Nodule-Detection-master/DATA_PROCESS/scratch/cse/dual/cs5130287/Luna2016/output_final/', saveprefix='model', stride=3)


Layer (type) Output Shape Param # Connected to

input_1 (InputLayer) (None, 1, 512, 512) 0


conv2d_1 (Conv2D) (None, 32, 512, 512) 320 input_1[0][0]


dropout_1 (Dropout) (None, 32, 512, 512) 0 conv2d_1[0][0]


conv_1 (Conv2D) (None, 32, 512, 512) 9248 dropout_1[0][0]


pool_1 (MaxPooling2D) (None, 32, 256, 256) 0 conv_1[0][0]


batch_normalization_1 (BatchNor (None, 32, 256, 256) 1024 pool_1[0][0]


conv2d_2 (Conv2D) (None, 64, 256, 256) 18496 batch_normalization_1[0][0]


dropout_2 (Dropout) (None, 64, 256, 256) 0 conv2d_2[0][0]


conv_2 (Conv2D) (None, 64, 256, 256) 36928 dropout_2[0][0]


pool_2 (MaxPooling2D) (None, 64, 128, 128) 0 conv_2[0][0]


batch_normalization_2 (BatchNor (None, 64, 128, 128) 512 pool_2[0][0]


conv2d_3 (Conv2D) (None, 128, 128, 128 73856 batch_normalization_2[0][0]


dropout_3 (Dropout) (None, 128, 128, 128 0 conv2d_3[0][0]


conv_3 (Conv2D) (None, 128, 128, 128 147584 dropout_3[0][0]


pool_3 (MaxPooling2D) (None, 128, 64, 64) 0 conv_3[0][0]


batch_normalization_3 (BatchNor (None, 128, 64, 64) 256 pool_3[0][0]


conv2d_4 (Conv2D) (None, 256, 64, 64) 295168 batch_normalization_3[0][0]


dropout_4 (Dropout) (None, 256, 64, 64) 0 conv2d_4[0][0]


conv_4 (Conv2D) (None, 256, 64, 64) 590080 dropout_4[0][0]


batch_normalization_4 (BatchNor (None, 256, 64, 64) 256 conv_4[0][0]


up_sampling2d_1 (UpSampling2D) (None, 256, 128, 128 0 batch_normalization_4[0][0]


concatenate_1 (Concatenate) (None, 384, 128, 128 0 up_sampling2d_1[0][0]
conv_3[0][0]


conv2d_5 (Conv2D) (None, 128, 128, 128 442496 concatenate_1[0][0]


dropout_5 (Dropout) (None, 128, 128, 128 0 conv2d_5[0][0]


conv_7 (Conv2D) (None, 128, 128, 128 147584 dropout_5[0][0]


batch_normalization_5 (BatchNor (None, 128, 128, 128 512 conv_7[0][0]


up_sampling2d_2 (UpSampling2D) (None, 128, 256, 256 0 batch_normalization_5[0][0]


concatenate_2 (Concatenate) (None, 192, 256, 256 0 up_sampling2d_2[0][0]
conv_2[0][0]


conv2d_6 (Conv2D) (None, 64, 256, 256) 110656 concatenate_2[0][0]


dropout_6 (Dropout) (None, 64, 256, 256) 0 conv2d_6[0][0]


conv_8 (Conv2D) (None, 64, 256, 256) 36928 dropout_6[0][0]


batch_normalization_6 (BatchNor (None, 64, 256, 256) 1024 conv_8[0][0]


up_sampling2d_3 (UpSampling2D) (None, 64, 512, 512) 0 batch_normalization_6[0][0]


concatenate_3 (Concatenate) (None, 96, 512, 512) 0 up_sampling2d_3[0][0]
conv_1[0][0]


conv2d_7 (Conv2D) (None, 32, 512, 512) 27680 concatenate_3[0][0]


dropout_7 (Dropout) (None, 32, 512, 512) 0 conv2d_7[0][0]


conv_9 (Conv2D) (None, 32, 512, 512) 9248 dropout_7[0][0]


batch_normalization_7 (BatchNor (None, 32, 512, 512) 2048 conv_9[0][0]


sigmoid (Conv2D) (None, 1, 512, 512) 33 batch_normalization_7[0][0]

Total params: 1,951,937 Trainable params: 1,949,121 Non-trainable params: 2,816

dyther commented 6 years ago

I also got this error ,and I comment out Accuracy to solve it. And I'm curious about how you solve it?

Akhiladdh commented 5 years ago

@hiroshiperera were you able to resolve the issue?