costapt / vess2ret

A Keras implementation of pix2pix code adapted to generate retinal images from vessel networks.
MIT License
94 stars 42 forks source link

exception while running test.py #6

Open dreamflyer opened 7 years ago

dreamflyer commented 7 years ago
Using Theano backend.
TheanoShapedU-NET
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(512, strides=(1, 1), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(512, strides=(2, 2), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(256, strides=(2, 2), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(128, strides=(2, 2), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(64, strides=(2, 2), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
/Users/dreamflyer/Downloads/vess2ret/models.py:59: UserWarning: Update your `Conv2DTranspose` call to the Keras 2 API: `Conv2DTranspose(3, strides=(2, 2), data_format="channels_first", kernel_size=(2, 2))`
  **kwargs)
Traceback (most recent call last):
  File "/Users/dreamflyer/Downloads/vess2ret/test.py", line 138, in <module>
    target_size=(ts, ts), shuffle=False)
  File "/Users/dreamflyer/Downloads/vess2ret/util/data.py", line 82, in __init__
    self._load_imgs_to_memory()
  File "/Users/dreamflyer/Downloads/vess2ret/util/data.py", line 131, in _load_imgs_to_memory
    ai, bi = self._load_img_pair(idx, False)
  File "/Users/dreamflyer/Downloads/vess2ret/util/data.py", line 164, in _load_img_pair
    a = img_to_array(a, self.dim_ordering)
  File "/Users/dreamflyer/anaconda2/envs/keras/lib/python2.7/site-packages/keras/preprocessing/image.py", line 284, in img_to_array
    raise ValueError('Unknown data_format: ', data_format)
ValueError: ('Unknown data_format: ', 'default')

Process finished with exit code 1.

Looking at code, i see that only 'tf', 'th', or 'default' can be passed in img_to_array method as second argument, but method is expecting one of 'channels_first' or 'channels_last'. So it looks like it is shouldn't to work. May be i have wrong version of image.py? However, even after i manually specify 'channels_first' instead of self.dim_ordering in img_to_array call, and test.py runs without issues, i have strange result with weights that provided by reference in readme:

img_0

sample image for test was downloaded from demo that provided in readme.

what i am doing wrong? Also please note that i'm on Mac OS X Yosemite, and without GPU usage, may be thats the reason?

Also, can you please comment what this warnings are mean?

costapt commented 7 years ago

Hi. I am sorry, it looks like the Keras 2 version of the code has some issues still. I need to look at it more carefully.

The warning seems to be saying that the code is using the previous Keras API, which is deprecated.

Since the code actually ran and gave some results I guess that the problem is not in the dim_ordering/image_data_format. The weights I provided were generated from Keras version 1.2.2 and I am not sure if they are still valid on Keras 2. If you want to use those weights I would advise you to use Keras 1.2.2.

MinuteswithMetrics commented 6 years ago

Is it possible to use the code without the weights?

(C:\Users\green\Anaconda3\envs\py35) C:\Users\green\Documents\Data\input>python train.py [--base_dir][C:/Users/green/Documen ts/Data Competitions/Data Science Bowl 2018/input/data/unet_segmentations_binary ] [--train] [--val] C:\Users\green\Anaconda3\envs\py35\lib\site-packages\h5py__init.py:36: Future Warning: Conversion of the second argument of issubdtype from float to np.flo ating is deprecated. In future, it will be treated as np.float64 == np.dtype(f loat).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. TheanoShapedU-NET 2018-02-13 13:08:28.098000: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\ 35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn 't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2018-02-13 13:08:28.098274: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\ 35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn 't compiled to use AVX2 instructions, but these are available on your machine an d could speed up CPU computations. Traceback (most recent call last): File "train.py", line 326, in batch_size=params.batch_size, is_binary=params.is_b_binary) File "C:\Users\green\Documents\Data\input\ models.py", line 400, in g_unet x = LeakyReLU(0.2)(conv1) File "C:\Users\green\Anaconda3\envs\py35\lib\site-packages\keras\engine\topolo gy.py", line 617, in call__ output = self.call(inputs, *kwargs) File "C:\Users\green\Anaconda3\envs\py35\lib\site-packages\keras\layers\advanc ed_activations.py", line 46, in call return K.relu(inputs, alpha=self.alpha) File "C:\Users\green\Anaconda3\envs\py35\lib\site-packages\keras\backend\tenso rflow_backend.py", line 2918, in relu x = tf.nn.leaky_relu(x, alpha) AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' swig/python detected a memory leak of type 'int64_t ', no destructor found.