razeineldin / DeepSeg

DeepSeg: Deep Neural Network Framework for Automatic Brain Tumor Segmentation using Magnetic Resonance FLAIR Images
MIT License
26 stars 13 forks source link

issues on train.py and data.py #7

Closed kszuyen closed 2 years ago

kszuyen commented 2 years ago

Hello, so I have just finished preprocessing the dataset, and is running the train.py file. I have passed the dataset verification so the dataset seem to have no problem. But it popped out an error:

ValueError: tf.function only supports singleton tf.Variables created on the first call. Make sure the tf.Variable is only created once or created outside tf.function. See https://www.tensorflow.org/guide/function#creating_tfvariables for more information.

at line:weights = K.variable(config['weights_arr']) in the data.py. (model.fit_generator() at the train.py file) I have searched but couldn't find any useful information. Also, it popped out some warnings such as

DeepSeg-1.1/train.py:53: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.
  results = model.fit_generator(train_gen, steps_per_epoch, validation_data=val_gen, validation_steps=validation_steps,
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/imgaug/imgaug.py:184: DeprecationWarning: Function `SegmentationMapOnImage()` is deprecated. Use `SegmentationMapsOnImage` instead. (Note the plural 'Maps' instead of old 'Map'.).
  warn_deprecated(msg, stacklevel=3)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/imgaug/imgaug.py:106: DeprecationWarning: Providing nb_classes to SegmentationMapsOnImage is no longer necessary and hence deprecated. The argument is ignored and can be safely removed.
  warn(msg, category=DeprecationWarning, stacklevel=stacklevel)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/imgaug/imgaug.py:184: DeprecationWarning: Method `SegmentationMapsOnImage.get_arr_int()` is deprecated. Use `SegmentationMapsOnImage.get_arr()` instead.
  warn_deprecated(msg, stacklevel=3)
Epoch 21/35

I have attempted using model.fit in replace of model.fit_generator, but it popped out an error:

ValueError: `y` argument is not supported when using dataset as input.

and I do not know how to fix it.

What could I possibly do wrong? Could you help to fix?

SabirKhanAkash commented 2 years ago

python 3.7 keras 2.2.5 keras-Applications 1.0.8 keras-Preprocessing 1.1.2 tensorflow 1.15.0 tensorflow-gpu 1.15.0 tensorflow-gpu-estimator 2.1.0 tensorflow-estimator 1.15.1 h5py 2.10.0

try installing these versions of modules and in config.py set

config['load_model'] = False (when you run train.py) and config['load_model'] = True (when you run predict.py)