Modes#
from wholeslidedata.data.mode import WholeSlideMode
from wholeslidedata.iterators.batchiterator import create_batch_iterator
list(WholeSlideMode)
[<WholeSlideMode.default: 1>,
<WholeSlideMode.training: 2>,
<WholeSlideMode.validation: 3>,
<WholeSlideMode.test: 4>,
<WholeSlideMode.inference: 5>]
Mode specific settings in user config#
Using different modes allow for specific settings. For example for training mode and validation mode you can set different batch sizes in the config file
See also
Checkout the Dicfg documentation about context keys
user_config = './configs/user_config_modes.yml'
!cat {user_config}
wholeslidedata:
default:
yaml_source:
training:
- wsi:
path: /tmp/TCGA-21-5784-01Z-00-DX1.tif
wsa:
path: /tmp/TCGA-21-5784-01Z-00-DX1.xml
validation:
- wsi:
path: /tmp/TCGA-21-5784-01Z-00-DX1.tif
wsa:
path: /tmp/TCGA-21-5784-01Z-00-DX1.xml
labels:
stroma: 1
tumor: 2
lymphocytes: 3
batch_shape:
batch_size: 4
spacing: 1.0
shape: [512, 512, 3]
validation:
batch_shape:
batch_size: 8
training_iterator = create_batch_iterator(mode='training', user_config=user_config)
validation_iterator = create_batch_iterator(mode='validation', user_config=user_config)
print('Batch size training: ', training_iterator.batch_size)
print('Batch size validation: ', validation_iterator.batch_size)
training_iterator.stop()
validation_iterator.stop()
Batch size training: 4
Batch size validation: 8