Skip to content

Commit 7dd06e1

Browse files
authored
Add endoscopy integration test infer and trainer (#1071)
1 parent 5b7b45c commit 7dd06e1

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

runtests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,5 @@ if [ $doNetTests = true ]; then
470470
run_integration_tests "radiology" "tests/data/dataset/local/spleen" "deepedit,segmentation_spleen,segmentation,deepgrow_2d,deepgrow_3d"
471471
run_integration_tests "pathology" "tests/data/pathology" "deepedit_nuclei,segmentation_nuclei,nuclick"
472472
run_integration_tests "monaibundle" "tests/data/dataset/local/spleen" "spleen_ct_segmentation_v0.1.0,spleen_deepedit_annotation_v0.1.0,swin_unetr_btcv_segmentation_v0.1.0"
473+
run_integration_tests "endoscopy" "tests/data/endoscopy" "tooltracking,inbody,deepedit"
473474
fi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) MONAI Consortium
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) MONAI Consortium
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
import unittest
12+
13+
import requests
14+
import torch
15+
16+
from tests.integration import SERVER_URI
17+
18+
19+
class EndPointInfer(unittest.TestCase):
20+
def test_tooltracking(self):
21+
if not torch.cuda.is_available():
22+
return
23+
24+
model = "tooltracking"
25+
image = "Video_2_VTS_01_1_Trim_04-40_f600"
26+
27+
response = requests.post(f"{SERVER_URI}/infer/{model}?image={image}")
28+
assert response.status_code == 200
29+
30+
def test_inbody(self):
31+
if not torch.cuda.is_available():
32+
return
33+
34+
model = "inbody"
35+
image = "Video_2_VTS_01_1_Trim_04-40_f600"
36+
37+
response = requests.post(f"{SERVER_URI}/infer/{model}?image={image}&output=json")
38+
assert response.status_code == 200
39+
40+
def test_deepedit(self):
41+
if not torch.cuda.is_available():
42+
return
43+
44+
model = "deepedit"
45+
image = "Video_2_VTS_01_1_Trim_04-40_f600"
46+
47+
response = requests.post(f"{SERVER_URI}/infer/{model}?image={image}")
48+
assert response.status_code == 200
49+
50+
51+
if __name__ == "__main__":
52+
unittest.main()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) MONAI Consortium
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
import unittest
12+
13+
import requests
14+
import torch
15+
16+
from tests.integration import SERVER_URI
17+
18+
19+
class EndPointSession(unittest.TestCase):
20+
def test_tooltracking_trainer(self):
21+
if not torch.cuda.is_available():
22+
return
23+
24+
params = {
25+
"model": "tooltracking",
26+
"max_epochs": 1,
27+
"name": "net_test_tooltracking_trainer_01",
28+
"val_split": 0.5,
29+
"multi_gpu": False,
30+
}
31+
32+
response = requests.post(f"{SERVER_URI}/train/tooltracking?run_sync=True", json=params)
33+
assert response.status_code == 200
34+
35+
def test_deepedit_trainer(self):
36+
if not torch.cuda.is_available():
37+
return
38+
39+
params = {
40+
"model": "deepedit",
41+
"max_epochs": 1,
42+
"name": "net_test_deepedit_trainer_01",
43+
"val_split": 0.5,
44+
"multi_gpu": False,
45+
}
46+
response = requests.post(f"{SERVER_URI}/train/deepedit?run_sync=True", json=params)
47+
assert response.status_code == 200
48+
49+
50+
if __name__ == "__main__":
51+
unittest.main()

tests/setup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ def run_main():
3434
os.makedirs(os.path.join(TEST_DATA, "pathology"))
3535
shutil.copy(downloaded_pathology_file, os.path.join(TEST_DATA, "pathology"))
3636

37+
downloaded_endoscopy_file = os.path.join(TEST_DIR, "downloads", "endoscopy_frames.zip")
38+
endoscopy_url = "https://drive.google.com/uc?export=download&id=115fS_RZxOXMFb3wgepS2aJA2XYpXjHOU"
39+
if not os.path.exists(downloaded_endoscopy_file):
40+
download_url(url=endoscopy_url, filepath=downloaded_endoscopy_file)
41+
if not os.path.exists(os.path.join(TEST_DATA, "endoscopy")):
42+
os.makedirs(os.path.join(TEST_DATA, "endoscopy"))
43+
extractall(filepath=downloaded_endoscopy_file, output_dir=os.path.join(TEST_DATA, "endoscopy"))
44+
3745

3846
if __name__ == "__main__":
3947
run_main()

0 commit comments

Comments
 (0)