Upload pathology_tumor_detection version 0.6.3
Browse files- .gitattributes +1 -0
- LICENSE +201 -0
- configs/inference.json +131 -0
- configs/inference_trt.json +10 -0
- configs/logging.conf +21 -0
- configs/metadata.json +110 -0
- configs/multi_gpu_train.json +42 -0
- configs/train.json +380 -0
- docs/README.md +194 -0
- docs/data_license.txt +128 -0
- models/model.pt +3 -0
- scripts/evaluate_froc.sh +20 -0
- scripts/lesion_froc.py +56 -0
- testing.csv +48 -0
- training.csv +3 -0
- validation.csv +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
training.csv filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
configs/inference.json
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"imports": [
|
3 |
+
"$import glob",
|
4 |
+
"$import os"
|
5 |
+
],
|
6 |
+
"bundle_root": ".",
|
7 |
+
"output_dir": "$os.path.join(@bundle_root, 'eval')",
|
8 |
+
"dataset_dir": "/workspace/data/medical/pathology",
|
9 |
+
"testing_file": "$os.path.join(@bundle_root, 'testing.csv')",
|
10 |
+
"wsi_reader": "cuCIM",
|
11 |
+
"patch_size": [
|
12 |
+
224,
|
13 |
+
224
|
14 |
+
],
|
15 |
+
"number_intensity_ch": 3,
|
16 |
+
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
|
17 |
+
"network_def": {
|
18 |
+
"_target_": "TorchVisionFCModel",
|
19 |
+
"model_name": "resnet18",
|
20 |
+
"num_classes": 1,
|
21 |
+
"use_conv": true,
|
22 |
+
"pretrained": true
|
23 |
+
},
|
24 |
+
"network": "$@network_def.to(@device)",
|
25 |
+
"preprocessing": {
|
26 |
+
"_target_": "Compose",
|
27 |
+
"transforms": [
|
28 |
+
{
|
29 |
+
"_target_": "CastToTyped",
|
30 |
+
"keys": "image",
|
31 |
+
"dtype": "float32"
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"_target_": "ScaleIntensityRanged",
|
35 |
+
"keys": "image",
|
36 |
+
"a_min": 0.0,
|
37 |
+
"a_max": 255.0,
|
38 |
+
"b_min": -1.0,
|
39 |
+
"b_max": 1.0
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"_target_": "ToTensord",
|
43 |
+
"keys": "image"
|
44 |
+
}
|
45 |
+
]
|
46 |
+
},
|
47 |
+
"datalist": {
|
48 |
+
"_target_": "CSVDataset",
|
49 |
+
"src": "@testing_file",
|
50 |
+
"kwargs_read_csv": {
|
51 |
+
"names": [
|
52 |
+
"image"
|
53 |
+
],
|
54 |
+
"header": null
|
55 |
+
},
|
56 |
+
"transform": {
|
57 |
+
"_target_": "Lambdad",
|
58 |
+
"keys": "image",
|
59 |
+
"func": "$lambda x: os.path.join(@dataset_dir, 'testing/images', x + '.tif')"
|
60 |
+
}
|
61 |
+
},
|
62 |
+
"dataset": {
|
63 |
+
"_target_": "MaskedPatchWSIDataset",
|
64 |
+
"data": "@datalist",
|
65 |
+
"mask_level": 6,
|
66 |
+
"patch_size": "@patch_size",
|
67 |
+
"transform": "@preprocessing",
|
68 |
+
"reader": "@wsi_reader"
|
69 |
+
},
|
70 |
+
"dataloader": {
|
71 |
+
"_target_": "DataLoader",
|
72 |
+
"dataset": "@dataset",
|
73 |
+
"batch_size": 400,
|
74 |
+
"shuffle": false,
|
75 |
+
"num_workers": 8
|
76 |
+
},
|
77 |
+
"inferer": {
|
78 |
+
"_target_": "SimpleInferer"
|
79 |
+
},
|
80 |
+
"postprocessing": {
|
81 |
+
"_target_": "Compose",
|
82 |
+
"transforms": [
|
83 |
+
{
|
84 |
+
"_target_": "EnsureTyped",
|
85 |
+
"keys": "pred"
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"_target_": "Activationsd",
|
89 |
+
"keys": "pred",
|
90 |
+
"sigmoid": true
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"_target_": "ToNumpyd",
|
94 |
+
"keys": "pred"
|
95 |
+
}
|
96 |
+
]
|
97 |
+
},
|
98 |
+
"handlers": [
|
99 |
+
{
|
100 |
+
"_target_": "CheckpointLoader",
|
101 |
+
"load_path": "$@bundle_root + '/models/model.pt'",
|
102 |
+
"load_dict": {
|
103 |
+
"model": "@network"
|
104 |
+
}
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"_target_": "StatsHandler",
|
108 |
+
"tag_name": "progress",
|
109 |
+
"iteration_print_logger": "$lambda engine: print(f'image: \"{engine.state.batch[\"image\"].meta[\"name\"][0]}\", iter: {engine.state.iteration}/{engine.state.epoch_length}') if engine.state.iteration % 100 == 0 else None",
|
110 |
+
"output_transform": "$lambda x: None"
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"_target_": "monai.handlers.ProbMapProducer",
|
114 |
+
"output_dir": "@output_dir"
|
115 |
+
}
|
116 |
+
],
|
117 |
+
"evaluator": {
|
118 |
+
"_target_": "SupervisedEvaluator",
|
119 |
+
"device": "@device",
|
120 |
+
"val_data_loader": "@dataloader",
|
121 |
+
"network": "@network",
|
122 |
+
"inferer": "@inferer",
|
123 |
+
"postprocessing": "@postprocessing",
|
124 |
+
"val_handlers": "@handlers",
|
125 |
+
"amp": true,
|
126 |
+
"decollate": false
|
127 |
+
},
|
128 |
+
"run": [
|
129 |
+
"[email protected]()"
|
130 |
+
]
|
131 |
+
}
|
configs/inference_trt.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"imports": [
|
3 |
+
"$import glob",
|
4 |
+
"$import os",
|
5 |
+
"$import torch_tensorrt"
|
6 |
+
],
|
7 |
+
"handlers#0#_disabled_": true,
|
8 |
+
"network_def": "$torch.jit.load(@bundle_root + '/models/model_trt.ts')",
|
9 |
+
"evaluator#amp": false
|
10 |
+
}
|
configs/logging.conf
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[loggers]
|
2 |
+
keys=root
|
3 |
+
|
4 |
+
[handlers]
|
5 |
+
keys=consoleHandler
|
6 |
+
|
7 |
+
[formatters]
|
8 |
+
keys=fullFormatter
|
9 |
+
|
10 |
+
[logger_root]
|
11 |
+
level=INFO
|
12 |
+
handlers=consoleHandler
|
13 |
+
|
14 |
+
[handler_consoleHandler]
|
15 |
+
class=StreamHandler
|
16 |
+
level=INFO
|
17 |
+
formatter=fullFormatter
|
18 |
+
args=(sys.stdout,)
|
19 |
+
|
20 |
+
[formatter_fullFormatter]
|
21 |
+
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
configs/metadata.json
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json",
|
3 |
+
"version": "0.6.3",
|
4 |
+
"changelog": {
|
5 |
+
"0.6.3": "update to huggingface hosting",
|
6 |
+
"0.6.2": "enhance readme for nccl timout issue",
|
7 |
+
"0.6.1": "fix multi-gpu issue",
|
8 |
+
"0.6.0": "use monai 1.4 and update large files",
|
9 |
+
"0.5.9": "update to use monai 1.3.1",
|
10 |
+
"0.5.8": "update readme to add memory warning",
|
11 |
+
"0.5.7": "update channel_def in metadata",
|
12 |
+
"0.5.6": "fix the wrong GPU index issue of multi-node",
|
13 |
+
"0.5.5": "modify mgpu logging level",
|
14 |
+
"0.5.4": "retrain using an internal pretrained ResNet18",
|
15 |
+
"0.5.3": "make the training bundle deterministic",
|
16 |
+
"0.5.2": "update TensorRT descriptions",
|
17 |
+
"0.5.1": "update the TensorRT part in the README file",
|
18 |
+
"0.5.0": "add the command of executing inference with TensorRT models",
|
19 |
+
"0.4.9": "adapt to BundleWorkflow interface",
|
20 |
+
"0.4.8": "update the readme file with TensorRT convert",
|
21 |
+
"0.4.7": "add name tag",
|
22 |
+
"0.4.6": "modify dataset key name",
|
23 |
+
"0.4.5": "update model weights and perfomance metrics",
|
24 |
+
"0.4.4": "restructure readme to match updated template",
|
25 |
+
"0.4.3": "fix wrong figure url",
|
26 |
+
"0.4.2": "update metadata with new metrics",
|
27 |
+
"0.4.1": "Fix inference print logger and froc",
|
28 |
+
"0.4.0": "add lesion FROC calculation and wsi_reader",
|
29 |
+
"0.3.3": "update to use monai 1.0.1",
|
30 |
+
"0.3.2": "enhance readme on commands example",
|
31 |
+
"0.3.1": "fix license Copyright error",
|
32 |
+
"0.3.0": "update license files",
|
33 |
+
"0.2.0": "unify naming",
|
34 |
+
"0.1.1": "fix location variable name change",
|
35 |
+
"0.1.0": "initialize release of the bundle"
|
36 |
+
},
|
37 |
+
"monai_version": "1.4.0",
|
38 |
+
"pytorch_version": "2.4.0",
|
39 |
+
"numpy_version": "1.24.4",
|
40 |
+
"required_packages_version": {
|
41 |
+
"cucim-cu12": "24.6.0",
|
42 |
+
"pandas": "2.2.1",
|
43 |
+
"torchvision": "0.19.0",
|
44 |
+
"pytorch-ignite": "0.4.11",
|
45 |
+
"tensorboard": "2.17.0"
|
46 |
+
},
|
47 |
+
"supported_apps": {},
|
48 |
+
"name": "Pathology tumor detection",
|
49 |
+
"task": "Pathology metastasis detection",
|
50 |
+
"description": "A pre-trained model for metastasis detection on Camelyon 16 dataset.",
|
51 |
+
"authors": "MONAI team",
|
52 |
+
"copyright": "Copyright (c) MONAI Consortium",
|
53 |
+
"data_source": "Camelyon dataset",
|
54 |
+
"data_type": "tiff",
|
55 |
+
"image_classes": "RGB image with intensity between 0 and 255",
|
56 |
+
"label_classes": "binary labels for each patch",
|
57 |
+
"pred_classes": "scalar probability",
|
58 |
+
"eval_metrics": {
|
59 |
+
"accuracy": 0.9,
|
60 |
+
"froc": 0.72
|
61 |
+
},
|
62 |
+
"intended_use": "This is an example, not to be used for diagnostic purposes",
|
63 |
+
"references": [
|
64 |
+
""
|
65 |
+
],
|
66 |
+
"network_data_format": {
|
67 |
+
"inputs": {
|
68 |
+
"image": {
|
69 |
+
"type": "image",
|
70 |
+
"format": "magnitude",
|
71 |
+
"num_channels": 3,
|
72 |
+
"spatial_shape": [
|
73 |
+
224,
|
74 |
+
224
|
75 |
+
],
|
76 |
+
"dtype": "float32",
|
77 |
+
"value_range": [
|
78 |
+
0,
|
79 |
+
255
|
80 |
+
],
|
81 |
+
"is_patch_data": true,
|
82 |
+
"channel_def": {
|
83 |
+
"0": "R",
|
84 |
+
"1": "G",
|
85 |
+
"2": "B"
|
86 |
+
}
|
87 |
+
}
|
88 |
+
},
|
89 |
+
"outputs": {
|
90 |
+
"pred": {
|
91 |
+
"type": "probability",
|
92 |
+
"format": "classification",
|
93 |
+
"num_channels": 1,
|
94 |
+
"spatial_shape": [
|
95 |
+
1,
|
96 |
+
1
|
97 |
+
],
|
98 |
+
"dtype": "float32",
|
99 |
+
"is_patch_data": true,
|
100 |
+
"value_range": [
|
101 |
+
0,
|
102 |
+
1
|
103 |
+
],
|
104 |
+
"channel_def": {
|
105 |
+
"0": "metastasis"
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
configs/multi_gpu_train.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"device": "$torch.device('cuda:' + os.environ['LOCAL_RANK'])",
|
3 |
+
"network": {
|
4 |
+
"_target_": "torch.nn.parallel.DistributedDataParallel",
|
5 |
+
"module": "$@network_def.to(@device)",
|
6 |
+
"device_ids": [
|
7 |
+
"@device"
|
8 |
+
]
|
9 |
+
},
|
10 |
+
"train#sampler": {
|
11 |
+
"_target_": "DistributedSampler",
|
12 |
+
"dataset": "@train#dataset",
|
13 |
+
"even_divisible": true,
|
14 |
+
"shuffle": true
|
15 |
+
},
|
16 |
+
"train#dataloader#sampler": "@train#sampler",
|
17 |
+
"train#dataloader#shuffle": false,
|
18 |
+
"train#trainer#train_handlers": "$@train#handlers[: -2 if dist.get_rank() > 0 else None]",
|
19 |
+
"validate#sampler": {
|
20 |
+
"_target_": "DistributedSampler",
|
21 |
+
"dataset": "@validate#dataset",
|
22 |
+
"even_divisible": false,
|
23 |
+
"shuffle": false
|
24 |
+
},
|
25 |
+
"validate#dataloader#sampler": "@validate#sampler",
|
26 |
+
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
27 |
+
"initialize": [
|
28 |
+
"$import torch.distributed as dist",
|
29 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
30 |
+
"$torch.cuda.set_device(@device)",
|
31 |
+
"$monai.utils.set_determinism(seed=123)",
|
32 |
+
"$import logging",
|
33 |
+
"$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
34 |
+
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
35 |
+
],
|
36 |
+
"run": [
|
37 |
+
"$@train#trainer.run()"
|
38 |
+
],
|
39 |
+
"finalize": [
|
40 |
+
"$dist.destroy_process_group()"
|
41 |
+
]
|
42 |
+
}
|
configs/train.json
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"imports": [
|
3 |
+
"$import os",
|
4 |
+
"$import ignite"
|
5 |
+
],
|
6 |
+
"lr": 0.001,
|
7 |
+
"num_epochs": 4,
|
8 |
+
"val_interval": 1,
|
9 |
+
"bundle_root": ".",
|
10 |
+
"ckpt_dir": "$os.path.join(@bundle_root, 'models')",
|
11 |
+
"output_dir": "$os.path.join(@bundle_root, 'log')",
|
12 |
+
"training_file": "$os.path.join(@bundle_root, 'training.csv')",
|
13 |
+
"validation_file": "$os.path.join(@bundle_root, 'validation.csv')",
|
14 |
+
"dataset_dir": "/workspace/data/medical/pathology",
|
15 |
+
"wsi_reader": "cuCIM",
|
16 |
+
"region_size": [
|
17 |
+
768,
|
18 |
+
768
|
19 |
+
],
|
20 |
+
"patch_size": [
|
21 |
+
224,
|
22 |
+
224
|
23 |
+
],
|
24 |
+
"grid_shape": [
|
25 |
+
3,
|
26 |
+
3
|
27 |
+
],
|
28 |
+
"number_intensity_ch": 3,
|
29 |
+
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
|
30 |
+
"network_def": {
|
31 |
+
"_target_": "TorchVisionFCModel",
|
32 |
+
"model_name": "resnet18",
|
33 |
+
"num_classes": 1,
|
34 |
+
"use_conv": true,
|
35 |
+
"pretrained": false
|
36 |
+
},
|
37 |
+
"network": "$@network_def.to(@device)",
|
38 |
+
"loss": {
|
39 |
+
"_target_": "torch.nn.BCEWithLogitsLoss"
|
40 |
+
},
|
41 |
+
"optimizer": {
|
42 |
+
"_target_": "Novograd",
|
43 |
+
"params": "[email protected]()",
|
44 |
+
"lr": "@lr"
|
45 |
+
},
|
46 |
+
"lr_scheduler": {
|
47 |
+
"_target_": "torch.optim.lr_scheduler.CosineAnnealingLR",
|
48 |
+
"optimizer": "@optimizer",
|
49 |
+
"T_max": "@num_epochs"
|
50 |
+
},
|
51 |
+
"train": {
|
52 |
+
"preprocessing": {
|
53 |
+
"_target_": "Compose",
|
54 |
+
"transforms": [
|
55 |
+
{
|
56 |
+
"_target_": "Lambdad",
|
57 |
+
"keys": [
|
58 |
+
"label"
|
59 |
+
],
|
60 |
+
"func": "$lambda x: x.reshape((1, *@grid_shape))"
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"_target_": "GridSplitd",
|
64 |
+
"keys": [
|
65 |
+
"image",
|
66 |
+
"label"
|
67 |
+
],
|
68 |
+
"grid": "@grid_shape",
|
69 |
+
"size": {
|
70 |
+
"image": "@patch_size",
|
71 |
+
"label": 1
|
72 |
+
}
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"_target_": "ToTensord",
|
76 |
+
"keys": "image"
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"_target_": "TorchVisiond",
|
80 |
+
"keys": "image",
|
81 |
+
"name": "ColorJitter",
|
82 |
+
"brightness": 0.25,
|
83 |
+
"contrast": 0.75,
|
84 |
+
"saturation": 0.25,
|
85 |
+
"hue": 0.04
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"_target_": "ToNumpyd",
|
89 |
+
"keys": "image"
|
90 |
+
},
|
91 |
+
{
|
92 |
+
"_target_": "RandFlipd",
|
93 |
+
"keys": "image",
|
94 |
+
"prob": 0.5
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"_target_": "RandRotate90d",
|
98 |
+
"keys": "image",
|
99 |
+
"prob": 0.5,
|
100 |
+
"max_k": 3,
|
101 |
+
"spatial_axes": [
|
102 |
+
-2,
|
103 |
+
-1
|
104 |
+
]
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"_target_": "CastToTyped",
|
108 |
+
"keys": "image",
|
109 |
+
"dtype": "float32"
|
110 |
+
},
|
111 |
+
{
|
112 |
+
"_target_": "RandZoomd",
|
113 |
+
"keys": "image",
|
114 |
+
"prob": 0.5,
|
115 |
+
"min_zoom": 0.9,
|
116 |
+
"max_zoom": 1.1
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"_target_": "ScaleIntensityRanged",
|
120 |
+
"keys": "image",
|
121 |
+
"a_min": 0.0,
|
122 |
+
"a_max": 255.0,
|
123 |
+
"b_min": -1.0,
|
124 |
+
"b_max": 1.0
|
125 |
+
},
|
126 |
+
{
|
127 |
+
"_target_": "ToTensord",
|
128 |
+
"keys": [
|
129 |
+
"image",
|
130 |
+
"label"
|
131 |
+
]
|
132 |
+
}
|
133 |
+
]
|
134 |
+
},
|
135 |
+
"datalist": {
|
136 |
+
"_target_": "CSVDataset",
|
137 |
+
"src": "@training_file",
|
138 |
+
"col_groups": {
|
139 |
+
"image": 0,
|
140 |
+
"location": [
|
141 |
+
2,
|
142 |
+
1
|
143 |
+
],
|
144 |
+
"label": [
|
145 |
+
3,
|
146 |
+
6,
|
147 |
+
9,
|
148 |
+
4,
|
149 |
+
7,
|
150 |
+
10,
|
151 |
+
5,
|
152 |
+
8,
|
153 |
+
11
|
154 |
+
]
|
155 |
+
},
|
156 |
+
"kwargs_read_csv": {
|
157 |
+
"header": null
|
158 |
+
},
|
159 |
+
"transform": {
|
160 |
+
"_target_": "Lambdad",
|
161 |
+
"keys": "image",
|
162 |
+
"func": "$lambda x: os.path.join(@dataset_dir, 'training/images', x + '.tif')"
|
163 |
+
}
|
164 |
+
},
|
165 |
+
"dataset": {
|
166 |
+
"_target_": "monai.data.wsi_datasets.PatchWSIDataset",
|
167 |
+
"data": "@train#datalist",
|
168 |
+
"patch_level": 0,
|
169 |
+
"patch_size": "@region_size",
|
170 |
+
"reader": "@wsi_reader",
|
171 |
+
"transform": "@train#preprocessing"
|
172 |
+
},
|
173 |
+
"dataloader": {
|
174 |
+
"_target_": "DataLoader",
|
175 |
+
"dataset": "@train#dataset",
|
176 |
+
"batch_size": 128,
|
177 |
+
"pin_memory": false,
|
178 |
+
"num_workers": 8
|
179 |
+
},
|
180 |
+
"inferer": {
|
181 |
+
"_target_": "SimpleInferer"
|
182 |
+
},
|
183 |
+
"postprocessing": {
|
184 |
+
"_target_": "Compose",
|
185 |
+
"transforms": [
|
186 |
+
{
|
187 |
+
"_target_": "Activationsd",
|
188 |
+
"keys": "pred",
|
189 |
+
"sigmoid": true
|
190 |
+
},
|
191 |
+
{
|
192 |
+
"_target_": "AsDiscreted",
|
193 |
+
"keys": "pred",
|
194 |
+
"threshold": 0.5
|
195 |
+
}
|
196 |
+
]
|
197 |
+
},
|
198 |
+
"handlers": [
|
199 |
+
{
|
200 |
+
"_target_": "LrScheduleHandler",
|
201 |
+
"lr_scheduler": "@lr_scheduler",
|
202 |
+
"print_lr": true
|
203 |
+
},
|
204 |
+
{
|
205 |
+
"_target_": "ValidationHandler",
|
206 |
+
"validator": "@validate#evaluator",
|
207 |
+
"epoch_level": true,
|
208 |
+
"interval": "@val_interval"
|
209 |
+
},
|
210 |
+
{
|
211 |
+
"_target_": "StatsHandler",
|
212 |
+
"tag_name": "train_loss",
|
213 |
+
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)"
|
214 |
+
},
|
215 |
+
{
|
216 |
+
"_target_": "TensorBoardStatsHandler",
|
217 |
+
"log_dir": "@output_dir",
|
218 |
+
"tag_name": "train_loss",
|
219 |
+
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)"
|
220 |
+
}
|
221 |
+
],
|
222 |
+
"key_metric": {
|
223 |
+
"train_acc": {
|
224 |
+
"_target_": "ignite.metrics.Accuracy",
|
225 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
226 |
+
}
|
227 |
+
},
|
228 |
+
"trainer": {
|
229 |
+
"_target_": "SupervisedTrainer",
|
230 |
+
"device": "@device",
|
231 |
+
"max_epochs": "@num_epochs",
|
232 |
+
"train_data_loader": "@train#dataloader",
|
233 |
+
"network": "@network",
|
234 |
+
"optimizer": "@optimizer",
|
235 |
+
"loss_function": "@loss",
|
236 |
+
"inferer": "@train#inferer",
|
237 |
+
"amp": true,
|
238 |
+
"postprocessing": "@train#postprocessing",
|
239 |
+
"key_train_metric": "@train#key_metric",
|
240 |
+
"train_handlers": "@train#handlers"
|
241 |
+
}
|
242 |
+
},
|
243 |
+
"validate": {
|
244 |
+
"preprocessing": {
|
245 |
+
"_target_": "Compose",
|
246 |
+
"transforms": [
|
247 |
+
{
|
248 |
+
"_target_": "Lambdad",
|
249 |
+
"keys": "label",
|
250 |
+
"func": "$lambda x: x.reshape((1, *@grid_shape))"
|
251 |
+
},
|
252 |
+
{
|
253 |
+
"_target_": "GridSplitd",
|
254 |
+
"keys": [
|
255 |
+
"image",
|
256 |
+
"label"
|
257 |
+
],
|
258 |
+
"grid": "@grid_shape",
|
259 |
+
"size": {
|
260 |
+
"image": "@patch_size",
|
261 |
+
"label": 1
|
262 |
+
}
|
263 |
+
},
|
264 |
+
{
|
265 |
+
"_target_": "CastToTyped",
|
266 |
+
"keys": "image",
|
267 |
+
"dtype": "float32"
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"_target_": "ScaleIntensityRanged",
|
271 |
+
"keys": "image",
|
272 |
+
"a_min": 0.0,
|
273 |
+
"a_max": 255.0,
|
274 |
+
"b_min": -1.0,
|
275 |
+
"b_max": 1.0
|
276 |
+
},
|
277 |
+
{
|
278 |
+
"_target_": "ToTensord",
|
279 |
+
"keys": [
|
280 |
+
"image",
|
281 |
+
"label"
|
282 |
+
]
|
283 |
+
}
|
284 |
+
]
|
285 |
+
},
|
286 |
+
"datalist": {
|
287 |
+
"_target_": "CSVDataset",
|
288 |
+
"src": "@validation_file",
|
289 |
+
"col_groups": {
|
290 |
+
"image": 0,
|
291 |
+
"location": [
|
292 |
+
2,
|
293 |
+
1
|
294 |
+
],
|
295 |
+
"label": [
|
296 |
+
3,
|
297 |
+
6,
|
298 |
+
9,
|
299 |
+
4,
|
300 |
+
7,
|
301 |
+
10,
|
302 |
+
5,
|
303 |
+
8,
|
304 |
+
11
|
305 |
+
]
|
306 |
+
},
|
307 |
+
"kwargs_read_csv": {
|
308 |
+
"header": null
|
309 |
+
},
|
310 |
+
"transform": {
|
311 |
+
"_target_": "Lambdad",
|
312 |
+
"keys": "image",
|
313 |
+
"func": "$lambda x: os.path.join(@dataset_dir, 'training/images', x + '.tif')"
|
314 |
+
}
|
315 |
+
},
|
316 |
+
"dataset": {
|
317 |
+
"_target_": "monai.data.wsi_datasets.PatchWSIDataset",
|
318 |
+
"data": "@validate#datalist",
|
319 |
+
"patch_level": 0,
|
320 |
+
"patch_size": "@region_size",
|
321 |
+
"reader": "@wsi_reader",
|
322 |
+
"transform": "@validate#preprocessing"
|
323 |
+
},
|
324 |
+
"dataloader": {
|
325 |
+
"_target_": "DataLoader",
|
326 |
+
"dataset": "@validate#dataset",
|
327 |
+
"batch_size": 128,
|
328 |
+
"pin_memory": false,
|
329 |
+
"shuffle": false,
|
330 |
+
"num_workers": 8
|
331 |
+
},
|
332 |
+
"inferer": {
|
333 |
+
"_target_": "SimpleInferer"
|
334 |
+
},
|
335 |
+
"postprocessing": "%train#postprocessing",
|
336 |
+
"handlers": [
|
337 |
+
{
|
338 |
+
"_target_": "StatsHandler",
|
339 |
+
"iteration_log": false
|
340 |
+
},
|
341 |
+
{
|
342 |
+
"_target_": "TensorBoardStatsHandler",
|
343 |
+
"log_dir": "@output_dir",
|
344 |
+
"iteration_log": false
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"_target_": "CheckpointSaver",
|
348 |
+
"save_dir": "@ckpt_dir",
|
349 |
+
"save_dict": {
|
350 |
+
"model": "@network"
|
351 |
+
},
|
352 |
+
"save_key_metric": true,
|
353 |
+
"key_metric_filename": "model.pt"
|
354 |
+
}
|
355 |
+
],
|
356 |
+
"key_metric": {
|
357 |
+
"valid_acc": {
|
358 |
+
"_target_": "ignite.metrics.Accuracy",
|
359 |
+
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])"
|
360 |
+
}
|
361 |
+
},
|
362 |
+
"evaluator": {
|
363 |
+
"_target_": "SupervisedEvaluator",
|
364 |
+
"device": "@device",
|
365 |
+
"val_data_loader": "@validate#dataloader",
|
366 |
+
"network": "@network",
|
367 |
+
"inferer": "@validate#inferer",
|
368 |
+
"postprocessing": "@validate#postprocessing",
|
369 |
+
"key_val_metric": "@validate#key_metric",
|
370 |
+
"val_handlers": "@validate#handlers",
|
371 |
+
"amp": true
|
372 |
+
}
|
373 |
+
},
|
374 |
+
"initialize": [
|
375 |
+
"$monai.utils.set_determinism(seed=15)"
|
376 |
+
],
|
377 |
+
"run": [
|
378 |
+
"$@train#trainer.run()"
|
379 |
+
]
|
380 |
+
}
|
docs/README.md
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Model Overview
|
2 |
+
|
3 |
+
A pre-trained model for automated detection of metastases in whole-slide histopathology images.
|
4 |
+
|
5 |
+
The model is trained based on ResNet18 [1] with the last fully connected layer replaced by a 1x1 convolution layer.
|
6 |
+

|
7 |
+
|
8 |
+
## Data
|
9 |
+
|
10 |
+
All the data used to train, validate, and test this model is from [Camelyon-16 Challenge](https://camelyon16.grand-challenge.org/). You can download all the images for "CAMELYON16" data set from various sources listed [here](https://camelyon17.grand-challenge.org/Data/).
|
11 |
+
|
12 |
+
Location information for training/validation patches (the location on the whole slide image where patches are extracted) are adopted from [NCRF/coords](https://github.com/baidu-research/NCRF/tree/master/coords).
|
13 |
+
|
14 |
+
Annotation information are adopted from [NCRF/jsons](https://github.com/baidu-research/NCRF/tree/master/jsons).
|
15 |
+
|
16 |
+
- Target: Tumor
|
17 |
+
- Task: Detection
|
18 |
+
- Modality: Histopathology
|
19 |
+
- Size: 270 WSIs for training/validation, 48 WSIs for testing
|
20 |
+
|
21 |
+
### Preprocessing
|
22 |
+
|
23 |
+
This bundle expects the training/validation data (whole slide images) reside in a `{dataset_dir}/training/images`. By default `dataset_dir` is pointing to `/workspace/data/medical/pathology/` You can modify `dataset_dir` in the bundle config files to point to a different directory.
|
24 |
+
|
25 |
+
To reduce the computation burden during the inference, patches are extracted only where there is tissue and ignoring the background according to a tissue mask. Please also create a directory for prediction output. By default `output_dir` is set to `eval` folder under the bundle root.
|
26 |
+
|
27 |
+
Please refer to "Annotation" section of [Camelyon challenge](https://camelyon17.grand-challenge.org/Data/) to prepare ground truth images, which are needed for FROC computation. By default, this data set is expected to be at `/workspace/data/medical/pathology/ground_truths`. But it can be modified in `evaluate_froc.sh`.
|
28 |
+
|
29 |
+
## Training configuration
|
30 |
+
|
31 |
+
The training was performed with the following:
|
32 |
+
|
33 |
+
- Config file: train.config
|
34 |
+
- GPU: at least 16 GB of GPU memory.
|
35 |
+
- Actual Model Input: 224 x 224 x 3
|
36 |
+
- AMP: True
|
37 |
+
- Optimizer: Novograd
|
38 |
+
- Learning Rate: 1e-3
|
39 |
+
- Loss: BCEWithLogitsLoss
|
40 |
+
- Whole slide image reader: cuCIM (if running on Windows or Mac, please install `OpenSlide` on your system and change `wsi_reader` to "OpenSlide")
|
41 |
+
|
42 |
+
### Pretrained Weights
|
43 |
+
|
44 |
+
By setting the `"pretrained"` parameter of `TorchVisionFCModel` in the config file to `true`, ImageNet pre-trained weights will be used for training. Please note that these weights are for non-commercial use. Each user is responsible for checking the content of the models/datasets and the applicable licenses and determining if suitable for the intended use. In order to use other pretrained weights, you can use `CheckpointLoader` in train handlers section as the first handler:
|
45 |
+
|
46 |
+
```json
|
47 |
+
{
|
48 |
+
"_target_": "CheckpointLoader",
|
49 |
+
"load_path": "$@bundle_root + '/pretrained_resnet18.pth'",
|
50 |
+
"strict": false,
|
51 |
+
"load_dict": {
|
52 |
+
"model_new": "@network"
|
53 |
+
}
|
54 |
+
}
|
55 |
+
```
|
56 |
+
|
57 |
+
### Input
|
58 |
+
|
59 |
+
The training pipeline is a json file (dataset.json) which includes path to each WSI, the location and the label information for each training patch.
|
60 |
+
|
61 |
+
### Output
|
62 |
+
|
63 |
+
A probability number of the input patch being tumor or normal.
|
64 |
+
|
65 |
+
### Memory Consumption Warning
|
66 |
+
|
67 |
+
If you face memory issues in traning, you can lower the `batch_size` in the configurations to reduce the System RAM requirements.
|
68 |
+
|
69 |
+
### Inference on a WSI
|
70 |
+
|
71 |
+
Inference is performed on WSI in a sliding window manner with specified stride. A foreground mask is needed to specify the region where the inference will be performed on, given that background region which contains no tissue at all can occupy a significant portion of a WSI. Output of the inference pipeline is a probability map of size 1/stride of original WSI size.
|
72 |
+
|
73 |
+
### Note on determinism
|
74 |
+
|
75 |
+
By default this bundle use a deterministic approach to make the results reproducible. However, it comes at a cost of performance loss. Thus if you do not care about reproducibility, you can have a performance gain by replacing `"$monai.utils.set_determinism"` line with `"$setattr(torch.backends.cudnn, 'benchmark', True)"` in initialize section of training configuration (`configs/train.json` and `configs/multi_gpu_train.json` for single GPU and multi-GPU training respectively).
|
76 |
+
|
77 |
+
## Performance
|
78 |
+
|
79 |
+
FROC score is used for evaluating the performance of the model. After inference is done, `evaluate_froc.sh` needs to be run to evaluate FROC score based on predicted probability map (output of inference) and the ground truth tumor masks.
|
80 |
+
Using an internal pretrained weights for ResNet18, this model deterministically achieves the 0.90 accuracy on validation patches, and FROC of 0.72 on the 48 Camelyon testing data that have ground truth annotations available.
|
81 |
+
|
82 |
+

|
83 |
+
|
84 |
+
The `pathology_tumor_detection` bundle supports acceleration with TensorRT. The table below displays the speedup ratios observed on an A100 80G GPU.
|
85 |
+
|
86 |
+
Please notice that the benchmark results are tested on one WSI image since the images are too large to benchmark. And the inference time in the end-to-end line stands for one patch of the whole image.
|
87 |
+
|
88 |
+
| method | torch_fp32(ms) | torch_amp(ms) | trt_fp32(ms) | trt_fp16(ms) | speedup amp | speedup fp32 | speedup fp16 | amp vs fp16|
|
89 |
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
90 |
+
| model computation |1.93 | 2.52 | 1.61 | 1.33 | 0.77 | 1.20 | 1.45 | 1.89 |
|
91 |
+
| end2end |224.97 | 223.50 | 222.65 | 224.03 | 1.01 | 1.01 | 1.00 | 1.00 |
|
92 |
+
|
93 |
+
Where:
|
94 |
+
|
95 |
+
- `model computation` means the speedup ratio of model's inference with a random input without preprocessing and postprocessing
|
96 |
+
- `end2end` means run the bundle end-to-end with the TensorRT based model.
|
97 |
+
- `torch_fp32` and `torch_amp` are for the PyTorch models with or without `amp` mode.
|
98 |
+
- `trt_fp32` and `trt_fp16` are for the TensorRT based models converted in corresponding precision.
|
99 |
+
- `speedup amp`, `speedup fp32` and `speedup fp16` are the speedup ratios of corresponding models versus the PyTorch float32 model
|
100 |
+
- `amp vs fp16` is the speedup ratio between the PyTorch amp model and the TensorRT float16 based model.
|
101 |
+
|
102 |
+
This result is benchmarked under:
|
103 |
+
|
104 |
+
- TensorRT: 8.5.3+cuda11.8
|
105 |
+
- Torch-TensorRT Version: 1.4.0
|
106 |
+
- CPU Architecture: x86-64
|
107 |
+
- OS: ubuntu 20.04
|
108 |
+
- Python version:3.8.10
|
109 |
+
- CUDA version: 12.0
|
110 |
+
- GPU models and configuration: A100 80G
|
111 |
+
|
112 |
+
## MONAI Bundle Commands
|
113 |
+
|
114 |
+
In addition to the Pythonic APIs, a few command line interfaces (CLI) are provided to interact with the bundle. The CLI supports flexible use cases, such as overriding configs at runtime and predefining arguments in a file.
|
115 |
+
|
116 |
+
For more details usage instructions, visit the [MONAI Bundle Configuration Page](https://docs.monai.io/en/latest/config_syntax.html).
|
117 |
+
|
118 |
+
#### Execute training
|
119 |
+
|
120 |
+
```
|
121 |
+
python -m monai.bundle run --config_file configs/train.json
|
122 |
+
```
|
123 |
+
|
124 |
+
Please note that if the default dataset path is not modified with the actual path in the bundle config files, you can also override it by using `--dataset_dir`:
|
125 |
+
|
126 |
+
```
|
127 |
+
python -m monai.bundle run --config_file configs/train.json --dataset_dir <actual dataset path>
|
128 |
+
```
|
129 |
+
|
130 |
+
#### Override the `train` config to execute multi-GPU training
|
131 |
+
|
132 |
+
```
|
133 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
|
134 |
+
```
|
135 |
+
|
136 |
+
Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).
|
137 |
+
|
138 |
+
**Note:** When using a container based on [PyTorch 24.0x](https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes), you may encounter random NCCL timeout errors. To address this issue, consider the following adjustments:
|
139 |
+
|
140 |
+
- Reduce the `num_workers`: Decreasing the number of data loader workers can help minimize these errors.
|
141 |
+
- Set `pin_memory` to `False`: Disabling pinned memory may reduce the likelihood of timeouts.
|
142 |
+
- Switch to the `gloo` backend: As a workaround, you can set the distributed training backend to `gloo` to avoid NCCL-related timeouts.
|
143 |
+
|
144 |
+
You can implement these settings by adding flags like `--train#dataloader#num_workers 0` or `--train#dataloader#pin_memory false`.
|
145 |
+
|
146 |
+
#### Execute inference
|
147 |
+
|
148 |
+
```
|
149 |
+
CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run --config_file configs/inference.json
|
150 |
+
```
|
151 |
+
|
152 |
+
#### Evaluate FROC metric
|
153 |
+
|
154 |
+
```
|
155 |
+
cd scripts && source evaluate_froc.sh
|
156 |
+
```
|
157 |
+
|
158 |
+
#### Export checkpoint to TorchScript file
|
159 |
+
|
160 |
+
```
|
161 |
+
python -m monai.bundle ckpt_export network_def --filepath models/model.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json
|
162 |
+
```
|
163 |
+
|
164 |
+
#### Export checkpoint to TensorRT based models with fp32 or fp16 precision
|
165 |
+
|
166 |
+
```
|
167 |
+
python -m monai.bundle trt_export --net_id network_def --filepath models/model_trt.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json --precision <fp32/fp16> --dynamic_batchsize "[1, 400, 600]"
|
168 |
+
```
|
169 |
+
|
170 |
+
#### Execute inference with the TensorRT model
|
171 |
+
|
172 |
+
```
|
173 |
+
python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
|
174 |
+
```
|
175 |
+
|
176 |
+
# References
|
177 |
+
|
178 |
+
[1] He, Kaiming, et al, "Deep Residual Learning for Image Recognition." In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770-778. 2016. <https://arxiv.org/pdf/1512.03385.pdf>
|
179 |
+
|
180 |
+
# License
|
181 |
+
|
182 |
+
Copyright (c) MONAI Consortium
|
183 |
+
|
184 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
185 |
+
you may not use this file except in compliance with the License.
|
186 |
+
You may obtain a copy of the License at
|
187 |
+
|
188 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
189 |
+
|
190 |
+
Unless required by applicable law or agreed to in writing, software
|
191 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
192 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
193 |
+
See the License for the specific language governing permissions and
|
194 |
+
limitations under the License.
|
docs/data_license.txt
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CAMELYON16 data set by Computational Pathology Group of Radboud University
|
2 |
+
Medical Centre
|
3 |
+
|
4 |
+
CAMELYON16 data set is available under CC0.
|
5 |
+
|
6 |
+
==========================================================================
|
7 |
+
|
8 |
+
Creative Commons Legal Code
|
9 |
+
|
10 |
+
CC0 1.0 Universal
|
11 |
+
|
12 |
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
13 |
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
14 |
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
15 |
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
16 |
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
17 |
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
18 |
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
19 |
+
HEREUNDER.
|
20 |
+
|
21 |
+
Statement of Purpose
|
22 |
+
|
23 |
+
The laws of most jurisdictions throughout the world automatically confer
|
24 |
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
25 |
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
26 |
+
authorship and/or a database (each, a "Work").
|
27 |
+
|
28 |
+
Certain owners wish to permanently relinquish those rights to a Work for
|
29 |
+
the purpose of contributing to a commons of creative, cultural and
|
30 |
+
scientific works ("Commons") that the public can reliably and without fear
|
31 |
+
of later claims of infringement build upon, modify, incorporate in other
|
32 |
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
33 |
+
and for any purposes, including without limitation commercial purposes.
|
34 |
+
These owners may contribute to the Commons to promote the ideal of a free
|
35 |
+
culture and the further production of creative, cultural and scientific
|
36 |
+
works, or to gain reputation or greater distribution for their Work in
|
37 |
+
part through the use and efforts of others.
|
38 |
+
|
39 |
+
For these and/or other purposes and motivations, and without any
|
40 |
+
expectation of additional consideration or compensation, the person
|
41 |
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
42 |
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
43 |
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
44 |
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
45 |
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
46 |
+
|
47 |
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
48 |
+
protected by copyright and related or neighboring rights ("Copyright and
|
49 |
+
Related Rights"). Copyright and Related Rights include, but are not
|
50 |
+
limited to, the following:
|
51 |
+
|
52 |
+
i. the right to reproduce, adapt, distribute, perform, display,
|
53 |
+
communicate, and translate a Work;
|
54 |
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
55 |
+
iii. publicity and privacy rights pertaining to a person's image or
|
56 |
+
likeness depicted in a Work;
|
57 |
+
iv. rights protecting against unfair competition in regards to a Work,
|
58 |
+
subject to the limitations in paragraph 4(a), below;
|
59 |
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
60 |
+
in a Work;
|
61 |
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
62 |
+
European Parliament and of the Council of 11 March 1996 on the legal
|
63 |
+
protection of databases, and under any national implementation
|
64 |
+
thereof, including any amended or successor version of such
|
65 |
+
directive); and
|
66 |
+
vii. other similar, equivalent or corresponding rights throughout the
|
67 |
+
world based on applicable law or treaty, and any national
|
68 |
+
implementations thereof.
|
69 |
+
|
70 |
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
71 |
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
72 |
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
73 |
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
74 |
+
of action, whether now known or unknown (including existing as well as
|
75 |
+
future claims and causes of action), in the Work (i) in all territories
|
76 |
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
77 |
+
treaty (including future time extensions), (iii) in any current or future
|
78 |
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
79 |
+
including without limitation commercial, advertising or promotional
|
80 |
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
81 |
+
member of the public at large and to the detriment of Affirmer's heirs and
|
82 |
+
successors, fully intending that such Waiver shall not be subject to
|
83 |
+
revocation, rescission, cancellation, termination, or any other legal or
|
84 |
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
85 |
+
as contemplated by Affirmer's express Statement of Purpose.
|
86 |
+
|
87 |
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
88 |
+
be judged legally invalid or ineffective under applicable law, then the
|
89 |
+
Waiver shall be preserved to the maximum extent permitted taking into
|
90 |
+
account Affirmer's express Statement of Purpose. In addition, to the
|
91 |
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
92 |
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
93 |
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
94 |
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
95 |
+
maximum duration provided by applicable law or treaty (including future
|
96 |
+
time extensions), (iii) in any current or future medium and for any number
|
97 |
+
of copies, and (iv) for any purpose whatsoever, including without
|
98 |
+
limitation commercial, advertising or promotional purposes (the
|
99 |
+
"License"). The License shall be deemed effective as of the date CC0 was
|
100 |
+
applied by Affirmer to the Work. Should any part of the License for any
|
101 |
+
reason be judged legally invalid or ineffective under applicable law, such
|
102 |
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
103 |
+
of the License, and in such case Affirmer hereby affirms that he or she
|
104 |
+
will not (i) exercise any of his or her remaining Copyright and Related
|
105 |
+
Rights in the Work or (ii) assert any associated claims and causes of
|
106 |
+
action with respect to the Work, in either case contrary to Affirmer's
|
107 |
+
express Statement of Purpose.
|
108 |
+
|
109 |
+
4. Limitations and Disclaimers.
|
110 |
+
|
111 |
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
112 |
+
surrendered, licensed or otherwise affected by this document.
|
113 |
+
b. Affirmer offers the Work as-is and makes no representations or
|
114 |
+
warranties of any kind concerning the Work, express, implied,
|
115 |
+
statutory or otherwise, including without limitation warranties of
|
116 |
+
title, merchantability, fitness for a particular purpose, non
|
117 |
+
infringement, or the absence of latent or other defects, accuracy, or
|
118 |
+
the present or absence of errors, whether or not discoverable, all to
|
119 |
+
the greatest extent permissible under applicable law.
|
120 |
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
121 |
+
that may apply to the Work or any use thereof, including without
|
122 |
+
limitation any person's Copyright and Related Rights in the Work.
|
123 |
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
124 |
+
consents, permissions or other rights required for any use of the
|
125 |
+
Work.
|
126 |
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
127 |
+
party to this document and has no duty or obligation with respect to
|
128 |
+
this CC0 or use of the Work.
|
models/model.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5a0d9b9e714e18a90c1f7f7d9c7e47f807c59f9f8c681b84865fae208fcbb4d6
|
3 |
+
size 44780565
|
scripts/evaluate_froc.sh
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
LEVEL=6
|
4 |
+
SPACING=0.243
|
5 |
+
READER=openslide
|
6 |
+
EVAL_DIR=../eval
|
7 |
+
GROUND_TRUTH_DIR=/workspace/data/medical/pathology/testing/ground_truths
|
8 |
+
|
9 |
+
echo "=> Level= ${LEVEL}"
|
10 |
+
echo "=> Spacing = ${SPACING}"
|
11 |
+
echo "=> WSI Reader: ${READER}"
|
12 |
+
echo "=> Evaluation output directory: ${EVAL_DIR}"
|
13 |
+
echo "=> Ground truth directory: ${GROUND_TRUTH_DIR}"
|
14 |
+
|
15 |
+
python3 ./lesion_froc.py \
|
16 |
+
--level $LEVEL \
|
17 |
+
--spacing $SPACING \
|
18 |
+
--reader $READER \
|
19 |
+
--eval-dir ${EVAL_DIR} \
|
20 |
+
--ground-truth-dir ${GROUND_TRUTH_DIR}
|
scripts/lesion_froc.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
|
4 |
+
from monai.apps.pathology import LesionFROC
|
5 |
+
|
6 |
+
|
7 |
+
def full_path(dir: str, file: str):
|
8 |
+
return os.path.normpath(os.path.join(dir, file))
|
9 |
+
|
10 |
+
|
11 |
+
def load_data(ground_truth_dir: str, eval_dir: str, level: int, spacing: float):
|
12 |
+
# Get the list of probability map result files
|
13 |
+
prob_files = os.listdir(eval_dir)
|
14 |
+
|
15 |
+
# read the dataset and create an eval_dataset based on that.
|
16 |
+
eval_dataset = []
|
17 |
+
for prob_name in prob_files:
|
18 |
+
if prob_name.endswith(".npy"):
|
19 |
+
sample = {
|
20 |
+
"tumor_mask": full_path(ground_truth_dir, prob_name.replace("npy", "tif")),
|
21 |
+
"prob_map": full_path(eval_dir, prob_name),
|
22 |
+
"level": level,
|
23 |
+
"pixel_spacing": spacing,
|
24 |
+
}
|
25 |
+
|
26 |
+
eval_dataset.append(sample)
|
27 |
+
|
28 |
+
return eval_dataset
|
29 |
+
|
30 |
+
|
31 |
+
def evaluate_froc(data, reader):
|
32 |
+
lesion_froc = LesionFROC(data, image_reader_name=reader)
|
33 |
+
score = lesion_froc.evaluate()
|
34 |
+
return score
|
35 |
+
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
# Parse command line arguments
|
39 |
+
parser = argparse.ArgumentParser()
|
40 |
+
parser.add_argument("-s", "--spacing", type=float, default=0.243, dest="spacing")
|
41 |
+
parser.add_argument("-l", "--level", type=int, default=6, dest="level")
|
42 |
+
parser.add_argument("-r", "--reader", type=str, default="cucim", dest="reader")
|
43 |
+
parser.add_argument("-e", "--eval-dir", type=str, dest="eval_dir")
|
44 |
+
parser.add_argument("-g", "--ground-truth-dir", type=str, dest="ground_truth_dir")
|
45 |
+
args = parser.parse_args()
|
46 |
+
|
47 |
+
# prepare FROC input data
|
48 |
+
data = load_data(args.ground_truth_dir, args.eval_dir, args.level, args.spacing)
|
49 |
+
if len(data) < 1:
|
50 |
+
raise RuntimeError(f"No probability map result found in '{args.eval_dir}' with '.npy' extension.")
|
51 |
+
|
52 |
+
# evaluate FROC
|
53 |
+
score = evaluate_froc(data, args.reader)
|
54 |
+
with open(full_path(args.eval_dir, "froc_score.txt"), "w") as f:
|
55 |
+
f.write(f"FROC Score: {score}\n")
|
56 |
+
print(f"FROC Score: {score}")
|
testing.csv
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
test_001
|
2 |
+
test_002
|
3 |
+
test_004
|
4 |
+
test_008
|
5 |
+
test_010
|
6 |
+
test_011
|
7 |
+
test_013
|
8 |
+
test_016
|
9 |
+
test_021
|
10 |
+
test_026
|
11 |
+
test_027
|
12 |
+
test_029
|
13 |
+
test_030
|
14 |
+
test_033
|
15 |
+
test_038
|
16 |
+
test_040
|
17 |
+
test_046
|
18 |
+
test_048
|
19 |
+
test_051
|
20 |
+
test_052
|
21 |
+
test_061
|
22 |
+
test_064
|
23 |
+
test_065
|
24 |
+
test_066
|
25 |
+
test_068
|
26 |
+
test_069
|
27 |
+
test_071
|
28 |
+
test_073
|
29 |
+
test_074
|
30 |
+
test_075
|
31 |
+
test_079
|
32 |
+
test_082
|
33 |
+
test_084
|
34 |
+
test_090
|
35 |
+
test_092
|
36 |
+
test_094
|
37 |
+
test_097
|
38 |
+
test_099
|
39 |
+
test_102
|
40 |
+
test_104
|
41 |
+
test_105
|
42 |
+
test_108
|
43 |
+
test_110
|
44 |
+
test_113
|
45 |
+
test_116
|
46 |
+
test_117
|
47 |
+
test_121
|
48 |
+
test_122
|
training.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e3e51c55b11485c51fea7f9dab7811edc120ab473da0f1349c4bf40c9d15d0b4
|
3 |
+
size 20690435
|
validation.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|