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

Method save_batch

monai/data/csv_saver.py:101–113  ·  view source on GitHub ↗

Save a batch of data into the cache dictionary. Args: batch_data: target batch data content that save into cache. meta_data: every key-value in the meta_data is corresponding to 1 batch of data.

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

Source from the content-addressed store, hash-verified

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.
103
104 Args:
105 batch_data: target batch data content that save into cache.
106 meta_data: every key-value in the meta_data is corresponding to 1 batch of data.
107
108 """
109 for i, data in enumerate(batch_data): # save a batch of files
110 self.save(data, {k: meta_data[k][i] for k in meta_data} if meta_data else None)
111
112 if self.flush:
113 self.finalize()
114
115 def get_cache(self) -> OrderedDict:
116 """Get the cache dictionary, key is filename and value is the corresponding data"""

Callers 2

test_saved_contentMethod · 0.95
_finalizeMethod · 0.80

Calls 2

saveMethod · 0.95
finalizeMethod · 0.95

Tested by 1

test_saved_contentMethod · 0.76