Skip to content

Commit f129c24

Browse files
author
Songki Choi
committed
Cache "cache_key" in the pipeline
Signed-off-by: Songki Choi <songki.choi@intel.com>
1 parent 429a125 commit f129c24

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/otx/algorithms/common/adapters/mmcv/pipelines/load_image_from_otx_dataset.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ def _get_unique_key(results: Dict[str, Any]) -> Tuple:
4545
# TODO: We should improve it by assigning an unique id to DatasetItemEntity.
4646
# This is because there is a case which
4747
# d_item.media.path is None, but d_item.media.data is not None
48+
if "cache_key" in results:
49+
return results["cache_key"]
4850
d_item = results["dataset_item"]
49-
return d_item.media.path, d_item.roi.id
51+
results["cache_key"] = d_item.media.path, d_item.roi.id
52+
return results["cache_key"]
5053

5154
def __call__(self, results: Dict[str, Any]):
5255
"""Callback function of LoadImageFromOTXDataset."""
@@ -177,7 +180,6 @@ def _save_cache(self, results: Dict[str, Any]):
177180
return
178181
key = self._get_unique_key(results)
179182
meta = results.copy()
180-
meta.pop("dataset_item") # remove irrlevant info
181183
img = meta.pop("img")
182184
self._mem_cache_handler.put(key, img, meta)
183185

src/otx/algorithms/detection/adapters/mmdet/datasets/pipelines/load_pipelines.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _load_masks(results, ann_info):
119119

120120
def __call__(self, results: Dict[str, Any]):
121121
"""Callback function of LoadAnnotationFromOTXDataset."""
122-
dataset_item = results.get("dataset_item")
122+
dataset_item = results.pop("dataset_item") # Prevent unnecessary deepcopy
123123
label_list = results.pop("ann_info")["label_list"]
124124
ann_info = get_annotation_mmdet_format(dataset_item, label_list, self.domain, self.min_size)
125125
if self.with_bbox:

0 commit comments

Comments
 (0)