biapy 3.3.2__tar.gz → 3.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {biapy-3.3.2/biapy.egg-info → biapy-3.3.3}/PKG-INFO +1 -1
- {biapy-3.3.2 → biapy-3.3.3}/biapy/config/config.py +9 -9
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/pre_processing.py +6 -6
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/base_workflow.py +64 -61
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/check_configuration.py +15 -30
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/detection.py +15 -15
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/instance_seg.py +94 -24
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/semantic_seg.py +1 -1
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/super_resolution.py +5 -5
- {biapy-3.3.2 → biapy-3.3.3/biapy.egg-info}/PKG-INFO +1 -1
- {biapy-3.3.2 → biapy-3.3.3}/pyproject.toml +1 -1
- {biapy-3.3.2 → biapy-3.3.3}/setup.py +1 -1
- {biapy-3.3.2 → biapy-3.3.3}/templates/denoising/2d_denoising.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/denoising/3d_denoising.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/detection/2d_detection.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/detection/3d_detection.yaml +0 -3
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/2d_instance_segmentation.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/3d_instance_segmentation.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/MitoEM_paper/mitoem.yaml +0 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/self-supervised/2d_self-supervised.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/self-supervised/3d_self-supervised.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/semantic_segmentation/2d_semantic_segmentation.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/semantic_segmentation/3d_semantic_segmentation.yaml +1 -4
- {biapy-3.3.2 → biapy-3.3.3}/templates/super-resolution/3d_super-resolution.yaml +0 -3
- {biapy-3.3.2 → biapy-3.3.3}/.gitignore +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/CODE_OF_CONDUCT.md +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/LICENSE.md +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/README.md +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/_biapy.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/config/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/data_2D_manipulation.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/data_3D_manipulation.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/augmentors.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/pair_base_data_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/pair_data_2D_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/pair_data_3D_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/single_base_data_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/single_data_2D_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/single_data_3D_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/test_pair_data_generators.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/generators/test_single_data_generator.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/post_processing/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/post_processing/post_processing.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/data/post_processing/smooth_tiled_predictions.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/classification.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/denoising.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/metrics.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/schedulers/warmup_cosine_decay.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/self_supervised.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/engine/train_engine.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/__init__.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/attention_unet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/blocks.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/dfcan.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/edsr.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/efficientnet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/mae.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/multiresunet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/rcan.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/resunet++.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/resunet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/seunet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/simple_cnn.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/tr_layers.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/unet.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/unetr.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/vit.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/models/wdsr.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/callbacks.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/env/Dockerfile +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/env/Dockerfile_CUDA10.2 +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/env/create_docker_image.sh +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/matching.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/misc.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/calculate_detection_metrics.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/calculate_metrics_3D.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/create_probability_csv.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/crop_2D_dataset.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/crop_3D_dataset.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/crop_and_discard_3D_dataset.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/detection_plots.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/detection_probs_to_points.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/fill_holes_in_seg_masks.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/filter_close_points.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/from_class_csv_to_folders.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/h5_to_tif.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/h5_to_zarr.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/merge_dataset_channels.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/order_axes.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/scripts/tif_to_h5.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy/utils/util.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy.egg-info/SOURCES.txt +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy.egg-info/dependency_links.txt +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy.egg-info/requires.txt +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/biapy.egg-info/top_level.txt +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/BiaPy-Euro-BioImaging-youtube.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/BiaPy-workflow-readme.svg +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/BiaPy_GUI_main_page.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/BiaPy_presentation_and_demo_at_RTmfm.jpg +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/MitoEM_teaser_cable_length_split.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/biapy_logo.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/complex_MOAS.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/cyst_instance_prediction.gif +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/cyst_sample.gif +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/domain_EM.jpg +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/halo_instances.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/unet_attn_stable.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/img/wound_diagram_VQVAE.png +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/main.py +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/BiaPy_Inference.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/classification/BiaPy_2D_Classification.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/classification/BiaPy_2D_Classification_Butterfly.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/classification/BiaPy_3D_Classification.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/denoising/BiaPy_2D_Denoising.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/denoising/BiaPy_3D_Denoising.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/detection/BiaPy_2D_Detection.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/detection/BiaPy_3D_Detection.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/instance_segmentation/BiaPy_2D_Instance_Segmentation.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/instance_segmentation/BiaPy_3D_Instance_Segmentation.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/self-supervised/BiaPy_2D_Self_Supervision.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/self-supervised/BiaPy_3D_Self_Supervision.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/semantic_segmentation/BiaPy_2D_Semantic_Segmentation.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/semantic_segmentation/BiaPy_3D_Semantic_Segmentation.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/super-resolution/BiaPy_2D_Super_Resolution.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/notebooks/super-resolution/BiaPy_3D_Super_Resolution.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/setup.cfg +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/classification/2d_classification.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/classification/2d_classification_rgb.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/classification/3d_classification.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/CartoCell_paper/CartoCell - Inference workflow (Phase 5).ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/CartoCell_paper/CartoCell - Training workflow (Phase 2).ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/CartoCell_paper/cartocell_inference.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/CartoCell_paper/cartocell_training.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/instance_segmentation/CartoCell_paper/model_weights_cartocell.h5 +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/semantic_segmentation/stable_paper/semantic_segmentation_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/sota_implementations/Casser_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/sota_implementations/Cheng_2D_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/sota_implementations/Cheng_3D_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/sota_implementations/Oztel_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/sota_implementations/Xiao_workflow.ipynb +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/super-resolution/2d_super-resolution.yaml +0 -0
- {biapy-3.3.2 → biapy-3.3.3}/templates/super-resolution/2d_super-resolution_rgb.yaml +0 -0
|
@@ -237,7 +237,7 @@ class Config:
|
|
|
237
237
|
# Points outside the boundaries of the input are filled according to the given mode: {‘constant’, ‘edge’, ‘symmetric’, ‘reflect’, ‘wrap’}
|
|
238
238
|
_C.DATA.PREPROCESS.RESIZE.MODE = 'reflect'
|
|
239
239
|
# Used in conjunction with mode ‘constant’, the value outside the image boundaries.
|
|
240
|
-
_C.DATA.PREPROCESS.RESIZE.CVAL = 0
|
|
240
|
+
_C.DATA.PREPROCESS.RESIZE.CVAL = 0.
|
|
241
241
|
# Whether to clip the output to the range of values of the input image.
|
|
242
242
|
_C.DATA.PREPROCESS.RESIZE.CLIP = True
|
|
243
243
|
# Whether to keep the original range of values.
|
|
@@ -784,14 +784,12 @@ class Config:
|
|
|
784
784
|
_C.TEST.AUGMENTATION = False
|
|
785
785
|
# Whether to evaluate or not
|
|
786
786
|
_C.TEST.EVALUATE = True
|
|
787
|
-
# Stack 2D images into a 3D image and then process it entirely instead of going image per image
|
|
788
|
-
# images that have been merged with 'TEST.STATS.MERGE_PATCHES' = True or 'TEST.STATS.FULL_IMG' (priorizes this later)
|
|
787
|
+
# Stack 2D images into a 3D image and then process it entirely instead of going image per image
|
|
789
788
|
_C.TEST.ANALIZE_2D_IMGS_AS_3D_STACK = False
|
|
790
789
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
_C.TEST.
|
|
794
|
-
_C.TEST.STATS.FULL_IMG = True # Only when if PROBLEM.NDIM = '2D' as 3D images are huge for the GPU
|
|
790
|
+
# If PROBLEM.NDIM = '2D' this can be activated to process each image entirely instead of patch by patch. Only can be done
|
|
791
|
+
# if the neural network is fully convolutional
|
|
792
|
+
_C.TEST.FULL_IMG = False
|
|
795
793
|
|
|
796
794
|
### Instance segmentation
|
|
797
795
|
# Whether to calculate matching statistics (average overlap, accuracy, recall, precision, etc.)
|
|
@@ -830,8 +828,7 @@ class Config:
|
|
|
830
828
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
831
829
|
# Post-processing
|
|
832
830
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
833
|
-
# When PROBLEM.NDIM = '2D' only applies when _C.TEST.
|
|
834
|
-
# when _C.TEST.STATS.MERGE_PATCHES = True
|
|
831
|
+
# When PROBLEM.NDIM = '2D' only applies when _C.TEST.ANALIZE_2D_IMGS_AS_3D_STACK = True
|
|
835
832
|
_C.TEST.POST_PROCESSING = CN()
|
|
836
833
|
_C.TEST.POST_PROCESSING.YZ_FILTERING = False
|
|
837
834
|
_C.TEST.POST_PROCESSING.YZ_FILTERING_SIZE = 5
|
|
@@ -958,6 +955,9 @@ class Config:
|
|
|
958
955
|
_C.PATHS.RESULT_DIR.PER_IMAGE_POST_PROCESSING = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'per_image_post_processing')
|
|
959
956
|
_C.PATHS.RESULT_DIR.FULL_IMAGE = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'full_image')
|
|
960
957
|
_C.PATHS.RESULT_DIR.FULL_IMAGE_BIN = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'full_image_binarized')
|
|
958
|
+
_C.PATHS.RESULT_DIR.FULL_IMAGE_INSTANCES = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'full_image_instances')
|
|
959
|
+
_C.PATHS.RESULT_DIR.FULL_IMAGE_POST_PROCESSING = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'full_image_post_processing')
|
|
960
|
+
_C.PATHS.RESULT_DIR.AS_3D_STACK = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'as_3d_stack')
|
|
961
961
|
_C.PATHS.RESULT_DIR.AS_3D_STACK_POST_PROCESSING = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'as_3d_stack_post_processing')
|
|
962
962
|
_C.PATHS.RESULT_DIR.DET_LOCAL_MAX_COORDS_CHECK = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'per_image_local_max_check')
|
|
963
963
|
_C.PATHS.RESULT_DIR.DET_ASSOC_POINTS = os.path.join(_C.PATHS.RESULT_DIR.PATH, 'point_associations')
|
|
@@ -1190,7 +1190,7 @@ def preprocess_data(cfg, x_data=[], y_data=[], is_2d=True, is_y_mask=False):
|
|
|
1190
1190
|
Preprocessed data. The same structure and dimensionality of the given data will be returned.
|
|
1191
1191
|
"""
|
|
1192
1192
|
|
|
1193
|
-
if cfg.RESIZE.
|
|
1193
|
+
if cfg.RESIZE.ENABLE:
|
|
1194
1194
|
print("Preprocessing: applying resize . . .")
|
|
1195
1195
|
if len(x_data) > 0:
|
|
1196
1196
|
x_data = resize_images(x_data,
|
|
@@ -1216,31 +1216,31 @@ def preprocess_data(cfg, x_data=[], y_data=[], is_2d=True, is_y_mask=False):
|
|
|
1216
1216
|
)
|
|
1217
1217
|
|
|
1218
1218
|
if len(x_data) > 0:
|
|
1219
|
-
if cfg.GAUSSIAN_BLUR.
|
|
1219
|
+
if cfg.GAUSSIAN_BLUR.ENABLE:
|
|
1220
1220
|
print("Preprocessing: applying gaussian blur . . .")
|
|
1221
1221
|
x_data = apply_gaussian_blur(x_data,
|
|
1222
1222
|
sigma = cfg.GAUSSIAN_BLUR.SIGMA,
|
|
1223
1223
|
mode = cfg.GAUSSIAN_BLUR.MODE,
|
|
1224
1224
|
channel_axis = cfg.GAUSSIAN_BLUR.CHANNEL_AXIS,
|
|
1225
1225
|
)
|
|
1226
|
-
if cfg.MEDIAN_BLUR.
|
|
1226
|
+
if cfg.MEDIAN_BLUR.ENABLE:
|
|
1227
1227
|
print("Preprocessing: applying median blur . . .")
|
|
1228
1228
|
x_data = apply_median_blur(x_data,
|
|
1229
1229
|
footprint = cfg.MEDIAN_BLUR.FOOTPRINT,
|
|
1230
1230
|
)
|
|
1231
|
-
if cfg.MATCH_HISTOGRAM.
|
|
1231
|
+
if cfg.MATCH_HISTOGRAM.ENABLE:
|
|
1232
1232
|
print("Preprocessing: applying histogram matching . . .")
|
|
1233
1233
|
x_data = apply_histogram_matching(x_data,
|
|
1234
1234
|
reference_path = cfg.MATCH_HISTOGRAM.REFERENCE_PATH,
|
|
1235
1235
|
is_2d = is_2d,
|
|
1236
1236
|
)
|
|
1237
|
-
if cfg.CLAHE.
|
|
1237
|
+
if cfg.CLAHE.ENABLE:
|
|
1238
1238
|
print("Preprocessing: applying CLAHE . . .")
|
|
1239
1239
|
x_data = apply_clahe(x_data,
|
|
1240
1240
|
kernel_size = cfg.CLAHE.KERNEL_SIZE,
|
|
1241
1241
|
clip_limit = cfg.CLAHE.CLIP_LIMIT,
|
|
1242
1242
|
)
|
|
1243
|
-
if cfg.CANNY.
|
|
1243
|
+
if cfg.CANNY.ENABLE:
|
|
1244
1244
|
print("Preprocessing: applying Canny . . .")
|
|
1245
1245
|
x_data = detect_edges(x_data,
|
|
1246
1246
|
low_threshold = cfg.CANNY.LOW_THRESHOLD,
|
|
@@ -59,7 +59,7 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
59
59
|
self.cross_val_samples_ids = None
|
|
60
60
|
self.post_processing = {}
|
|
61
61
|
self.post_processing['per_image'] = False
|
|
62
|
-
self.post_processing['
|
|
62
|
+
self.post_processing['as_3D_stack'] = False
|
|
63
63
|
self.test_filenames = None
|
|
64
64
|
self.metrics = []
|
|
65
65
|
self.data_norm = None
|
|
@@ -88,18 +88,20 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
88
88
|
self.stats['patch_counter'] = 0
|
|
89
89
|
|
|
90
90
|
# Merging the image
|
|
91
|
-
self.stats['
|
|
92
|
-
self.stats['
|
|
91
|
+
self.stats['iou_merge_patches'] = 0
|
|
92
|
+
self.stats['ov_iou_merge_patches'] = 0
|
|
93
|
+
self.stats['iou_merge_patches_post'] = 0
|
|
94
|
+
self.stats['ov_iou_merge_patches_post'] = 0
|
|
95
|
+
|
|
96
|
+
# As 3D stack
|
|
97
|
+
self.stats['iou_as_3D_stack_post'] = 0
|
|
98
|
+
self.stats['ov_iou_as_3D_stack_post'] = 0
|
|
93
99
|
|
|
94
100
|
# Full image
|
|
95
101
|
self.stats['loss'] = 0
|
|
96
102
|
self.stats['iou'] = 0
|
|
97
103
|
self.stats['ov_iou'] = 0
|
|
98
104
|
|
|
99
|
-
# Post processing
|
|
100
|
-
self.stats['iou_post'] = 0
|
|
101
|
-
self.stats['ov_iou_post'] = 0
|
|
102
|
-
|
|
103
105
|
self.world_size = get_world_size()
|
|
104
106
|
self.global_rank = get_rank()
|
|
105
107
|
if self.cfg.TEST.BY_CHUNKS.ENABLE and self.cfg.PROBLEM.NDIM == '3D':
|
|
@@ -111,7 +113,7 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
111
113
|
# Test variables
|
|
112
114
|
if self.cfg.TEST.ANALIZE_2D_IMGS_AS_3D_STACK and self.cfg.PROBLEM.NDIM == "2D":
|
|
113
115
|
if self.cfg.TEST.POST_PROCESSING.YZ_FILTERING or self.cfg.TEST.POST_PROCESSING.Z_FILTERING:
|
|
114
|
-
self.post_processing['
|
|
116
|
+
self.post_processing['as_3D_stack'] = True
|
|
115
117
|
elif self.cfg.PROBLEM.NDIM == "3D":
|
|
116
118
|
if self.cfg.TEST.POST_PROCESSING.YZ_FILTERING or self.cfg.TEST.POST_PROCESSING.Z_FILTERING:
|
|
117
119
|
self.post_processing['per_image'] = True
|
|
@@ -1119,7 +1121,7 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1119
1121
|
#################
|
|
1120
1122
|
### PER PATCH ###
|
|
1121
1123
|
#################
|
|
1122
|
-
if self.cfg.TEST.
|
|
1124
|
+
if not self.cfg.TEST.FULL_IMG or self.cfg.PROBLEM.NDIM == '3D':
|
|
1123
1125
|
# Reflect data to complete the needed shape
|
|
1124
1126
|
if self.cfg.DATA.REFLECT_TO_COMPLETE_SHAPE:
|
|
1125
1127
|
reflected_orig_shape = self._X.shape
|
|
@@ -1278,49 +1280,45 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1278
1280
|
save_tif(np.expand_dims(pred,0), self.cfg.PATHS.RESULT_DIR.PER_IMAGE, self.processing_filenames,
|
|
1279
1281
|
verbose=self.cfg.TEST.VERBOSE)
|
|
1280
1282
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
if
|
|
1304
|
-
pred,
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
self.processing_filenames, verbose=self.cfg.TEST.VERBOSE)
|
|
1310
|
-
else:
|
|
1311
|
-
save_tif(pred, self.cfg.PATHS.RESULT_DIR.PER_IMAGE_POST_PROCESSING, self.processing_filenames,
|
|
1312
|
-
verbose=self.cfg.TEST.VERBOSE)
|
|
1283
|
+
if self.cfg.DATA.TEST.LOAD_GT and self.cfg.PROBLEM.INSTANCE_SEG.DATA_CHANNELS != "Dv2":
|
|
1284
|
+
if self._Y.ndim > pred.ndim: self._Y = self._Y[0]
|
|
1285
|
+
if self.cfg.LOSS.TYPE != 'MASKED_BCE':
|
|
1286
|
+
_iou_merge_patches = jaccard_index_numpy((self._Y>0.5).astype(np.uint8), (pred>0.5).astype(np.uint8))
|
|
1287
|
+
_ov_iou_merge_patches = voc_calculation((self._Y>0.5).astype(np.uint8), (pred>0.5).astype(np.uint8),
|
|
1288
|
+
_iou_merge_patches)
|
|
1289
|
+
else:
|
|
1290
|
+
exclusion_mask = self._Y < 2
|
|
1291
|
+
binY = self._Y * exclusion_mask.astype( float )
|
|
1292
|
+
_iou_merge_patches = jaccard_index_numpy((binY>0.5).astype(np.uint8), (pred>0.5).astype(np.uint8))
|
|
1293
|
+
_ov_iou_merge_patches = voc_calculation((binY>0.5).astype(np.uint8), (pred>0.5).astype(np.uint8),
|
|
1294
|
+
_iou_merge_patches)
|
|
1295
|
+
self.stats['iou_merge_patches'] += _iou_merge_patches
|
|
1296
|
+
self.stats['ov_iou_merge_patches'] += _ov_iou_merge_patches
|
|
1297
|
+
|
|
1298
|
+
############################
|
|
1299
|
+
### POST-PROCESSING (3D) ###
|
|
1300
|
+
############################
|
|
1301
|
+
if self.post_processing['per_image']:
|
|
1302
|
+
pred, _iou_post, _ov_iou_post = apply_post_processing(self.cfg, pred, self._Y)
|
|
1303
|
+
self.stats['iou_merge_patches_post'] += _iou_post
|
|
1304
|
+
self.stats['ov_iou_merge_patches_post'] += _ov_iou_post
|
|
1305
|
+
if pred.ndim == 4:
|
|
1306
|
+
save_tif(np.expand_dims(pred,0), self.cfg.PATHS.RESULT_DIR.PER_IMAGE_POST_PROCESSING,
|
|
1307
|
+
self.processing_filenames, verbose=self.cfg.TEST.VERBOSE)
|
|
1308
|
+
else:
|
|
1309
|
+
save_tif(pred, self.cfg.PATHS.RESULT_DIR.PER_IMAGE_POST_PROCESSING, self.processing_filenames,
|
|
1310
|
+
verbose=self.cfg.TEST.VERBOSE)
|
|
1313
1311
|
|
|
1314
1312
|
self.after_merge_patches(pred)
|
|
1315
1313
|
|
|
1316
|
-
if
|
|
1314
|
+
if self.cfg.TEST.ANALIZE_2D_IMGS_AS_3D_STACK:
|
|
1317
1315
|
self.all_pred.append(pred)
|
|
1318
1316
|
if self.cfg.DATA.TEST.LOAD_GT: self.all_gt.append(self._Y)
|
|
1319
1317
|
|
|
1320
1318
|
##################
|
|
1321
1319
|
### FULL IMAGE ###
|
|
1322
1320
|
##################
|
|
1323
|
-
if self.cfg.TEST.
|
|
1321
|
+
if self.cfg.TEST.FULL_IMG and self.cfg.PROBLEM.NDIM == '2D':
|
|
1324
1322
|
self._X, o_test_shape = check_downsample_division(self._X, len(self.cfg.MODEL.FEATURE_MAPS)-1)
|
|
1325
1323
|
if self.cfg.DATA.TEST.LOAD_GT:
|
|
1326
1324
|
self._Y, _ = check_downsample_division(self._Y, len(self.cfg.MODEL.FEATURE_MAPS)-1)
|
|
@@ -1398,18 +1396,21 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1398
1396
|
self.stats['iou_per_crop'] = self.stats['iou_per_crop'] / self.stats['patch_counter'] if self.stats['patch_counter'] != 0 else 0
|
|
1399
1397
|
|
|
1400
1398
|
# Merge patches
|
|
1401
|
-
self.stats['
|
|
1402
|
-
self.stats['
|
|
1399
|
+
self.stats['iou_merge_patches'] = self.stats['iou_merge_patches'] / image_counter
|
|
1400
|
+
self.stats['ov_iou_merge_patches'] = self.stats['ov_iou_merge_patches'] / image_counter
|
|
1403
1401
|
|
|
1404
1402
|
# Full image
|
|
1405
1403
|
self.stats['iou'] = self.stats['iou'] / image_counter
|
|
1406
1404
|
self.stats['loss'] = self.stats['loss'] / image_counter
|
|
1407
1405
|
self.stats['ov_iou'] = self.stats['ov_iou'] / image_counter
|
|
1408
1406
|
|
|
1409
|
-
if self.post_processing['per_image']
|
|
1410
|
-
self.stats['
|
|
1411
|
-
self.stats['
|
|
1412
|
-
|
|
1407
|
+
if self.post_processing['per_image']:
|
|
1408
|
+
self.stats['iou_merge_patches_post'] = self.stats['iou_merge_patches_post'] / image_counter
|
|
1409
|
+
self.stats['ov_iou_merge_patches_post'] = self.stats['ov_iou_merge_patches_post'] / image_counter
|
|
1410
|
+
if self.post_processing['as_3D_stack']:
|
|
1411
|
+
self.stats['iou_as_3D_stack_post'] = self.stats['iou_as_3D_stack_post'] / image_counter
|
|
1412
|
+
self.stats['ov_iou_as_3D_stack_post'] = self.stats['ov_iou_as_3D_stack_post'] / image_counter
|
|
1413
|
+
|
|
1413
1414
|
def print_stats(self, image_counter):
|
|
1414
1415
|
"""
|
|
1415
1416
|
Print statistics.
|
|
@@ -1421,15 +1422,14 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1421
1422
|
"""
|
|
1422
1423
|
self.normalize_stats(image_counter)
|
|
1423
1424
|
if self.cfg.DATA.TEST.LOAD_GT:
|
|
1424
|
-
if self.cfg.TEST.
|
|
1425
|
+
if not self.cfg.TEST.FULL_IMG:
|
|
1425
1426
|
print("Loss (per patch): {}".format(self.stats['loss_per_crop']))
|
|
1426
1427
|
print("Test Foreground IoU (per patch): {}".format(self.stats['iou_per_crop']))
|
|
1427
1428
|
print(" ")
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
if self.cfg.TEST.STATS.FULL_IMG:
|
|
1429
|
+
print("Test Foreground IoU (merge patches): {}".format(self.stats['iou_merge_patches']))
|
|
1430
|
+
print("Test Overall IoU (merge patches): {}".format(self.stats['ov_iou_merge_patches']))
|
|
1431
|
+
print(" ")
|
|
1432
|
+
else:
|
|
1433
1433
|
print("Loss (per image): {}".format(self.stats['loss']))
|
|
1434
1434
|
print("Test Foreground IoU (per image): {}".format(self.stats['iou']))
|
|
1435
1435
|
print("Test Overall IoU (per image): {}".format(self.stats['ov_iou']))
|
|
@@ -1439,11 +1439,14 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1439
1439
|
"""
|
|
1440
1440
|
Print post-processing statistics.
|
|
1441
1441
|
"""
|
|
1442
|
-
if self.post_processing['per_image']
|
|
1443
|
-
print("Test Foreground IoU (post-processing): {}".format(self.stats['
|
|
1444
|
-
print("Test Overall IoU (post-processing): {}".format(self.stats['
|
|
1442
|
+
if self.post_processing['per_image']:
|
|
1443
|
+
print("Test Foreground IoU (merge patches - post-processing): {}".format(self.stats['iou_merge_patches_post']))
|
|
1444
|
+
print("Test Overall IoU (merge patches - post-processing): {}".format(self.stats['ov_iou_merge_patches_post']))
|
|
1445
1445
|
print(" ")
|
|
1446
|
-
|
|
1446
|
+
if self.post_processing['as_3D_stack']:
|
|
1447
|
+
print("Test Foreground IoU (as 3D stack - post-processing): {}".format(self.stats['iou_as_3D_stack_post']))
|
|
1448
|
+
print("Test Overall IoU (as 3D stack - post-processing): {}".format(self.stats['ov_iou_as_3D_stack_post']))
|
|
1449
|
+
print(" ")
|
|
1447
1450
|
|
|
1448
1451
|
@abstractmethod
|
|
1449
1452
|
def after_merge_patches(self, pred):
|
|
@@ -1525,10 +1528,10 @@ class Base_Workflow(metaclass=ABCMeta):
|
|
|
1525
1528
|
############################
|
|
1526
1529
|
### POST-PROCESSING (2D) ###
|
|
1527
1530
|
############################
|
|
1528
|
-
if self.post_processing['
|
|
1531
|
+
if self.post_processing['as_3D_stack']:
|
|
1529
1532
|
self.all_pred = np.concatenate(self.all_pred)
|
|
1530
1533
|
self.all_gt = np.concatenate(self.all_gt) if self.cfg.DATA.TEST.LOAD_GT else None
|
|
1531
|
-
self.all_pred, self.stats['
|
|
1534
|
+
self.all_pred, self.stats['iou_as_3D_stack_post'], self.stats['ov_iou_as_3D_stack_post'] = apply_post_processing(self.cfg, self.all_pred, self.all_gt)
|
|
1532
1535
|
save_tif(np.expand_dims(self.all_pred,0), self.cfg.PATHS.RESULT_DIR.AS_3D_STACK_POST_PROCESSING, verbose=self.cfg.TEST.VERBOSE)
|
|
1533
1536
|
|
|
1534
1537
|
def extract_patch_from_dataset(data, cfg, input_queue, extract_info_queue, verbose=False):
|
|
@@ -153,15 +153,9 @@ def check_configuration(cfg, jobname, check_data_paths=True):
|
|
|
153
153
|
assert cfg.PROBLEM.TYPE in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED'],\
|
|
154
154
|
"PROBLEM.TYPE not in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED']"
|
|
155
155
|
|
|
156
|
-
if cfg.PROBLEM.NDIM ==
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if cfg.PROBLEM.NDIM == '3D':
|
|
160
|
-
if not cfg.TEST.STATS.PER_PATCH and not cfg.TEST.STATS.MERGE_PATCHES and cfg.PROBLEM.TYPE != "CLASSIFICATION":
|
|
161
|
-
raise ValueError("At least one between 'TEST.STATS.PER_PATCH' or 'TEST.STATS.MERGE_PATCHES' needs to be True when 'PROBLEM.NDIM'=='3D'")
|
|
162
|
-
if cfg.TEST.STATS.FULL_IMG:
|
|
163
|
-
print("WARNING: TEST.STATS.FULL_IMG == True while using PROBLEM.NDIM == '3D'. As 3D images are usually 'huge'"
|
|
164
|
-
", full image statistics will be disabled to avoid GPU memory overflow")
|
|
156
|
+
if cfg.PROBLEM.NDIM == '3D' and cfg.TEST.FULL_IMG:
|
|
157
|
+
print("WARNING: TEST.FULL_IMG == True while using PROBLEM.NDIM == '3D'. As 3D images are usually 'huge'"
|
|
158
|
+
", full image statistics will be disabled to avoid GPU memory overflow")
|
|
165
159
|
|
|
166
160
|
if cfg.LOSS.TYPE != "CE" and cfg.PROBLEM.TYPE not in ['SEMANTIC_SEG', 'DETECTION']:
|
|
167
161
|
raise ValueError("Not implemented pipeline option: LOSS.TYPE != 'CE' only available in 'SEMANTIC_SEG' and 'DETECTION'")
|
|
@@ -215,12 +209,9 @@ def check_configuration(cfg, jobname, check_data_paths=True):
|
|
|
215
209
|
f"'DATA.PATCH_SIZE' set is {cfg.DATA.PATCH_SIZE}")
|
|
216
210
|
if cfg.PROBLEM.NDIM == '3D':
|
|
217
211
|
raise ValueError("TorchVision model's for semantic segmentation are only available for 2D images")
|
|
218
|
-
if not cfg.TEST.
|
|
219
|
-
raise ValueError("With TorchVision models for semantic segmentation workflow only 'TEST.
|
|
212
|
+
if not cfg.TEST.FULL_IMG:
|
|
213
|
+
raise ValueError("With TorchVision models for semantic segmentation workflow only 'TEST.FULL_IMG' setting is available, so "
|
|
220
214
|
"please set it.")
|
|
221
|
-
if cfg.TEST.STATS.PER_PATCH or cfg.TEST.STATS.MERGE_PATCHES:
|
|
222
|
-
raise ValueError("With TorchVision models for semantic segmentation workflow only 'TEST.STATS.FULL_IMG' setting is available, so "
|
|
223
|
-
"please enable it and disable 'TEST.STATS.PER_PATCH' and 'TEST.STATS.MERGE_PATCHES'")
|
|
224
215
|
if cfg.LOSS.TYPE != "CE":
|
|
225
216
|
raise ValueError("Only 'LOSS.TYPE' = 'CE' is available in semantic segmentation workflow using TorchVision models")
|
|
226
217
|
|
|
@@ -263,12 +254,9 @@ def check_configuration(cfg, jobname, check_data_paths=True):
|
|
|
263
254
|
if cfg.TEST.ANALIZE_2D_IMGS_AS_3D_STACK:
|
|
264
255
|
raise ValueError("'TEST.ANALIZE_2D_IMGS_AS_3D_STACK' can not be activated with TorchVision models for instance segmentation "
|
|
265
256
|
"workflow")
|
|
266
|
-
if not cfg.TEST.
|
|
267
|
-
raise ValueError("With TorchVision models for instance segmentation workflow only 'TEST.
|
|
257
|
+
if not cfg.TEST.FULL_IMG:
|
|
258
|
+
raise ValueError("With TorchVision models for instance segmentation workflow only 'TEST.FULL_IMG' setting is available, so "
|
|
268
259
|
"please set it.")
|
|
269
|
-
if cfg.TEST.STATS.PER_PATCH or cfg.TEST.STATS.MERGE_PATCHES:
|
|
270
|
-
raise ValueError("With TorchVision models for instance segmentation workflow only 'TEST.STATS.FULL_IMG' setting is available, so "
|
|
271
|
-
"please enable it and disable 'TEST.STATS.PER_PATCH' and 'TEST.STATS.MERGE_PATCHES'")
|
|
272
260
|
|
|
273
261
|
#### Detection ####
|
|
274
262
|
if cfg.PROBLEM.TYPE == 'DETECTION':
|
|
@@ -301,12 +289,9 @@ def check_configuration(cfg, jobname, check_data_paths=True):
|
|
|
301
289
|
raise ValueError("TorchVision model's for detection are only available for 2D images")
|
|
302
290
|
if cfg.TRAIN.ENABLE:
|
|
303
291
|
raise NotImplementedError # require bbox generator etc.
|
|
304
|
-
if not cfg.TEST.
|
|
305
|
-
raise ValueError("With TorchVision models for detection workflow only 'TEST.
|
|
292
|
+
if not cfg.TEST.FULL_IMG:
|
|
293
|
+
raise ValueError("With TorchVision models for detection workflow only 'TEST.FULL_IMG' setting is available, so "
|
|
306
294
|
"please set it.")
|
|
307
|
-
if cfg.TEST.STATS.PER_PATCH or cfg.TEST.STATS.MERGE_PATCHES:
|
|
308
|
-
raise ValueError("With TorchVision models for detection workflow only 'TEST.STATS.FULL_IMG' setting is available, so "
|
|
309
|
-
"please enable it and disable 'TEST.STATS.PER_PATCH' and 'TEST.STATS.MERGE_PATCHES'")
|
|
310
295
|
|
|
311
296
|
#### Super-resolution ####
|
|
312
297
|
elif cfg.PROBLEM.TYPE == 'SUPER_RESOLUTION':
|
|
@@ -395,25 +380,25 @@ def check_configuration(cfg, jobname, check_data_paths=True):
|
|
|
395
380
|
|
|
396
381
|
### Pre-processing ###
|
|
397
382
|
if cfg.DATA.PREPROCESS.TRAIN or cfg.DATA.PREPROCESS.TEST or cfg.DATA.PREPROCESS.VAL:
|
|
398
|
-
if cfg.DATA.PREPROCESS.RESIZE.
|
|
383
|
+
if cfg.DATA.PREPROCESS.RESIZE.ENABLE:
|
|
399
384
|
if cfg.PROBLEM.TYPE == 'DETECTION':
|
|
400
385
|
raise ValueError('Resizing preprocessing is not available for the DETECTION workflow.')
|
|
401
386
|
if cfg.PROBLEM.NDIM == '3D':
|
|
402
387
|
if cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE == (512,512):
|
|
403
388
|
opts.extend(['DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE', (512,512,512)])
|
|
404
389
|
elif len(cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE) != 3:
|
|
405
|
-
raise ValueError("When 'PROBLEM.NDIM' is 3D,
|
|
390
|
+
raise ValueError("When 'PROBLEM.NDIM' is 3D, 'DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE' must indicate desired size for each dimension."
|
|
406
391
|
f"Given shape ({cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE}) is not compatible.")
|
|
407
392
|
if cfg.PROBLEM.NDIM == '2D' and len(cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE) != 2:
|
|
408
|
-
raise ValueError("When 'PROBLEM.NDIM' is 2D,
|
|
393
|
+
raise ValueError("When 'PROBLEM.NDIM' is 2D, 'DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE' must indicate desired size for each dimension."
|
|
409
394
|
f"Given shape ({cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE}) is not compatible.")
|
|
410
395
|
for i, s in enumerate(cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE):
|
|
411
396
|
if cfg.DATA.PATCH_SIZE[i] > s:
|
|
412
|
-
raise ValueError(f'
|
|
413
|
-
if cfg.DATA.PREPROCESS.CANNY.
|
|
397
|
+
raise ValueError(f"'DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE' {cfg.DATA.PREPROCESS.RESIZE.OUTPUT_SHAPE} can not be smaller than 'DATA.PATCH_SIZE' {cfg.DATA.PATCH_SIZE}.")
|
|
398
|
+
if cfg.DATA.PREPROCESS.CANNY.ENABLE and cfg.PROBLEM.NDIM != '2D':
|
|
414
399
|
raise ValueError("Canny or edge detection can not be activated when 'PROBLEM.NDIM' is 2D.")
|
|
415
400
|
if not cfg.DATA.PREPROCESS.VAL and cfg.DATA.VAL.FROM_TRAIN and cfg.DATA.PREPROCESS.TRAIN:
|
|
416
|
-
raise ValueError(
|
|
401
|
+
raise ValueError("When 'DATA.VAL.FROM_TRAIN' is True and 'DATA.PREPROCESS.TRAIN' is True, 'DATA.PREPROCESS.VAL' also needs to be True.")
|
|
417
402
|
if cfg.DATA.PREPROCESS.MATCH_HISTOGRAM.ENABLE:
|
|
418
403
|
if not os.path.exists(cfg.DATA.PREPROCESS.MATCH_HISTOGRAM.REFERENCE_PATH):
|
|
419
404
|
raise ValueError(f"Path pointed by 'DATA.PREPROCESS.MATCH_HISTOGRAM.REFERENCE_PATH' does not exist: {cfg.DATA.PREPROCESS.MATCH_HISTOGRAM.REFERENCE_PATH}")
|
|
@@ -45,9 +45,9 @@ class Detection_Workflow(Base_Workflow):
|
|
|
45
45
|
self.stats['d_recall'] = 0
|
|
46
46
|
self.stats['d_f1'] = 0
|
|
47
47
|
|
|
48
|
-
self.stats['
|
|
49
|
-
self.stats['
|
|
50
|
-
self.stats['
|
|
48
|
+
self.stats['d_precision_merge_patches'] = 0
|
|
49
|
+
self.stats['d_recall_merge_patches'] = 0
|
|
50
|
+
self.stats['d_f1_merge_patches'] = 0
|
|
51
51
|
|
|
52
52
|
self.original_test_mask_path = self.prepare_detection_data()
|
|
53
53
|
|
|
@@ -451,11 +451,11 @@ class Detection_Workflow(Base_Workflow):
|
|
|
451
451
|
for nr in range(len(self.cell_count_lines)):
|
|
452
452
|
csvwriter.writerow([nr+1] + self.cell_count_lines[nr])
|
|
453
453
|
if self.cfg.DATA.TEST.LOAD_GT or self.cfg.DATA.TEST.USE_VAL_AS_TEST:
|
|
454
|
-
if self.cfg.TEST.
|
|
455
|
-
self.stats['
|
|
456
|
-
self.stats['
|
|
457
|
-
self.stats['
|
|
458
|
-
|
|
454
|
+
if not self.cfg.TEST.FULL_IMG:
|
|
455
|
+
self.stats['d_precision_merge_patches'] = self.stats['d_precision_merge_patches'] / image_counter
|
|
456
|
+
self.stats['d_recall_merge_patches'] = self.stats['d_recall_merge_patches'] / image_counter
|
|
457
|
+
self.stats['d_f1_merge_patches'] = self.stats['d_f1_merge_patches'] / image_counter
|
|
458
|
+
else:
|
|
459
459
|
self.stats['d_precision'] = self.stats['d_precision'] / image_counter
|
|
460
460
|
self.stats['d_recall'] = self.stats['d_recall'] / image_counter
|
|
461
461
|
self.stats['d_f1'] = self.stats['d_f1'] / image_counter
|
|
@@ -469,7 +469,7 @@ class Detection_Workflow(Base_Workflow):
|
|
|
469
469
|
pred : Torch Tensor
|
|
470
470
|
Model prediction.
|
|
471
471
|
"""
|
|
472
|
-
self.detection_process(pred, self.processing_filenames, ['
|
|
472
|
+
self.detection_process(pred, self.processing_filenames, ['d_precision_merge_patches', 'd_recall_merge_patches', 'd_f1_merge_patches'])
|
|
473
473
|
|
|
474
474
|
def after_merge_patches_by_chunks_proccess_patch(self, filename):
|
|
475
475
|
"""
|
|
@@ -618,7 +618,7 @@ class Detection_Workflow(Base_Workflow):
|
|
|
618
618
|
##################
|
|
619
619
|
### FULL IMAGE ###
|
|
620
620
|
##################
|
|
621
|
-
if self.cfg.TEST.
|
|
621
|
+
if self.cfg.TEST.FULL_IMG:
|
|
622
622
|
# Make the prediction
|
|
623
623
|
with torch.cuda.amp.autocast():
|
|
624
624
|
pred = self.model_call_func(self._X)
|
|
@@ -701,11 +701,11 @@ class Detection_Workflow(Base_Workflow):
|
|
|
701
701
|
|
|
702
702
|
print("Detection specific metrics:")
|
|
703
703
|
if self.cfg.DATA.TEST.LOAD_GT or self.cfg.DATA.TEST.USE_VAL_AS_TEST:
|
|
704
|
-
if self.cfg.TEST.
|
|
705
|
-
print("Detection - Test Precision (merge patches): {}".format(self.stats['
|
|
706
|
-
print("Detection - Test Recall (merge patches): {}".format(self.stats['
|
|
707
|
-
print("Detection - Test F1 (merge patches): {}".format(self.stats['
|
|
708
|
-
|
|
704
|
+
if not self.cfg.TEST.FULL_IMG:
|
|
705
|
+
print("Detection - Test Precision (merge patches): {}".format(self.stats['d_precision_merge_patches']))
|
|
706
|
+
print("Detection - Test Recall (merge patches): {}".format(self.stats['d_recall_merge_patches']))
|
|
707
|
+
print("Detection - Test F1 (merge patches): {}".format(self.stats['d_f1_merge_patches']))
|
|
708
|
+
else:
|
|
709
709
|
print("Detection - Test Precision (per image): {}".format(self.stats['d_precision']))
|
|
710
710
|
print("Detection - Test Recall (per image): {}".format(self.stats['d_recall']))
|
|
711
711
|
print("Detection - Test F1 (per image): {}".format(self.stats['d_f1']))
|