Skip to content

Commit 541d7ab

Browse files
4043 Fix windows PIL issue (#4044)
* fix pil via specifying cpuonly version Signed-off-by: Yiheng Wang <[email protected]> * add push branch to check Signed-off-by: Yiheng Wang <[email protected]> * remove extra line Signed-off-by: Yiheng Wang <[email protected]> * remove push branch for upstream Signed-off-by: Yiheng Wang <[email protected]>
1 parent 167a320 commit 541d7ab

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

.github/workflows/conda.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ jobs:
4747
run: |
4848
conda activate monai
4949
# this `cpuonly` and -c conda-forge is needed to reduce the paging file size on a github instance
50-
conda install pytorch torchvision torchaudio cpuonly -c pytorch -c conda-forge
50+
# force to install `cpuonly==2.0.0` is to fix the same issue as:
51+
# https://github.com/pytorch/vision/issues/4240
52+
conda install pytorch torchvision torchaudio cpuonly==2.0.0 -c pytorch -c conda-forge
5153
conda deactivate
5254
- name: Test env(CPU ${{ runner.os }})
5355
shell: bash -l {0}

monai/handlers/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class mean median max 5percentile 95percentile notnans
121121
with open(os.path.join(save_dir, f"{k}_raw.csv"), "w") as f:
122122
f.write(f"filename{deli}{deli.join(class_labels)}\n")
123123
for i, b in enumerate(v):
124-
f.write(f"{images[i] if images is not None else str(i)}{deli}{deli.join([str(c) for c in b])}\n")
124+
f.write(
125+
f"{images[i] if images is not None else str(i)}{deli}"
126+
f"{deli.join([f'{c:.4f}' if isinstance(c, (int, float)) else str(c) for c in b])}\n"
127+
)
125128

126129
if summary_ops is not None:
127130
supported_ops = OrderedDict(

tests/test_handler_metrics_saver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _save_metrics(engine):
6666
f_csv = csv.reader(f)
6767
for i, row in enumerate(f_csv):
6868
if i > 0:
69-
self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"])
69+
self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"])
7070
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
7171
# check the metric_summary.csv and content
7272
with open(os.path.join(tempdir, "metric4_summary.csv")) as f:

tests/test_handler_metrics_saver_dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _all_gather(engine):
9595
f_csv = csv.reader(f)
9696
for i, row in enumerate(f_csv):
9797
if i > 0:
98-
expected = [f"{fnames[i-1]}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"]
98+
expected = [f"{fnames[i-1]}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"]
9999
self.assertEqual(row, expected)
100100
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
101101
# check the metric_summary.csv and content

tests/test_write_metrics_reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_content(self):
4545
f_csv = csv.reader(f)
4646
for i, row in enumerate(f_csv):
4747
if i > 0:
48-
self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"])
48+
self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"])
4949
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
5050
# check the metric_summary.csv and content
5151
with open(os.path.join(tempdir, "metric3_summary.csv")) as f:

0 commit comments

Comments
 (0)