Dear Fahdi,
My name is Mitch Chen, clinical lecturer in radiology at Imperial collaborating with Andrea. Hope things are going well on your end.
I've been testing out the training part of your slice detection model (with l3_dataset.npy) but have encountered the following error. Just checking if you happen to have across this before or might know a fix.
Thought I'd also ask about prepping a new training dataset (t12_dataset.npy) and wondered if you could offer any more guidance, in addition to what's described in your Clin Rad manuscript.
Feel free to reply to me by email if it suits better ([email protected]).
Thanks,
Rgds,
Mitch
(sarcopenia-ai) mitchchen@oem-System-Product-Name:~/git/sarcopenia-ai$ docker run --runtime=nvidia -t --rm -it -v $(pwd)/data/:/data -v $(pwd)/configs:/configs sarcopeniaai python -m sarcopenia_ai.apps.slice_detection.trainer --config /configs/slice_detection.cfg
Using TensorFlow backend.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
Namespace(batch_size=16, cache_path='/data', cuda_devices='0', dataset_path='/data/l3_dataset.npz', do_augment=True, do_checkpoint=False, do_crossval=0, ds_factor=1, flatten_output=1, image_type='frontal', img_batch_size=1, input_shape=[256, 384, 1], input_spacing=1, mode='heatmap', model_input_shape=[None, None, 1], model_name='CNNLineSep', model_path='/data/slice_detection/', n_splits=3, num_epochs=50, num_val=20, preview_generator_output=1, preview_training_output=1, preview_validation_steps=2, random_state=42, regression_dual_output=False, restart=False, sampling_rate=0.5, sigma=1.5, steps_per_epoch=55, use_cache=1, workers=4)
11:24:19 - tensorflow - WARNING - From /sarcopenia_ai/sarcopenia_ai/core/model_wrapper.py:35: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.
11:24:19 - tensorflow - WARNING - From /sarcopenia_ai/sarcopenia_ai/core/model_wrapper.py:39: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.
2023-05-26 11:24:19.280154: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2023-05-26 11:24:19.285523: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcuda.so.1
2023-05-26 11:24:19.389436: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.389875: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4914a70 executing computations on platform CUDA. Devices:
2023-05-26 11:24:19.389906: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): NVIDIA GeForce RTX 3090, Compute Capability 8.6
2023-05-26 11:24:19.410573: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3593435000 Hz
2023-05-26 11:24:19.414278: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x48b1740 executing computations on platform Host. Devices:
2023-05-26 11:24:19.414306: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): ,
2023-05-26 11:24:19.414628: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.415028: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: NVIDIA GeForce RTX 3090 major: 8 minor: 6 memoryClockRate(GHz): 1.8
pciBusID: 0000:41:00.0
2023-05-26 11:24:19.415391: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.0
2023-05-26 11:24:19.417109: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcublas.so.10.0
2023-05-26 11:24:19.418606: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcufft.so.10.0
2023-05-26 11:24:19.419014: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcurand.so.10.0
2023-05-26 11:24:19.420227: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusolver.so.10.0
2023-05-26 11:24:19.421002: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusparse.so.10.0
2023-05-26 11:24:19.423156: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudnn.so.7
2023-05-26 11:24:19.423265: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.423449: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.423562: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2023-05-26 11:24:19.423589: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.0
2023-05-26 11:24:19.424397: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-05-26 11:24:19.424405: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
2023-05-26 11:24:19.424410: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
2023-05-26 11:24:19.424500: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.424670: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2023-05-26 11:24:19.424801: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 22803 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:41:00.0, compute capability: 8.6)
Resuming training on model_path /data/slice_detection/
l3_dataset
random split
/usr/local/lib/python3.6/dist-packages/imgaug/imgaug.py:184: DeprecationWarning: Function SimplexNoiseAlpha()
is deprecated. Use BlendAlphaSimplexNoise
instead. SimplexNoiseAlpha is deprecated. Use BlendAlphaSimplexNoise instead. The order of parameters is the same. Parameter 'first' was renamed to 'foreground'. Parameter 'second' was renamed to 'background'.
warn_deprecated(msg, stacklevel=3)
{'model_dir': '/data/slice_detection/', 'config': Namespace(batch_size=16, cache_path='/data', cuda_devices='0', dataset_path='/data/l3_dataset.npz', do_augment=True, do_checkpoint=False, do_crossval=0, ds_factor=1, flatten_output=1, image_type='frontal', img_batch_size=1, input_shape=[256, 384, 1], input_spacing=1, is_multi_gpu=False, mode='heatmap', model_input_shape=[None, None, 1], model_name='CNNLineSep', model_path='/data/slice_detection/', n_splits=3, num_epochs=50, num_gpus=1, num_val=20, preview_generator_output=1, preview_training_output=1, preview_validation_steps=2, random_state=42, regression_dual_output=False, restart=False, sampling_rate=0.5, sigma=1.5, steps_per_epoch=55, use_cache=1, workers=4), 'model': None, 'parallel_model': None, 'name': 'CNNLineSep', 'start_epoch': 0, 'is_multi_gpu': False, 'num_gpus': 1, 'class_mode': 'binary', 'data_loader': <sarcopenia_ai.apps.slice_detection.dataloader.TrainerData object at 0x7efd4920a588>, 'custom_objects': {'GroupNormalization': <class 'sarcopenia_ai.core.layers.GroupNormalization'>}, 'callbacks': [], 'model_input_shape': [None, None, 1], 'max_queue_size': 10, 'workers': 4, 'depth_multiplier': 0.5, 'epochs': 50, 'labels': [], 'steps_per_epoch': 55, 'learning_rate': 0.05, 'compile_args': {'loss': 'binary_crossentropy', 'optimizer': <keras.optimizers.Adam object at 0x7efd49376390>, 'metrics': ['accuracy']}, 'input_shape': [None, None, 1], 'use_multiprocessing': True}
11:24:41 - sarcopenia_ai.core.model_wrapper - INFO - Attempting to load model architecture from file.
11:24:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
11:24:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:4138: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.
11:24:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:245: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.
11:28:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1834: The name tf.nn.fused_batch_norm is deprecated. Please use tf.compat.v1.nn.fused_batch_norm instead.
11:28:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3976: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.
11:28:41 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate
instead of keep_prob
. Rate should be set to rate = 1 - keep_prob
.
11:28:42 - sarcopenia_ai.core.model_wrapper - INFO - Model architecture loaded from file.
11:28:42 - sarcopenia_ai.core.model_wrapper - INFO - Loading model weights /data/slice_detection/CNNLineSep_at_epoch_01-checkpoint.h5 ...
11:28:43 - sarcopenia_ai.core.model_wrapper - INFO - Model weights loaded.
11:28:43 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/keras/optimizers.py:790: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.
11:28:43 - tensorflow - WARNING - From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/nn_impl.py:180: add_dispatch_support..wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
==================================================================================================
input_1 (InputLayer) (None, None, None, 1 0
.... model details .....
Total params: 511,450
Trainable params: 508,058
Non-trainable params: 3,392
None
Epoch 2/50
learning rate 0.1
2023-05-26 11:28:50.540860: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudnn.so.7
48/47 [==============================] - 843s 18s/step - loss: 144634.8605 - acc: 0.0193 - distance: 14000.3229 - val_loss: 2592.5620 - val_acc: 0.9288 - val_distance: 12693.7031
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/sarcopenia_ai/sarcopenia_ai/apps/slice_detection/trainer.py", line 167, in
main()
File "/sarcopenia_ai/sarcopenia_ai/apps/slice_detection/trainer.py", line 158, in main
model_wrapper.train_generator()
File "/sarcopenia_ai/sarcopenia_ai/core/model_wrapper.py", line 318, in train_generator
class_weight=self.data_loader.class_weight
File "/usr/local/lib/python3.6/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training_generator.py", line 251, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "/usr/local/lib/python3.6/dist-packages/keras/callbacks.py", line 79, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "/sarcopenia_ai/sarcopenia_ai/apps/slice_detection/callbacks.py", line 38, in on_epoch_end
pred_map = np.expand_dims(zoom(np.squeeze(pred_map), ds), 2)
File "<array_function internals>", line 6, in expand_dims
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/shape_base.py", line 597, in expand_dims
axis = normalize_axis_tuple(axis, out_ndim)
File "/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py", line 1358, in normalize_axis_tuple
axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
File "/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py", line 1358, in
axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
numpy.AxisError: axis 2 is out of bounds for array of dimension 2