MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / finalize

Method finalize

monai/data/csv_saver.py:69–83  ·  view source on GitHub ↗

Writes the cached dict to a csv

(self)

Source from the content-addressed store, hash-verified

67 self._data_index = 0
68
69 def finalize(self) -> None:
70 """
71 Writes the cached dict to a csv
72
73 """
74 if not self.output_dir.exists():
75 self.output_dir.mkdir(parents=True, exist_ok=True)
76 with open(self._filepath, "a") as f:
77 for k, v in self._cache_dict.items():
78 f.write(k)
79 for result in v.flatten():
80 f.write(self.delimiter + str(result))
81 f.write("\n")
82 # clear cache content after writing
83 self.reset_cache()
84
85 def save(self, data: torch.Tensor | np.ndarray, meta_data: dict | None = None) -> None:
86 """Save data into the cache dictionary. The metadata should have the following key:

Callers 3

save_batchMethod · 0.95
test_saved_contentMethod · 0.95
test_saved_contentMethod · 0.95

Calls 3

reset_cacheMethod · 0.95
writeMethod · 0.45
flattenMethod · 0.45

Tested by 2

test_saved_contentMethod · 0.76
test_saved_contentMethod · 0.76