Brain-tumor-segmentation icon indicating copy to clipboard operation
Brain-tumor-segmentation copied to clipboard

ValueError: Cannot create group in read only mode.

Open NareshM67 opened this issue 6 years ago • 5 comments

Using TensorFlow backend. Traceback (most recent call last): File "/content/drive/My Drive/Brain-tumor-segmentation-master/train.py", line 108, in brain_seg = Training(batch_size=4,nb_epoch=3,load_model_resume_training=model_to_load) File "/content/drive/My Drive/Brain-tumor-segmentation-master/train.py", line 39, in init self.model =load_model(load_model_resume_training,custom_objects={'gen_dice_loss': gen_dice_loss,'dice_whole_metric':dice_whole_metric,'dice_core_metric':dice_core_metric,'dice_en_metric':dice_en_metric}) File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 221, in _deserialize_model model_config = f['model_config'] File "/usr/local/lib/python3.6/dist-packages/keras/utils/io_utils.py", line 302, in getitem raise ValueError('Cannot create group in read only mode.') ValueError: Cannot create group in read only mode.

while running train.py in colab got this error.

NareshM67 avatar Dec 01 '18 11:12 NareshM67

You got any solution for ValueError? I am with same error please help. Thanks

sapnii2 avatar May 24 '19 13:05 sapnii2

I got any solution for ValueError. If you want to train the model from scratch, the parameter load_model_resume_training shoud be None. If you train the model from the pretrained weights provided by @Issam28, the parameter load_model_resume_training shoud be pretrained weights filepath without extension and code

self.model =load_model(load_model_resume_training,custom_objects={'gen_dice_loss': gen_dice_loss,'dice_whole_metric':dice_whole_metric,'dice_core_metric':dice_core_metric,'dice_en_metric':dice_en_metric})

change to

self.model = self.load_model(load_model_resume_training)
sgd = SGD(lr=0.08, momentum=0.9, decay=5e-6, nesterov=False)
self.model.compile(loss=gen_dice_loss, optimizer=sgd, metrics=[dice_whole_metric,dice_core_metric,dice_en_metric])

latestgo avatar Feb 21 '20 09:02 latestgo

I got any solution for ValueError. If you want to train the model from scratch, the parameter load_model_resume_training shoud be None. If you train the model from the pretrained weights provided by @Issam28, the parameter load_model_resume_training shoud be pretrained weights filepath without extension and code

self.model =load_model(load_model_resume_training,custom_objects={'gen_dice_loss': gen_dice_loss,'dice_whole_metric':dice_whole_metric,'dice_core_metric':dice_core_metric,'dice_en_metric':dice_en_metric})

change to

self.model = self.load_model(load_model_resume_training)
sgd = SGD(lr=0.08, momentum=0.9, decay=5e-6, nesterov=False)
self.model.compile(loss=gen_dice_loss, optimizer=sgd, metrics=[dice_whole_metric,dice_core_metric,dice_en_metric])

The load_model function needs '{ }.json', but I didn't find it

muween avatar Apr 06 '20 20:04 muween

I got any solution for ValueError. If you want to train the model from scratch, the parameter load_model_resume_training shoud be None. If you train the model from the pretrained weights provided by @Issam28, the parameter load_model_resume_training shoud be pretrained weights filepath without extension and code

self.model =load_model(load_model_resume_training,custom_objects={'gen_dice_loss': gen_dice_loss,'dice_whole_metric':dice_whole_metric,'dice_core_metric':dice_core_metric,'dice_en_metric':dice_en_metric})

change to

self.model = self.load_model(load_model_resume_training)
sgd = SGD(lr=0.08, momentum=0.9, decay=5e-6, nesterov=False)
self.model.compile(loss=gen_dice_loss, optimizer=sgd, metrics=[dice_whole_metric,dice_core_metric,dice_en_metric])

The load_model function needs '{ }.json', but I didn't find it

Hello, hope it's not too late. The json file can be produced by function save_model in object Train.

latestgo avatar Apr 13 '20 04:04 latestgo

Hello, I used your solution(change self.model) and ran into this problem as well:No such file or directory: '*******/pretrained_weights/ResUnet.epoch_02.hdf5.json' I don't understand you said "The json file can be produced by function save_model in object Train.", Can you elaborate a bit more on how to solve this problem? Thank you very much! I am looking forward to your reply.

qiuyuan666 avatar Aug 19 '20 12:08 qiuyuan666