MrGiovanni / UNetPlusPlus

[IEEE TMI] Official Implementation for UNet++
Other
2.26k stars 538 forks source link

Implementing in colab #52

Open Swathi-Guptha opened 4 years ago

Swathi-Guptha commented 4 years ago

I have been trying to implement this code in colab but there is alot of version issue. The requirements file have tensorflow=1.14.1 which is supported by cuda=10.0 My colab have tensorflow=2.2.0 which is supported by 10.1 and i'm getting the following error: AttributeError Traceback (most recent call last)

in () ----> 1 model = Xnet(backbone_name='resnet50', encoder_weights='imagenet', decoder_block_type='transpose') # build UNet++ 7 frames /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in placeholder(shape, ndim, dtype, sparse, name) 513 x = tf.sparse_placeholder(dtype, shape=shape, name=name) 514 else: --> 515 x = tf.placeholder(dtype, shape=shape, name=name) 516 x._keras_shape = shape 517 x._uses_learning_phase = False AttributeError: module 'tensorflow' has no attribute 'placeholder' Can there be any way in which the above version problem can be rectified?
maksym33 commented 4 years ago

Maybe try: %tensorflow_version 1.x from https://colab.research.google.com/notebooks/tensorflow_version.ipynb ?

Swathi-Guptha commented 4 years ago

1.! python -m pip install Keras==2.3.1 tensorflow==2.1.0

  1. import tensorflow.compat.v1 as tf tf.disable_v2_behavior() print(tf.version)

After executing the requirements file we need to run the above two steps to run the code in colab

ItsCRC commented 3 years ago

After following your instructions from the above comment on colab, it gives this error after first epoch: Epoch 1/70 74/74 [==============================] - 273s 4s/step - loss: 0.4780 - dice_coef: 0.5583 - val_loss: 5.9511 - val_dice_coef: 0.2558 NotImplementedError Traceback (most recent call last)

in () ----> 1 history = model.fit(train_generator, validation_data=valid_generator, callbacks=callbackslist, epochs=70, verbose=1) /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/resource_variable_ops.py in numpy(self) 582 return self.read_value().numpy() 583 raise NotImplementedError( --> 584 "numpy() is only available when eager execution is enabled.") 585 586 @deprecated(None, "Prefer Dataset.range instead.") NotImplementedError: numpy() is only available when eager execution is enabled. I tried: import tensorflow.compat.v1 as tf tf.enable_eager_execution() tf.disable_v2_behavior() print(tf.version) Still same error....@Swathi-Gupta