-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
1742 lines (1707 loc) · 87.1 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
225
226
227
228
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
318
319
320
321
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import platform
import getpass
from PySide2.QtGui import QPixmap, QMovie
from ui_utils import resource_path
from packaging.version import Version
class Settings:
def __init__(self):
self.settings = {}
self.init_default_settings()
def init_default_settings(self):
self.settings = {}
self.settings["init"] = False
self.settings["page_number"] = 0
# OS
self.settings["os_host"] = platform.system()
if "win" in self.settings["os_host"].lower():
self.settings["user_host"] = getpass.getuser()
# environ["USERNAME"] if platform.startswith("win") else environ["USER"]
else: # Linux, macOS
self.settings["user_host"] = str(os.getuid()) + ":" + str(os.getgid())
# CUDA version match to decide the container to donwload
self.settings["NVIDIA_driver_list"] = [440.33, 520.61]
self.settings["CUDA_version"] = [10.2, 11.8]
self.settings["CUDA_selected"] = "" # to be filled by checking the GPU
# BiaPy
self.settings["biapy_code_version"] = Version("v3.5.5")
self.settings["biapy_code_github"] = "https://github.com/BiaPyX/BiaPy"
self.settings["biapy_gui_version"] = Version("v1.1.3")
self.settings["biapy_gui_github"] = "https://github.com/BiaPyX/BiaPy-GUI"
self.settings["biapy_container_basename"] = "biapyx/biapy"
self.settings["biapy_container_name"] = (
self.settings["biapy_container_basename"] + ":" + str(self.settings["biapy_code_version"]) + "-" + str(self.settings["CUDA_version"][-1])
)
self.settings["biapy_container_sizes"] = ["8GB", "12GB"]
self.settings["biapy_container_size"] = self.settings["biapy_container_sizes"][-1]
self.settings["biapy_container_dockerfile"] = (
"https://raw.githubusercontent.com/BiaPyX/BiaPy/master/biapy/utils/env/Dockerfile"
)
self.settings["yaml_config_file_path"] = ""
self.settings["yaml_config_filename"] = ""
self.settings["output_folder"] = ""
self.settings["biapy_cfg"] = None
self.settings["biapy_container_ready"] = False
# Docker
self.settings["docker_client"] = None
self.settings["docker_found"] = False
self.settings["running_threads"] = []
self.settings["running_workers"] = []
# For all pages
self.settings["advanced_frame_images"] = [
QPixmap(resource_path(os.path.join("images", "bn_images", "up_arrow.svg"))),
QPixmap(resource_path(os.path.join("images", "bn_images", "down_arrow.svg"))),
]
self.settings["info_image"] = QPixmap(resource_path(os.path.join("images", "bn_images", "info.png")))
self.settings["info_image_clicked"] = resource_path(os.path.join("images", "bn_images", "info_clicked.png"))
# Wizard icons
self.settings["wizard_img"] = QPixmap(resource_path(os.path.join("images", "wizard", "wizard.png")))
self.settings["wizard_animation_img"] = QMovie(
resource_path(os.path.join("images", "wizard", "wizard_question_animation.gif"))
)
# Workflow page
self.settings["workflow_names"] = [
"Semantic\nsegmentation",
"Instance\nsegmentation",
"Object\ndetection",
"Image\ndenoising",
"Super\nresolution",
"Self-supervised\nlearning",
"Image\nclassification",
"Image to image",
]
self.settings["workflow_key_names"] = [
"SEMANTIC_SEG",
"INSTANCE_SEG",
"DETECTION",
"DENOISING",
"SUPER_RESOLUTION",
"SELF_SUPERVISED",
"CLASSIFICATION",
"IMAGE_TO_IMAGE",
]
self.settings["selected_workflow"] = 1
self.settings["dot_images"] = self.settings["dot_images"] = [
QPixmap(resource_path(os.path.join("images", "bn_images", "dot_enable.svg"))),
QPixmap(resource_path(os.path.join("images", "bn_images", "dot_disable.svg"))),
]
self.settings["continue_bn_icons"] = None
# Semantic segmentation
self.settings["semantic_models"] = [
"resunet",
"unet",
"resunet++",
"resunet_se",
"unext_v1",
"attention_unet",
"multiresunet",
"seunet",
"unetr",
]
self.settings["semantic_models_real_names"] = [
"Residual U-Net",
"U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"Attention U-Net",
"MultiResUnet",
"SEUnet",
"UNETR",
]
self.settings["semantic_losses"] = [
"CE",
"DICE",
"W_CE_DICE"
]
self.settings["semantic_losses_real_names"] = [
"Cross Entropy (CE)",
"DICE",
"Weighted CE + DICE"
]
self.settings["semantic_metrics"] = [
"iou",
]
self.settings["semantic_metrics_real_names"] = [
"Intersection over union (IoU/Jaccard)",
]
# Instance segmentation
self.settings["instance_models"] = [
"resunet",
"unet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet",
"unetr",
]
self.settings["instance_models_real_names"] = [
"Residual U-Net",
"U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
"UNETR",
]
self.settings["instance_losses"] = [
"CE",
"DICE",
"W_CE_DICE"
]
self.settings["instance_losses_real_names"] = [
"Cross Entropy (CE)",
"DICE",
"Weighted CE + DICE"
]
self.settings["instance_metrics"] = [
"iou",
]
self.settings["instance_metrics_real_names"] = [
"Intersection over union (IoU/Jaccard)",
]
# Detection
self.settings["detection_models"] = [
"resunet",
"unet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet",
"unetr",
]
self.settings["detection_models_real_names"] = [
"Residual U-Net",
"U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
"UNETR",
]
self.settings["detection_losses"] = [
"CE",
"DICE",
"W_CE_DICE"
]
self.settings["detection_losses_real_names"] = [
"Cross Entropy (CE)",
"DICE",
"Weighted CE + DICE"
]
self.settings["detection_metrics"] = [
"iou",
]
self.settings["detection_metrics_real_names"] = [
"Intersection over union (IoU/Jaccard)",
]
# Denoising
self.settings["denoising_models"] = [
"unet",
"resunet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet",
"unetr",
]
self.settings["denoising_models_real_names"] = [
"U-Net",
"Residual U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
"UNETR",
]
self.settings["denoising_losses"] = [
"MSE",
]
self.settings["denoising_losses_real_names"] = [
"Mean square error (MSE/L2)",
]
self.settings["denoising_metrics"] = [
"mae",
"mse"
]
self.settings["denoising_metrics_real_names"] = [
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
]
# Super resolution
self.settings["sr_2d_models"] = [
"rcan",
"edsr",
"dfcan",
"wdsr",
"unet",
"resunet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet",
]
self.settings["sr_2d_models_real_names"] = [
"RCAN",
"EDSR",
"DFCAN",
"WDSR",
"U-Net",
"Residual U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
]
self.settings["sr_3d_models"] = [
"resunet",
"unet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet"
]
self.settings["sr_3d_models_real_names"] = [
"Residual U-Net",
"U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
]
self.settings["sr_losses"] = [
"MAE",
"MSE",
]
self.settings["sr_losses_real_names"] = [
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
]
self.settings["sr_metrics"] = [
"psnr",
"mae",
"mse",
"ssim",
]
self.settings["sr_metrics_real_names"] = [
"Peak signal-to-noise ratio (PSNR)"
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
"Structural similarity index measure (SSIM)"
]
# Self-supervised learning
self.settings["ssl_models"] = [
"mae",
"unet",
"resunet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"multiresunet",
"unetr",
]
self.settings["ssl_models_real_names"] = [
"MAE",
"U-Net",
"Residual U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"MultiResUnet",
"UNETR",
]
self.settings["ssl_losses"] = [
"MAE",
"MSE",
]
self.settings["ssl_losses_real_names"] = [
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
]
self.settings["ssl_metrics"] = [
"psnr",
"mae",
"mse",
"ssim",
]
self.settings["ssl_metrics_real_names"] = [
"Peak signal-to-noise ratio (PSNR)"
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
"Structural similarity index measure (SSIM)"
]
# Classification
self.settings["classification_models"] = [
"ViT",
"simple_cnn",
"efficientnet_b0",
"efficientnet_b1",
"efficientnet_b2",
"efficientnet_b3",
"efficientnet_b4",
"efficientnet_b5",
"efficientnet_b6",
"efficientnet_b7",
]
self.settings["classification_models_real_names"] = [
"ViT",
"Simple CNN",
"EfficientNetB0",
"EfficientNetB1",
"EfficientNetB2",
"EfficientNetB3",
"EfficientNetB4",
"EfficientNetB5",
"EfficientNetB6",
"EfficientNetB7",
]
self.settings["classification_losses"] = [
"CE",
]
self.settings["classification_losses_real_names"] = [
"Cross Entropy (CE)",
]
self.settings["classification_metrics"] = [
"accuracy",
"top-5-accuracy",
]
self.settings["classification_metrics_real_names"] = [
"Accuracy"
"Top-5 Accuracy",
]
# Image to image
self.settings["i2i_models"] = [
"resunet",
"edsr",
"rcan",
"dfcan",
"wdsr",
"unet",
"resunet++",
"resunet_se",
"unext_v1",
"seunet",
"attention_unet",
"unetr",
"multiresunet",
]
self.settings["i2i_models_real_names"] = [
"Residual U-Net",
"EDSR",
"RCAN",
"DFCAN",
"WDSR",
"U-Net",
"ResUNet++",
"ResUNet SE",
"U-NeXt V1",
"SEUnet",
"Attention U-Net",
"UNETR",
"MultiResUnet",
]
self.settings["i2i_losses"] = [
"MAE",
"MSE",
]
self.settings["i2i_losses_real_names"] = [
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
]
self.settings["i2i_metrics"] = [
"psnr",
"mae",
"mse",
"ssim",
]
self.settings["i2i_metrics_real_names"] = [
"Peak signal-to-noise ratio (PSNR)"
"Mean absolute error (MAE/L1)",
"Mean square error (MSE/L2)",
"Structural similarity index measure (SSIM)"
]
# Paths
self.settings["train_data_input_path"] = None
self.settings["train_data_gt_input_path"] = None
self.settings["validation_data_input_path"] = None
self.settings["validation_data_gt_input_path"] = None
self.settings["test_data_input_path"] = None
self.settings["test_data_gt_input_path"] = None
#################################
# Questions to identify workflow
#################################
self.settings["wizard_question_index"] = 0
self.settings["wizard_variable_to_map"] = {}
self.settings["wizard_question_condition"] = {}
self.settings["wizard_questions"] = []
self.settings["wizard_possible_answers"] = []
self.settings["wizard_sections"] = []
self.settings["wizard_from_toc_to_question_index"] = []
self.settings["wizard_from_question_index_to_toc"] = []
self.settings["wizard_question_additional_info"] = []
self.settings["wizard_question_visible"] = []
self.settings["wizard_answers"] = {}
self.settings["wizard_sections"] += [["Problem description", []]]
self.settings["wizard_from_toc_to_question_index"].append([])
q_count = 0
######
# Q1 #
######
self.settings["wizard_questions"] = [
"Are your images in 3D?",
]
self.settings["wizard_variable_to_map"]["Q1"] = {}
self.settings["wizard_possible_answers"] += [["Yes", "No", "No but I would like to have a 3D stack output"]]
self.settings["wizard_variable_to_map"]["Q1"]["PROBLEM.NDIM"] = ["3D", "2D", "2D"]
self.settings["wizard_variable_to_map"]["Q1"]["TEST.ANALIZE_2D_IMGS_AS_3D_STACK"] = [False, False, True]
self.settings["wizard_answers"]["PROBLEM.NDIM"] = -1
self.settings["wizard_answers"]["TEST.ANALIZE_2D_IMGS_AS_3D_STACK"] = -1
self.settings["wizard_sections"][-1][1] += ["Dimensions"]
self.settings["wizard_from_question_index_to_toc"].append(
[0, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(True)
q_count += 1
# Q1 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
The purpose of this question is to determine the type of images you will use. This will help decide which deep learning model will be applied to process your images. The options are:\
</p>\
<ul>\
<li>\
<p><strong>2D images</strong> are considered those that can be represented as (x, y, channels). For example, (512, 1024, 2).</p>\
</li>\
<li>\
<p><strong>3D images</strong> are those that can be represented as (x, y, z, channels). For example, (400, 400, 50, 1).</p>\
</li>\
</ul>\
<p>\
The last option, "No, but I would like to have a 3D stack output," refers to working with 2D images. After processing them with the deep learning model, the images will be combined in sequence to create a 3D stack. This option is useful if your 2D images together form a larger 3D volume.\
</p>"
]
######
# Q2 #
######
self.settings["wizard_questions"] += [
"Do you want to:",
]
self.settings["wizard_possible_answers"] += [
[
"Generate masks of different (or just one) objects/regions within the image",
"Generate masks for each object in the image",
"Count/locate roundish objects within the images (don’t care of the exact mask that circumscribes the objects)",
"Clean noisy images",
"Upsample images into higher resolution",
"Assign a label to each image",
"I want to restore a degraded image",
"I want to generate new images based on an input one",
]
]
self.settings["wizard_variable_to_map"]["Q2"] = {}
self.settings["wizard_variable_to_map"]["Q2"]["PROBLEM.TYPE"] = [
"SEMANTIC_SEG",
"INSTANCE_SEG",
"DETECTION",
"DENOISING",
"SUPER_RESOLUTION",
"CLASSIFICATION",
"IMAGE_TO_IMAGE",
"IMAGE_TO_IMAGE",
]
self.settings["wizard_answers"]["PROBLEM.TYPE"] = -1
self.settings["wizard_sections"][-1][1] += ["Workflow"]
self.settings["wizard_from_question_index_to_toc"].append(
[0, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(True)
q_count += 1
# Q2 additional information
se = resource_path(os.path.join("images", "semantic_seg_raw.png"))
self.settings["wizard_question_additional_info"] += [
"<p>\
This question determines the type of workflow you want to run. Each option corresponds to a workflow implemented in BiaPy.\
The options are:\
</p>\
<p>\
<strong>•"Generate masks of different (or just one) objects/regions within the image"</strong> refers to the workflow called "Semantic segmentation". The goal of this workflow is to assign a class to each pixel (or voxel) of the input image, thus producing a label image with semantic masks. The simplest case would be binary classification, as in the figure depicted below. There, only two labels are present in the label image: black pixels (usually with value 0) represent the background, and white pixels represent the foreground (the wound in this case, usually labeled with 1 or 255 value).\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about semantic segmenation workflow in <a href='https://biapy.readthedocs.io/en/latest/workflows/semantic_segmentation.html'>its documentation</a>.\
</p>\
\
<p>\
<strong>•"Generate masks for each object in the image"</strong> refers to the workflow called "Instance segmentation". The goal of this workflow is to assign a unique ID, i.e. an integer value, to each object of the input image, thus producing a label image with instance masks. An example of this task is displayed in the figure below, with an electron microscopy image used as input (left) and its corresponding instance label image identifying each individual mitochondrion (right). Each color in the mask image corresponds to a unique object.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>Find more information about instance segmenation workflow in <a href='https://biapy.readthedocs.io/en/latest/workflows/instance_segmentation.html'>its documentation</a>.</p>\
\
<p>\
<strong>•"Count/locate roundish objects within the images (don’t care of the exact mask that circumscribes the objects)"</strong> refers to the workflow called "Detection". The goal of this workflow is to localize objects in the input image, not requiring a pixel-level class. Common strategies produce either bounding boxes containing the objects or individual points at their center of mass, which is the one adopted by BiaPy.\
</p>\
<p>\
An example of this task is displayed in the figure below (credits to <a href='https://zenodo.org/records/3715492#.Y4m7FjPMJH6'>Jukkala & Jacquemet</a>), with a fluorescence microscopy image used as input (left) and its corresponding nuclei detection results (rigth). Each red dot in the right image corresponds to a unique predicted object.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about detection workflow in \
<a href='https://biapy.readthedocs.io/en/latest/workflows/detection.html'>its documentation</a>.\
</p>\
\
<p>\
<strong>•"Clean noisy images"</strong> refers to the workflow called "Denoising". The goal of this workflow is to remove noise from the input images. BiaPy makes use of <a href='https://openaccess.thecvf.com/content_CVPR_2019/html/Krull_Noise2Void_-_Learning_Denoising_From_Single_Noisy_Images_CVPR_2019_paper.html'>Nosei2Void</a> with any of the U-Net-like models provided. The main advantage of Noise2Void is neither relying on noise image pairs nor clean target images since frequently clean images are simply unavailable.\
</p>\
<p>\
An example of this task is displayed in the figure below, with an noisy fluorescence image and its corresponding denoised output. This image was obtained from a <a href='https://zenodo.org/record/5156913'>Convallaria dataset</a> used in <a href='https://openaccess.thecvf.com/content_CVPR_2019/html/Krull_Noise2Void_-_Learning_Denoising_From_Single_Noisy_Images_CVPR_2019_paper.html'>Nosei2Void</a>\
project.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about denoising workflow in \
<a href='https://biapy.readthedocs.io/en/latest/workflows/denoising.html'>its documentation</a>.\
</p>\
\
<p>\
<strong>•"Upsample images into higher resolution"</strong> refers to the workflow called "Super resolution". The goal of this workflow is to reconstruct high-resolution (HR) images from low-resolution (LR) ones. If there is a difference in the size of the LR and HR images, typically determined by a scale factor (x2, x4), this task is known as single-image super-resolution. If the size of the LR and HR images is the same, this task is usually referred to as image restoration.\
</p>\
<p>\
An example of this task is displayed in the figure below, with a LR fluorescence microscopy image used as input (left) and its corresponding HR image (x2 scale factor). Credits of this image to <a href='https://figshare.com/articles/dataset/BioSR/13264793'>F-actin dataset by Qiao et al</a>.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about super-resolution workflow in <a href='https://biapy.readthedocs.io/en/latest/workflows/super_resolution.html'>its documentation</a>.\
</p>\
<p>\
<strong>•"Assign a label to each image"</strong> refers to the workflow called "Classification". The goal of this workflow is to assign a label to the input image. In the figure below a few examples of this workflow's input are depicted where each image is classified as a result. Images obtained from <a href='https://medmnist.com/'>MedMNIST v2</a>, concretely from DermaMNIST dataset which is a large collection of multi-source dermatoscopic images of common pigmented skin lesions.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about classification workflow in \
<a href='https://biapy.readthedocs.io/en/latest/workflows/classification.html'>its documentation</a>.\
</p>\
<p>\
<strong>•"I want to restore a degraded image" and "I want to generate new images based on an input one"</strong> both questions refers to the workflow called "Image to image". The goal of this workflow aims at translating/mapping input images into target images. This workflow is as the super-resolution one but with no upsampling, e.g. with the scaling factor to x1.\
</p>\
<p>\
In the figure below an example of paired microscopy images (brightfield) is depicted. The images were obtained from <a href='https://lightmycells.grand-challenge.org/'>Light My Cells dataset</a>. \
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
<p>\
Find more information about image to image workflow in \
<a href='https://biapy.readthedocs.io/en/latest/workflows/image_to_image.html'>its documentation</a>.\
</p>\
".format(
resource_path(os.path.join("images", "wizard","semantic_seg_collage.png")),
resource_path(os.path.join("images", "wizard","instance_seg_collage.png")),
resource_path(os.path.join("images", "wizard","detection_collage.png")),
resource_path(os.path.join("images", "wizard","denoising_collage.png")),
resource_path(os.path.join("images", "wizard","sr_collage.png")),
resource_path(os.path.join("images", "wizard","classification_collage.png")),
resource_path(os.path.join("images", "wizard","i2i_collage.png")),
)
]
######
# Q3 #
######
self.settings["wizard_questions"] += [
"Do you want to use a pre-trained model?",
]
self.settings["wizard_possible_answers"] += [
[
"No, I want to build a model from scratch",
"Yes, I have a model previously trained in BiaPy",
"Yes, I want to check if there is a pretrained model I can use",
]
]
self.settings["wizard_variable_to_map"]["Q3"] = {}
self.settings["wizard_variable_to_map"]["Q3"]["MODEL.SOURCE"] = ["biapy", "biapy", "bmz"]
self.settings["wizard_variable_to_map"]["Q3"]["MODEL.LOAD_CHECKPOINT"] = [False, True, False]
self.settings["wizard_variable_to_map"]["Q3"]["MODEL.LOAD_MODEL_FROM_CHECKPOINT"] = [False, True, False]
self.settings["wizard_answers"]["MODEL.SOURCE"] = -1
self.settings["wizard_answers"]["MODEL.LOAD_CHECKPOINT"] = -1
self.settings["wizard_answers"]["MODEL.LOAD_MODEL_FROM_CHECKPOINT"] = -1
self.settings["wizard_sections"][-1][1] += ["Model source"]
self.settings["wizard_from_question_index_to_toc"].append(
[0, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(True)
q_count += 1
# Q3 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question determines how the deep learning model will be built. Based on your choice, additional questions may appear to guide the model setup process.\
</p>\
<p>\
Before using a deep learning model, it must be trained. The idea is to train the model on a specific task and then apply it to new images. For example, you could train a model to classify images based on their labels. If the training is successful, the model should be able to classify new images automatically.\
</p>\
<p>\
Training is a crucial step to ensure good results, but it requires labeled data, also known as 'ground truth'. Using the image classification example, you would need to label the training images first, like 'image1.png' as class 1, 'image2.png' as class 2, etc. Because training can be time-consuming, using a pre-trained model can be a major advantage. A pre-trained model has already been trained on a dataset and has some level of knowledge.\
</p>\
<p>\
If your images are similar to those used to train the pre-trained model, you might get good results without retraining it. If not, having similar images will at least make the retraining process faster and require fewer images. That's why it’s always a good idea to check for available pre-trained models that match your needs. Here are the options available:\
</p>\
<ul>\
<li>\
<p><strong>'No, I want to build a model from scratch'</strong> This option configures BiaPy to create a model from the ground up. No additional input will be required, and BiaPy will automatically configure the model based on the selected workflow and image dimensions.</p>\
</li>\
<li>\
<p><strong>'Yes, I have a model previously trained in BiaPy'</strong> Choose this option if you already have a model trained with BiaPy. The model must be stored in the folder you’ve selected for saving results, specifically in the 'checkpoints' folder, as a file with a '.pth' extension. You’ll need to specify this file when prompted after selecting this option.</p>\
</li>\
<li>\
<p><strong>'Yes, I want to check if there is a pretrained model I can use'</strong> This option allows you to load a pre-trained model from an external source. Currently, BiaPy supports loading models from the <a href='https://bioimage.io/#/'>BioImage Model Zoo</a> and <a href='https://pytorch.org/vision/stable/models.html'>Torchvision</a>. Depending on the workflow and image dimensions, you can search for compatible models to use.</p>\
</li>\
</ul>\
"
]
######
# Q4 #
######
self.settings["wizard_question_condition"]["Q4"] = {
"or_cond": [ ],
"and_cond": [
["MODEL.SOURCE", "biapy"],
["MODEL.LOAD_CHECKPOINT", True],
],
}
self.settings["wizard_questions"] += [
"Please select the pretrained model trained with BiaPy before:",
]
self.settings["wizard_possible_answers"] += [["MODEL_BIAPY",]]
self.settings["wizard_variable_to_map"]["Q4"] = {}
self.settings["wizard_variable_to_map"]["Q4"]["PATHS.CHECKPOINT_FILE"] = ""
self.settings["wizard_answers"]["PATHS.CHECKPOINT_FILE"] = -1
self.settings["wizard_sections"][-1][1] += ["Path to model"]
self.settings["wizard_from_question_index_to_toc"].append(
[0, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(False)
q_count += 1
# Q4 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question is about setting the path to the pre-trained model in BiaPy. The model should be stored in the folder you previously selected for saving results. Specifically, in the 'checkpoints' folder, there will be a file with a '.pth' extension, which represents the checkpoint of the pre-trained model. You need to locate this file on your system by clicking the 'Browse' button.\
</p>\
"
]
######
# Q5 #
######
self.settings["wizard_question_condition"]["Q5"] = {
"or_cond": [
[
"MODEL.SOURCE",
["bmz", "torchvision"]
],
[
"PROBLEM.TYPE",
[
"SEMANTIC_SEG",
"INSTANCE_SEG",
"DETECTION",
"DENOISING",
"SUPER_RESOLUTION",
"SELF_SUPERVISED",
"CLASSIFICATION",
"IMAGE_TO_IMAGE",
]
],
[
"PROBLEM.NDIM",
["2D", "3D"]
],
],
"and_cond": [],
}
self.settings["wizard_questions"] += [
"Please select a pretrained model by pressing 'Check models' below. This process "
"requires internet connection and may take a while.",
]
self.settings["wizard_possible_answers"] += [["MODEL_OTHERS",]]
self.settings["wizard_variable_to_map"]["Q5"] = {}
self.settings["wizard_variable_to_map"]["Q5"]["MODEL.BMZ.SOURCE_MODEL_ID"] = ""
self.settings["wizard_answers"]["MODEL.BMZ.SOURCE_MODEL_ID"] = -1
self.settings["wizard_sections"][-1][1] += ["Select model"]
self.settings["wizard_from_question_index_to_toc"].append(
[0, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(False)
q_count += 1
# Q5 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question allows you to load a pre-trained model from an external source. Currently, BiaPy supports loading models from the <a href='https://bioimage.io/#/'>BioImage Model Zoo</a> and <a href='https://pytorch.org/vision/stable/models.html'>Torchvision</a>.\
</p>\
<p>\
To search for all available models, click the 'Check models' button. This will start an online search, which requires an internet connection and may take several minutes. Once the process is complete, a new window will appear, displaying all the pre-trained models that can be used for the selected workflow and image dimensions.\
</p>"
]
######
# Q6 #
######
self.settings["wizard_question_condition"]["Q6"] = {
"or_cond": [
[
"PROBLEM.TYPE", # Depends on Q2
[
"SEMANTIC_SEG",
"INSTANCE_SEG",
"DETECTION",
"CLASSIFICATION",
"IMAGE_TO_IMAGE",
],
]
],
"and_cond": [
[
"MODEL.SOURCE",
"biapy"
],
],
}
self.settings["wizard_questions"] += [
"What is the average object width/height in pixels?",
]
self.settings["wizard_possible_answers"] += [
[
"0-25 px",
"25-100 px",
"100-200 px",
"200-500 px",
"More than 500 px",
]
]
self.settings["wizard_variable_to_map"]["Q6"] = {}
self.settings["wizard_variable_to_map"]["Q6"]["DATA.PATCH_SIZE_XY"] = [
(256, 256),
(256, 256),
(512, 512),
(512, 512),
(1024, 1024),
]
self.settings["wizard_variable_to_map"]["Q6"]["TEST.POST_PROCESSING.REMOVE_CLOSE_POINTS_RADIUS"] = [
[10],
[20],
[30],
[30],
[30],
]
self.settings["wizard_answers"]["DATA.PATCH_SIZE_XY"] = -1
self.settings["wizard_answers"]["TEST.POST_PROCESSING.REMOVE_CLOSE_POINTS_RADIUS"] = -1
self.settings["wizard_sections"] += [["Data", []]]
self.settings["wizard_from_toc_to_question_index"].append([])
self.settings["wizard_sections"][-1][1] += ["Object size (xy)"]
self.settings["wizard_from_question_index_to_toc"].append(
[1, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(False)
q_count += 1
# Q6 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question is meant to determine the size of the objects of interest in your images. For example, if you're working on cell nucleus segmentation, you should have a general idea of the size these nuclei will appear in the images.\
</p>\
<p>\
Continuing with the example, in the figure below, several cell nuclei are shown, all roughly the same size. If we measure one at random and find it is 24 pixels wide and 44 pixels tall, we can estimate the size range as '25-100 px'. These measurements don't need to be exact, but they help guide BiaPy to set up a more optimized workflow.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
".format(resource_path(os.path.join("images", "wizard", "object_size.png")))
]
######
# Q7 #
######
self.settings["wizard_question_condition"]["Q7"] = {
"and_cond": [
[
"PROBLEM.NDIM",
"3D"
],
[
"MODEL.SOURCE",
"biapy"
]
],
"or_cond": [
[
"PROBLEM.TYPE",
[
"SEMANTIC_SEG",
"INSTANCE_SEG",
"DETECTION",
"CLASSIFICATION",
"IMAGE_TO_IMAGE",
],
]
],
}
self.settings["wizard_questions"] += [
"How many slices can an object be represented in?",
]
self.settings["wizard_possible_answers"] += [
[
"1-5 slices",
"5-10 slices",
"10-20 slices",
"20-60 slices",
"More than 60 slices",
]
]
self.settings["wizard_variable_to_map"]["Q7"] = {}
self.settings["wizard_variable_to_map"]["Q7"]["DATA.PATCH_SIZE_Z"] = [5, 10, 20, 40, 80]
self.settings["wizard_answers"]["DATA.PATCH_SIZE_Z"] = -1
self.settings["wizard_sections"][-1][1] += ["Object size (z)"]
self.settings["wizard_from_question_index_to_toc"].append(
[1, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(False)
q_count += 1
# Q7 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question aims to determine the size of the objects of interest in your images along the Z axis. For example, if you're working on cell nucleus segmentation, you should have a rough idea of how many slices the nuclei will appear across in the images. Refer to the image below for a clearer, visual understanding of this concept.\
</p>\
<div style='float:center;'>\
<img style='float:center;' src='{}' width='200px'/> \
</div>\
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>\
".format(resource_path(os.path.join("images", "wizard", "object_slices.png")))
]
######
# Q8 #
######
self.settings["wizard_questions"] += [
"What do you want to do?",
]
self.settings["wizard_possible_answers"] += [
[
"Train a model",
"Test a model",
"Train and test the model",
]
]
self.settings["wizard_variable_to_map"]["Q8"] = {}
self.settings["wizard_variable_to_map"]["Q8"]["TRAIN.ENABLE"] = [True, False, True]
self.settings["wizard_variable_to_map"]["Q8"]["TEST.ENABLE"] = [False, True, True]
self.settings["wizard_answers"]["TRAIN.ENABLE"] = -1
self.settings["wizard_answers"]["TEST.ENABLE"] = -1
self.settings["wizard_sections"][-1][1] += ["Phases"]
self.settings["wizard_from_question_index_to_toc"].append(
[1, len(self.settings["wizard_from_toc_to_question_index"][-1])]
)
self.settings["wizard_from_toc_to_question_index"][-1].append(q_count)
self.settings["wizard_question_visible"].append(True)
q_count += 1
# Q8 additional information
self.settings["wizard_question_additional_info"] += [
"<p>\
This question is meant to determine which phases of the workflow you want to perform.\
</p>\
<p>\
Before using a deep learning model, it needs to be trained. The goal is to train the model on a specific task, then apply it to new images. For instance, you might train a model to classify images based on their labels. If the training is successful, the model should be able to classify new images automatically. This final phase is known as 'Test', sometimes referred to as 'Inference' or 'Prediction', which all describe the process of applying the model's knowledge to new data.\
</p>\
"
]
######
# Q9 #
######
self.settings["wizard_question_condition"]["Q9"] = {
"and_cond": [
[
"TRAIN.ENABLE",
True
]
],
"or_cond": [],
}
self.settings["wizard_questions"] += [
"Could you please specify the location of the training raw image folder? After that, click on the 'Check data' button to analyze the data.",
]
self.settings["wizard_possible_answers"] += [["PATH"]]
self.settings["wizard_variable_to_map"]["Q9"] = {}
self.settings["wizard_variable_to_map"]["Q9"]["DATA.TRAIN.PATH"] = ""
self.settings["wizard_answers"]["DATA.TRAIN.PATH"] = -1