Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ jobs:
run: |
conda activate monai
# this `cpuonly` and -c conda-forge is needed to reduce the paging file size on a github instance
conda install pytorch torchvision torchaudio cpuonly -c pytorch -c conda-forge
# force to install `cpuonly==2.0.0` is to fix the same issue as:
# https://github.com/pytorch/vision/issues/4240
conda install pytorch torchvision torchaudio cpuonly==2.0.0 -c pytorch -c conda-forge
conda deactivate
- name: Test env(CPU ${{ runner.os }})
shell: bash -l {0}
Expand Down
5 changes: 4 additions & 1 deletion monai/handlers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class mean median max 5percentile 95percentile notnans
with open(os.path.join(save_dir, f"{k}_raw.csv"), "w") as f:
f.write(f"filename{deli}{deli.join(class_labels)}\n")
for i, b in enumerate(v):
f.write(f"{images[i] if images is not None else str(i)}{deli}{deli.join([str(c) for c in b])}\n")
f.write(
f"{images[i] if images is not None else str(i)}{deli}"
f"{deli.join([f'{c:.4f}' if isinstance(c, (int, float)) else str(c) for c in b])}\n"
)

if summary_ops is not None:
supported_ops = OrderedDict(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_handler_metrics_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _save_metrics(engine):
f_csv = csv.reader(f)
for i, row in enumerate(f_csv):
if i > 0:
self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"])
self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"])
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
# check the metric_summary.csv and content
with open(os.path.join(tempdir, "metric4_summary.csv")) as f:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_handler_metrics_saver_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _all_gather(engine):
f_csv = csv.reader(f)
for i, row in enumerate(f_csv):
if i > 0:
expected = [f"{fnames[i-1]}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"]
expected = [f"{fnames[i-1]}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"]
self.assertEqual(row, expected)
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
# check the metric_summary.csv and content
Expand Down
2 changes: 1 addition & 1 deletion tests/test_write_metrics_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_content(self):
f_csv = csv.reader(f)
for i, row in enumerate(f_csv):
if i > 0:
self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"])
self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"])
self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv")))
# check the metric_summary.csv and content
with open(os.path.join(tempdir, "metric3_summary.csv")) as f:
Expand Down