Skip to content

Cli

Argparse for the AutoML Command Line Interface of aucmedi.automl.main.

The parameters are summarized in the docs: Documentation - AutoML - Parameters

cli_core() ¤

Internal function for Command-Line-Interface (CLI) setup.

Source code in aucmedi/automl/cli.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def cli_core():
    """ Internal function for Command-Line-Interface (CLI) setup. """
    # Set description for cli core
    desc = """ AutoML command-line interface for AUCMEDI: a framework for
               Automated Classification of Medical Images """
    # Setup ArgumentParser interface
    parser = argparse.ArgumentParser(prog="aucmedi", description=desc)
    # Add optional core arguments
    version = pkg_resources.require("aucmedi")[0].version
    parser.add_argument("-v", "--version", action="version",
                        version='%(prog)s_v' + version)

    # Add subparser interface
    subparsers = parser.add_subparsers(title="Application Modes",
                                       dest="hub")
    # Return parsers
    return parser, subparsers

cli_evaluation(subparsers) ¤

Parameter overview for the evaluation process.

Category Argument Type Default Description
I/O --path_imagedir str training Path to the directory containing the ground truth images.
I/O --path_gt str None Path to the index/class annotation CSV file (only required for defining the ground truth via 'csv' instead of 'directory' interface).
I/O --ohe bool False Boolean option whether annotation data is sparse categorical or one-hot encoded.
I/O --path_pred str preds.csv Path to the input file in which predicted csv file is stored.
I/O --path_evaldir str evaluation Path to the directory in which evaluation figures and tables should be stored.
Other --help bool False show this help message and exit.
Source code in aucmedi/automl/cli.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
def cli_evaluation(subparsers):
    """ Parameter overview for the evaluation process.

    | Category      | Argument               | Type       | Default        | Description |
    | :------------ | :--------------------- | :--------- | :------------- | :---------- |
    | I/O           | `--path_imagedir`      | str        | `training`     | Path to the directory containing the ground truth images. |
    | I/O           | `--path_gt`            | str        | `None`         | Path to the index/class annotation CSV file (only required for defining the ground truth via 'csv' instead of 'directory' interface). |
    | I/O           | `--ohe`                | bool       | `False`        | Boolean option whether annotation data is sparse categorical or one-hot encoded. |
    | I/O           | `--path_pred`          | str        | `preds.csv`    | Path to the input file in which predicted csv file is stored. |
    | I/O           | `--path_evaldir`       | str        | `evaluation`   | Path to the directory in which evaluation figures and tables should be stored. |
    | Other         | `--help`               | bool       | `False`        | show this help message and exit. |
    """
    # Set description for cli evaluation
    desc = """ Pipeline hub for Evaluation via AUCMEDI AutoML """
    # Setup SubParser
    parser_evaluate = subparsers.add_parser("evaluation",
                                            help=desc,
                                            add_help=False)

    # Add IO arguments
    od = parser_evaluate.add_argument_group("Arguments - I/O")
    od.add_argument("--path_imagedir",
                    type=str,
                    required=False,
                    default="training",
                    help="Path to the directory containing the ground truth" + \
                         " images " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_gt",
                    type=str,
                    required=False,
                    help="Path to the index/class annotation CSV file " + \
                         "(only required for defining the ground truth via " + \
                         "'csv' instead of 'directory' interface)",
                    )
    od.add_argument("--ohe",
                    action="store_true",
                    required=False,
                    default=False,
                    help="Boolean option whether annotation data is sparse " + \
                         "categorical or one-hot encoded " + \
                         "(only required for interface 'csv' and multi-" + \
                         "label data, " + \
                         "default: '%(default)s')",
                    )
    od.add_argument("--path_pred",
                    type=str,
                    required=False,
                    default="preds.csv",
                    help="Path to the output file in which predicted csv " + \
                         "file are stored " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_evaldir",
                    type=str,
                    required=False,
                    default="evaluation",
                    help="Path to the directory in which evaluation " + \
                         "figures and tables should be stored " + \
                         "(default: '%(default)s')",
                    )

    # Add other arguments
    oo = parser_evaluate.add_argument_group("Arguments - Other")
    oo.add_argument("-h",
                    "--help",
                    action="help",
                    help="show this help message and exit")

cli_prediction(subparsers) ¤

Parameter overview for the prediction process.

Category Argument Type Default Description
I/O --path_imagedir str test Path to the directory containing the images.
I/O --path_modeldir str model Path to the output directory in which fitted models and metadata are stored.
I/O --path_pred str preds.csv Path to the output file in which predicted csv file should be stored.
Configuration --xai_method str None Key for XAI method.
Configuration --xai_directory str xai Path to the output directory in which predicted image xai heatmaps should be stored.
Configuration --batch_size int 24 Number of samples inside a single batch.
Configuration --workers int 1 Number of workers/threads which preprocess batches during runtime.
Other --help bool False show this help message and exit.
List of XAI Methods

AUCMEDI provides a large library of state-of-the-art and ready-to-use XAI methods: aucmedi.xai.methods

Source code in aucmedi/automl/cli.py
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
def cli_prediction(subparsers):
    """ Parameter overview for the prediction process.

    | Category      | Argument               | Type       | Default        | Description |
    | :------------ | :--------------------- | :--------- | :------------- | :---------- |
    | I/O           | `--path_imagedir`      | str        | `test`         | Path to the directory containing the images. |
    | I/O           | `--path_modeldir`      | str        | `model`        | Path to the output directory in which fitted models and metadata are stored. |
    | I/O           | `--path_pred`          | str        | `preds.csv`    | Path to the output file in which predicted csv file should be stored. |
    | Configuration | `--xai_method`         | str        | `None`         | Key for XAI method.  |
    | Configuration | `--xai_directory`      | str        | `xai`          | Path to the output directory in which predicted image xai heatmaps should be stored. |
    | Configuration | `--batch_size`         | int        | `24`           | Number of samples inside a single batch. |
    | Configuration | `--workers`            | int        | `1`            | Number of workers/threads which preprocess batches during runtime. |
    | Other         | `--help`               | bool       | `False`        | show this help message and exit. |

    ??? info "List of XAI Methods"
        AUCMEDI provides a large library of state-of-the-art and ready-to-use XAI methods:
        [aucmedi.xai.methods][]
    """
    # Set description for cli prediction
    desc = """ Pipeline hub for Inference via AUCMEDI AutoML """
    # Setup SubParser
    parser_predict = subparsers.add_parser("prediction",
                                           help=desc,
                                           add_help=False)

    # Add IO arguments
    od = parser_predict.add_argument_group("Arguments - I/O")
    od.add_argument("--path_imagedir",
                    type=str,
                    required=False,
                    default="test",
                    help="Path to the directory containing the images " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_modeldir",
                    type=str,
                    required=False,
                    default="model",
                    help="Path to the model directory in which fitted " + \
                         "model weights and metadata are stored " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_pred",
                    type=str,
                    required=False,
                    default="preds.csv",
                    help="Path to the output file in which predicted csv " + \
                         "file should be stored " + \
                         "(default: '%(default)s')",
                    )

    # Add configuration arguments
    oc = parser_predict.add_argument_group("Arguments - Configuration")
    oc.add_argument("--xai_method",
                    type=str,
                    required=False,
                    help="Key for XAI method " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--xai_directory",
                    type=str,
                    required=False,
                    default="xai",
                    help="Path to the output directory in which predicted " + \
                         "image xai heatmaps should be stored " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--batch_size",
                    type=int,
                    required=False,
                    default=12,
                    help="Number of samples inside a single batch " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--workers",
                    type=int,
                    required=False,
                    default=1,
                    help="Number of workers/threads which preprocess " + \
                         "batches during runtime " + \
                         "(default: '%(default)s')",
                    )

    # Add other arguments
    oo = parser_predict.add_argument_group("Arguments - Other")
    oo.add_argument("-h",
                    "--help",
                    action="help",
                    help="show this help message and exit")

cli_training(subparsers) ¤

Parameter overview for the training process.

Category Argument Type Default Description
I/O --path_imagedir str training Path to the directory containing the images.
I/O --path_modeldir str model Path to the output directory in which fitted models and metadata are stored.
I/O --path_gt str None Path to the index/class annotation file if required. (only for 'csv' interface).
I/O --ohe bool False Boolean option whether annotation data is sparse categorical or one-hot encoded.
Configuration --analysis str standard Analysis mode for the AutoML training. Options: ["minimal", "standard", "advanced"].
Configuration --three_dim bool False Boolean, whether data is 2D or 3D.
Configuration --shape_3D str 128x128x128 Desired input shape of 3D volume for architecture (will be cropped into, format: 1x2x3).
Configuration --epochs int 500 Number of epochs. A single epoch is defined as one iteration through the complete data set.
Configuration --batch_size int 24 Number of samples inside a single batch.
Configuration --workers int 1 Number of workers/threads which preprocess batches during runtime.
Configuration --metalearner str mean Key for Metalearner or Aggregate function.
Configuration --architecture str DenseNet121 Key of single or multiple Architectures (only supported for 'analysis=advanced', format: 'KEY' or 'KEY,KEY,KEY).
Other --help bool False show this help message and exit.
List of Architectures

AUCMEDI provides a large library of state-of-the-art and ready-to-use architectures.

List of Metalearner
Source code in aucmedi/automl/cli.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def cli_training(subparsers):
    """ Parameter overview for the training process.

    | Category      | Argument               | Type       | Default        | Description |
    | :------------ | :--------------------- | :--------- | :------------- | :---------- |
    | I/O           | `--path_imagedir`      | str        | `training`     | Path to the directory containing the images. |
    | I/O           | `--path_modeldir`      | str        | `model`        | Path to the output directory in which fitted models and metadata are stored. |
    | I/O           | `--path_gt`            | str        | `None`         | Path to the index/class annotation file if required. (only for 'csv' interface). |
    | I/O           | `--ohe`                | bool       | `False`        | Boolean option whether annotation data is sparse categorical or one-hot encoded. |
    | Configuration | `--analysis`           | str        | `standard`     | Analysis mode for the AutoML training. Options: `["minimal", "standard", "advanced"]`. |
    | Configuration | `--three_dim`          | bool       | `False`        | Boolean, whether data is 2D or 3D. |
    | Configuration | `--shape_3D`           | str        | `128x128x128`  | Desired input shape of 3D volume for architecture (will be cropped into, format: `1x2x3`). |
    | Configuration | `--epochs`             | int        | `500`          | Number of epochs. A single epoch is defined as one iteration through the complete data set. |
    | Configuration | `--batch_size`         | int        | `24`           | Number of samples inside a single batch. |
    | Configuration | `--workers`            | int        | `1`            | Number of workers/threads which preprocess batches during runtime. |
    | Configuration | `--metalearner`        | str        | `mean`         | Key for Metalearner or Aggregate function. |
    | Configuration | `--architecture`       | str        | `DenseNet121`  | Key of single or multiple Architectures (only supported for 'analysis=advanced', format: 'KEY' or 'KEY,KEY,KEY). |
    | Other         | `--help`               | bool       | `False`        | show this help message and exit. |

    ??? info "List of Architectures"
        AUCMEDI provides a large library of state-of-the-art and ready-to-use architectures.

        - 2D Architectures: [aucmedi.neural_network.architectures.image][]
        - 3D Architectures: [aucmedi.neural_network.architectures.volume][]

    ??? info "List of Metalearner"
        - Homogeneous pooling functions: [Aggregate][aucmedi.ensemble.aggregate]
        - Heterogeneous pooling functions: [Metalearner][aucmedi.ensemble.metalearner]
    """
    # Set description for cli training
    desc = """ Pipeline hub for Training via AUCMEDI AutoML """
    # Setup SubParser
    parser_train = subparsers.add_parser("training", help=desc, add_help=False)

    # Add IO arguments
    od = parser_train.add_argument_group("Arguments - I/O")
    od.add_argument("--path_imagedir",
                    type=str,
                    required=False,
                    default="training",
                    help="Path to the directory containing the images " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_modeldir",
                    type=str,
                    required=False,
                    default="model",
                    help="Path to the output directory in which fitted " + \
                         "models and metadata are stored " + \
                         "(default: '%(default)s')",
                    )
    od.add_argument("--path_gt",
                    type=str,
                    required=False,
                    help="Path to the index/class annotation CSV file " + \
                         "(only required for defining the ground truth via " + \
                         "'csv' instead of 'directory' interface)",
                    )

    od.add_argument("--ohe",
                    action="store_true",
                    required=False,
                    default=False,
                    help="Boolean option whether annotation data is sparse " + \
                         "categorical or one-hot encoded " + \
                         "(only required for interface 'csv' and multi-" + \
                         "label data, " + \
                         "default: '%(default)s')",
                    )

    # Add configuration arguments
    oc = parser_train.add_argument_group("Arguments - Configuration")
    oc.add_argument("--analysis",
                    type=str,
                    required=False,
                    default="standard",
                    choices=["minimal", "standard", "advanced"],
                    help="Analysis mode for the AutoML training " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--three_dim",
                    action="store_true",
                    required=False,
                    default=False,
                    help="Boolean, whether imaging data is 2D or 3D " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--shape_3D",
                    type=str,
                    required=False,
                    default="128x128x128",
                    help="Desired input shape of 3D volume for architecture "+ \
                         "(will be cropped into, " + \
                         "format: '1x2x3', " + \
                         "default: '%(default)s')",
                    )
    oc.add_argument("--epochs",
                    type=int,
                    required=False,
                    default=500,
                    help="Number of epochs. A single epoch is defined as " + \
                         "one iteration through the complete data set " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--batch_size",
                    type=int,
                    required=False,
                    default=24,
                    help="Number of samples inside a single batch " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--workers",
                    type=int,
                    required=False,
                    default=1,
                    help="Number of workers/threads which preprocess " + \
                         "batches during runtime " + \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--metalearner",
                    type=str,
                    required=False,
                    default="mean",
                    help="Key for Metalearner or Aggregate function "+ \
                         "(default: '%(default)s')",
                    )
    oc.add_argument("--architecture",
                    type=str,
                    required=False,
                    default="DenseNet121",
                    help="Key of single or multiple Architectures " + \
                         "(multiple Architectures are only supported for " + \
                         "'analysis=advanced', " + \
                         "format: 'KEY' or 'KEY,KEY,KEY', " + \
                         "default: '%(default)s')",
                    )

    # Add other arguments
    oo = parser_train.add_argument_group("Arguments - Other")
    oo.add_argument("-h",
                    "--help",
                    action="help",
                    help="show this help message and exit")