pnlbwh / CNN-Diffusion-MRIBrain-Segmentation

CNN based brain masking
Other
14 stars 10 forks source link

Create log_dir and save_model_dir if they don't exist #18

Closed tashrifbillah closed 4 years ago

tashrifbillah commented 4 years ago

@SenthilCaesar , I think you made an assumption that they exist or they were so you didn't consider the issue:

https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation/blob/remove-ext-dep/src/compnet.py#L602

tashrifbillah commented 4 years ago
Traceback (most recent call last):
  File "./train.py", line 17, in <module>
    train_model(data_params, train_params, common_params)
  File "/home/tb571/tmp/CNN-Diffusion-MRIBrain-Segmentation/src/compnet.py", line 616, in train_model
    callbacks=[csv_logger, checkpoint])
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/training.py", line 1239, in fit
    validation_freq=validation_freq)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 216, in fit_loop
    callbacks.on_epoch_end(epoch, epoch_logs)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 152, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 728, in on_epoch_end
    self.model.save_weights(filepath, overwrite=True)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/saving.py", line 449, in save_wrapper
    save_function(obj, filepath, overwrite, *args, **kwargs)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/network.py", line 1183, in save_weights
    with h5py.File(filepath, 'w') as f:
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/h5py/_hl/files.py", line 394, in __init__
    swmr=swmr)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/h5py/_hl/files.py", line 176, in make_fid
    fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 105, in h5py.h5f.create
OSError: Unable to create file (unable to open file: name = '/tmp/model_dir//weights-sagittal-improvement-01.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 242)

and

Traceback (most recent call last):
  File "./train.py", line 17, in <module>
    train_model(data_params, train_params, common_params)
  File "/home/tb571/tmp/CNN-Diffusion-MRIBrain-Segmentation/src/compnet.py", line 616, in train_model
    callbacks=[csv_logger, checkpoint])
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/training.py", line 1239, in fit
    validation_freq=validation_freq)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 129, in fit_loop
    callbacks._call_begin_hook('train')
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 103, in _call_begin_hook
    self.on_train_begin()
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 219, in on_train_begin
    callback.on_train_begin(logs)
  File "/tmp/miniconda3/envs/tf/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 1116, in on_train_begin
    **self._open_args)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/cnn_log_dir/sagittal.csv'
tashrifbillah commented 4 years ago

I shall correct it for you, close the issue after you see it.

senthilcaesar commented 4 years ago

Sure, Thank you @tashrifbillah