Add new workflow¶
Creating a new workflow requires considering the different areas where custom functions can be added. Additionally, to fully integrate the new workflow, it is necessary to follow the steps outlined in the General guidelines section of the documentation.
All workflows are defined within the
engine folder and constructed in the
engine/engine.py file, specifically in the test function. The initial lines in this function pertain to post-processing configuration, for more information on this see the Add pre/post processing section of the documentation. After that, each workflow is built, and the inference is performed using the
process_sample function. The inference is done for each test image (currently one by one).
In addition to the
process_sample function, which is the primary function, creating the
normalize_stats functions (which will be explained later),
after_all_images functions are also necessary. To understand how these functions work, it’s helpful to know that the
process_sample function has mainly three steps:
TEST.STATS.PER_PATCHvariable is enabled, the test image is divided into smaller patches which are then passed through the model. After that, the original image shape is reconstructed.
TEST.STATS.MERGE_PATCHESvariable is enabled, IoU metrics are calculated and a post-processing step is performed for 3D data. When
TEST.STATS.FULL_IMGis enabled and working in 2D, full images are passed through the model.
after_merge_patchesfunction is applied after the second step (regardless of whether
TEST.STATS.MERGE_PATCHESis enabled), the
after_full_imagefunction is applied after the third step, and the
after_all_imagesfunction is applied when all images have been passed through the
process_samplefunction. With these three functions, you have the flexibility to apply any process you want after each main step.
Finally, you should implement the
normalize_stats functions within your own workflow so that you can print the values of the specific metrics you have calculated. For example, in instance segmentation, we reimplement
print_stats to print matching metrics used to evaluate instances (see here). In the same way, we reimplement
normalize_stats to normalize also the new measurements (see here).