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

Method save

monai/data/csv_saver.py:85–99  ·  view source on GitHub ↗

Save data into the cache dictionary. The metadata should have the following key: - ``'filename_or_obj'`` -- save the data corresponding to file name or object. If meta_data is None, use the default index from 0 to save data instead. Args: data: target data co

(self, data: torch.Tensor | np.ndarray, meta_data: dict | None = None)

Source from the content-addressed store, hash-verified

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:
87 - ``'filename_or_obj'`` -- save the data corresponding to file name or object.
88 If meta_data is None, use the default index from 0 to save data instead.
89
90 Args:
91 data: target data content that save into cache.
92 meta_data: the metadata information corresponding to the data.
93
94 """
95 save_key = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index)
96 self._data_index += 1
97 if isinstance(data, torch.Tensor):
98 data = data.detach().cpu().numpy()
99 self._cache_dict[save_key] = np.asarray(data, dtype=float)
100
101 def save_batch(self, batch_data: torch.Tensor | np.ndarray, meta_data: dict | None = None) -> None:
102 """Save a batch of data into the cache dictionary.

Callers 15

save_batchMethod · 0.95
storeMethod · 0.80
convert_to_torchscriptFunction · 0.80
_save_data_2dFunction · 0.80
_save_data_3dFunction · 0.80
create_new_data_copyFunction · 0.80
save_net_with_metadataFunction · 0.80
_cachecheckMethod · 0.80
_safe_serializeMethod · 0.80
_create_new_cacheMethod · 0.80

Calls

no outgoing calls

Tested by 15

make_nifti_imageFunction · 0.64
setUpMethod · 0.64
setUpMethod · 0.64
create_input_fileFunction · 0.64
run_training_testFunction · 0.64
setUpMethod · 0.64
setUpMethod · 0.64
setUpMethod · 0.64
setUpMethod · 0.64
test_shapeMethod · 0.64
setUpMethod · 0.64