Skip to content

Commit 50fcc51

Browse files
author
Tian-hao Zhang
committed
Merge branch 'master' of github.com:PytorchConnectomics/pytorch_connectomics
2 parents 3434a92 + 61d7925 commit 50fcc51

8 files changed

Lines changed: 126 additions & 126 deletions

File tree

Binary file not shown.

scripts/images_to_h5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def main():
3939
)
4040
print("")
4141
print("Examples:")
42-
print(' python scripts/images_to_h5.py "datasets/images/*.tiff" output.h5')
42+
print(' python scripts/images_to_h5.py "datasets/images/*.tiff" output.h5 seg')
4343
print(' python scripts/images_to_h5.py "/path/to/images/*.png" output.h5')
44-
print(' python scripts/images_to_h5.py "/path/to/labels/*.png" labels.h5 labels')
44+
print(' python scripts/images_to_h5.py "/path/to/labels/*.png" labels.h5 seg')
4545
print("")
4646
print("Note: Use quotes around the input pattern to prevent shell expansion.")
4747
sys.exit(1)

tutorials/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ python scripts/main.py --config tutorials/<config>.yaml
99
## Active top-level configs
1010

1111
- `tutorials/mito_lucchi++.yaml`: Lucchi++ mitochondria segmentation (MONAI UNet).
12-
- `tutorials/mito_mitoEM.yaml`: MitoEM mitochondria instance segmentation (MedNeXt, SDT).
12+
- `tutorials/mito_mitoEM.yaml`: Backward-compatible alias to `mito_mitoEM_30h.yaml`.
13+
- `tutorials/mito_mitoEM_30h.yaml`: MitoEM-Human (EM30-H) instance segmentation (MedNeXt, SDT).
14+
- `tutorials/mito_mitoEM_30r.yaml`: MitoEM-Rat (EM30-R) instance segmentation (MedNeXt, SDT).
15+
- `tutorials/mito_mitoEM_30hr.yaml`: Joint EM30-H + EM30-R training (MedNeXt, SDT).
1316
- `tutorials/mito_mitolab.yaml`: CEM-MitoLab 2D mitochondria segmentation (MedNeXt).
1417
- `tutorials/mito_betaseg.yaml`: BetaSeg mitochondria instance segmentation (MedNeXt, affinity+SDT).
1518
- `tutorials/neuron_snemi.yaml`: SNEMI3D neuron segmentation (RSUNet, affinities).

tutorials/mito_betaseg.yaml

Lines changed: 23 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -45,106 +45,40 @@ model:
4545
- sdt
4646
- - 1
4747
data:
48-
train_path: /projects/weilab/qiongwang/datasets/betaseg/tif
48+
train_path: /projects/weilab/dataset/mito/mitoEM/
4949
train_image:
50-
- high_c3_im.tiff
51-
- low_c1_im.tiff
52-
- low_c2_im.tiff
50+
- EM30-H/im_train_val.h5
5351
train_label:
54-
- high_c3_mito.tiff
55-
- low_c1_mito.tiff
56-
- low_c2_mito.tiff
52+
- EM30-H/mito_train_val.h5
5753
train_resolution:
58-
- 16
59-
- 16
60-
- 16
61-
val_path: /projects/weilab/qiongwang/datasets/betaseg/tif
62-
val_image:
63-
- high_c1_im.tiff
64-
val_label:
65-
- high_c1_mito.tiff
66-
use_preloaded_cache: false
67-
use_cache: true
54+
- 30
55+
- 8
56+
- 8
57+
use_preloaded_cache: true
6858
cache_rate: 1.0
6959
persistent_workers: true
7060
patch_size:
71-
- 128
72-
- 128
73-
- 128
74-
pad_size:
7561
- 16
62+
- 256
63+
- 256
64+
pad_size:
65+
- 4
7666
- 16
7767
- 16
7868
pad_mode: reflect
79-
iter_num_per_epoch: 790
69+
iter_num_per_epoch: 2000
8070
image_transform:
8171
clip_percentile_low: 0.005
8272
clip_percentile_high: 0.995
8373
label_transform:
8474
targets:
85-
- name: affinity
86-
kwargs:
87-
offsets:
88-
- 0-0-1
89-
- 0-1-0
90-
- 1-0-0
91-
- 0-0-10
92-
- 0-10-0
93-
- 10-0-0
94-
- name: skeleton_aware_edt
75+
- name: instance_edt
9576
kwargs:
96-
resolution:
97-
- 16
98-
- 16
99-
- 16
100-
alpha: 0.8
101-
bg_value: -1.0
102-
relabel: true
77+
mode: 3d
78+
quantize: false
79+
normalize: true
10380
augmentation:
104-
preset: some
105-
affine:
106-
enabled: true
107-
prob: 0.5
108-
rotate_range:
109-
- 0.2
110-
- 0.2
111-
- 0.2
112-
scale_range:
113-
- 0.2
114-
- 0.2
115-
- 0.2
116-
shear_range:
117-
- 0.5
118-
- 0.5
119-
- 0.5
120-
intensity:
121-
enabled: true
122-
gaussian_noise_prob: 0.3
123-
gaussian_noise_std: 0.5
124-
shift_intensity_prob: 0.3
125-
shift_intensity_offset: 0.1
126-
contrast_prob: 0.3
127-
contrast_range:
128-
- 0.7
129-
- 1.4
130-
missing_section:
131-
enabled: true
132-
prob: 0.05
133-
num_sections: 2
134-
misalignment:
135-
enabled: true
136-
prob: 0.05
137-
displacement: 10
138-
rotate_ratio: 0.0
139-
flip:
140-
enabled: true
141-
prob: 0.5
142-
rotate:
143-
enabled: true
144-
prob: 0.5
145-
elastic:
146-
enabled: true
147-
prob: 0.3
81+
preset: all
14882
optimization:
14983
max_steps: 1000000
15084
accumulate_grad_batches: 1
@@ -186,23 +120,13 @@ monitor:
186120
divergence_threshold: 100.0
187121
test:
188122
data:
189-
test_image:
190-
- /projects/weilab/qiongwang/datasets/betaseg/tif/high_c2_im.tiff
191-
- /projects/weilab/qiongwang/datasets/betaseg/tif/high_c4_im.tiff
192-
- /projects/weilab/qiongwang/datasets/betaseg/tif/low_c3_im.tiff
193-
test_label:
194-
- /projects/weilab/qiongwang/datasets/betaseg/tif/high_c2_mito.tiff
195-
- /projects/weilab/qiongwang/datasets/betaseg/tif/high_c4_mito.tiff
196-
- /projects/weilab/qiongwang/datasets/betaseg/tif/low_c3_mito.tiff
123+
test_image: /projects/weilab/dataset/mito/mitoEM/EM30-H/im_test.h5
124+
test_label: /projects/weilab/dataset/mito/mitoEM/EM30-H/mito_test.h5
197125
test_resolution:
198-
- 16
199-
- 16
200-
- 16
201-
output_path: outputs/betaseg_mednext_affinity_sdt/results/
202-
image_transform:
203-
normalize: 0-1
204-
clip_percentile_low: 0.005
205-
clip_percentile_high: 0.995
126+
- 30
127+
- 8
128+
- 8
129+
output_path: outputs/mitoem_mednext_sdt/results/
206130
decoding:
207131
- name: decode_distance_watershed
208132
kwargs:

tutorials/mito_mitoEM_30h.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
_base_: mito_mitoEM_common.yaml
2+
3+
experiment_name: mitoem30h_mednext_sdt
4+
data:
5+
train_image:
6+
- EM30-H/im_train.h5
7+
train_label:
8+
- EM30-H/mito_train.h5
9+
val_image:
10+
- EM30-H/im_val.h5
11+
val_label:
12+
- EM30-H/mito_val.h5
13+
monitor:
14+
checkpoint:
15+
dirpath: outputs/mitoem30h_mednext_sdt/checkpoints/
16+
test:
17+
data:
18+
test_image: /projects/weilab/dataset/mito/mitoEM/EM30-H/im_test.h5
19+
test_label: /projects/weilab/dataset/mito/mitoEM/EM30-H/mito_test.h5
20+
output_path: outputs/mitoem30h_mednext_sdt/results/

tutorials/mito_mitoEM_30hr.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
_base_: mito_mitoEM_common.yaml
2+
3+
experiment_name: mitoem30hr_mednext_sdt
4+
data:
5+
train_image:
6+
- EM30-H/im_train.h5
7+
- EM30-R/im_train.h5
8+
train_label:
9+
- EM30-H/mito_train.h5
10+
- EM30-R/mito_train.h5
11+
val_image:
12+
- EM30-H/im_val.h5
13+
- EM30-R/im_val.h5
14+
val_label:
15+
- EM30-H/mito_val.h5
16+
- EM30-R/mito_val.h5
17+
monitor:
18+
checkpoint:
19+
dirpath: outputs/mitoem30hr_mednext_sdt/checkpoints/
20+
test:
21+
data:
22+
test_image:
23+
- /projects/weilab/dataset/mito/mitoEM/EM30-H/im_test.h5
24+
- /projects/weilab/dataset/mito/mitoEM/EM30-R/im_test.h5
25+
test_label:
26+
- /projects/weilab/dataset/mito/mitoEM/EM30-H/mito_test.h5
27+
- /projects/weilab/dataset/mito/mitoEM/EM30-R/mito_test.h5
28+
output_path: outputs/mitoem30hr_mednext_sdt/results/

tutorials/mito_mitoEM_30r.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
_base_: mito_mitoEM_common.yaml
2+
3+
experiment_name: mitoem30r_mednext_sdt
4+
data:
5+
train_image:
6+
- EM30-R/im_train.h5
7+
train_label:
8+
- EM30-R/mito_train.h5
9+
val_image:
10+
- EM30-R/im_val.h5
11+
val_label:
12+
- EM30-R/mito_val.h5
13+
monitor:
14+
checkpoint:
15+
dirpath: outputs/mitoem30r_mednext_sdt/checkpoints/
16+
test:
17+
data:
18+
test_image: /projects/weilab/dataset/mito/mitoEM/EM30-R/im_test.h5
19+
test_label: /projects/weilab/dataset/mito/mitoEM/EM30-R/mito_test.h5
20+
output_path: outputs/mitoem30r_mednext_sdt/results/
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
_base_: bases/mednext.yaml
2+
13
description: MitoEM 3D mitochondria instance segmentation with MedNeXt using SDT only
24
system:
35
training:
46
num_cpus: 8
57
num_workers: 8
6-
batch_size: 16
8+
batch_size: 4
79
inference:
810
num_cpus: 1
911
num_workers: 1
1012
batch_size: 1
1113
seed: 42
1214
model:
1315
input_size:
14-
- 16
16+
- 32
1517
- 256
1618
- 256
1719
output_size:
18-
- 16
20+
- 32
1921
- 256
2022
- 256
2123
out_channels: 1
@@ -31,10 +33,6 @@ model:
3133
- tanh: true
3234
data:
3335
train_path: /projects/weilab/dataset/mito/mitoEM/
34-
train_image:
35-
- EM30-H/im_train_val.h5
36-
train_label:
37-
- EM30-H/mito_train_val.h5
3836
train_resolution:
3937
- 30
4038
- 8
@@ -43,7 +41,7 @@ data:
4341
cache_rate: 1.0
4442
persistent_workers: true
4543
patch_size:
46-
- 16
44+
- 32
4745
- 256
4846
- 256
4947
pad_size:
@@ -66,48 +64,55 @@ data:
6664
preset: all
6765
optimization:
6866
max_epochs: 1000
69-
accumulate_grad_batches: 4
70-
precision: 16-mixed
67+
accumulate_grad_batches: 2
68+
precision: bf16-mixed
69+
deterministic: false
70+
benchmark: true
7171
optimizer:
72-
lr: 0.001
72+
lr: 0.0003
7373
weight_decay: 1e-4
7474
eps: 1.0e-08
7575
scheduler:
76-
name: constant
76+
name: WarmupCosineLR
77+
warmup_epochs: 20
78+
warmup_start_lr: 3.0e-05
79+
min_lr: 1.0e-06
80+
interval: epoch
81+
frequency: 1
82+
ema:
83+
enabled: true
84+
decay: 0.999
85+
warmup_steps: 500
86+
validate_with_ema: true
7787
monitor:
7888
logging:
7989
scalar:
8090
loss:
8191
- train_loss_total_epoch
82-
loss_every_n_steps: 50
92+
- val_loss_total
93+
- val_loss_total_epoch
94+
loss_every_n_steps: 100
8395
val_check_interval: 1.0
8496
images:
8597
max_images: 4
8698
num_slices: 8
8799
log_every_n_epochs: 5
88100
checkpoint:
101+
monitor: val_loss_total_epoch
89102
save_top_k: 5
90-
save_every_n_epochs: 25
91-
dirpath: outputs/mitoem_mednext_sdt/checkpoints/
103+
save_every_n_epochs: 10
92104
early_stopping:
93-
monitor: train_loss_total_epoch
94-
patience: 150
95-
min_delta: 1e-6
96-
threshold: 0.01
97-
divergence_threshold: 100.0
105+
enabled: false
98106
test:
99107
data:
100-
test_image: /projects/weilab/dataset/mito/mitoEM/EM30-H/im_test.h5
101-
test_label: /projects/weilab/dataset/mito/mitoEM/EM30-H/mito_test.h5
102108
test_resolution:
103109
- 30
104110
- 8
105111
- 8
106-
output_path: outputs/mitoem_mednext_sdt/results/
107112
inference:
108113
sliding_window:
109114
window_size:
110-
- 16
115+
- 32
111116
- 256
112117
- 256
113118
sw_batch_size: 4

0 commit comments

Comments
 (0)