Skip to content

Commit

Permalink
Use default loading in case of None cfg
Browse files Browse the repository at this point in the history
Signed-off-by: Songki Choi <[email protected]>
  • Loading branch information
goodsong81 committed Aug 21, 2023
1 parent fcdb50e commit c6642cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class LoadImageFromOTXDataset(load_image_base.LoadImageFromOTXDataset):
class LoadResizeDataFromOTXDataset(load_image_base.LoadResizeDataFromOTXDataset):
"""Load and resize image & annotation with cache support."""

def _create_load_img_op(self, cfg: Dict) -> Any:
def _create_load_img_op(self, cfg: Optional[Dict]) -> Any:
"""Creates image loading operation."""
if cfg is None:
return self
return build_from_cfg(cfg, PIPELINES)

def _create_resize_op(self, cfg: Optional[Dict]) -> Optional[Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

__test_pipeline = [
dict(type="LoadImageFromOTXDataset"),
dict(type="Resize", size=__resize_target_size),
dict(type="ResizeTo", size=__resize_target_size),
dict(type="Normalize", **__img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class LoadResizeDataFromOTXDataset(LoadImageFromOTXDataset):
Finally, if enabled, cache the result and use pre-computed ones from next iterations.
Args:
load_img_cfg (Dict): Creates image loading operation based on the config
load_img_cfg (Dict, optional): Optionally Creates image loading operation that replaces base loading
logic based on the config. Defaults to None.
load_ann_cfg (Dict, optional): Optionally creates annotation loading operation based on the config.
Defaults to None.
resize_cfg (Dict, optional): Optionally creates resize operation based on the config. Defaults to None.
Expand All @@ -110,7 +111,7 @@ class LoadResizeDataFromOTXDataset(LoadImageFromOTXDataset):

def __init__(
self,
load_img_cfg: Dict,
load_img_cfg: Optional[Dict] = None,
load_ann_cfg: Optional[Dict] = None,
resize_cfg: Optional[Dict] = None,
**kwargs,
Expand All @@ -130,8 +131,10 @@ def __init__(
else:
self._resize_shape = None

def _create_load_img_op(self, cfg: Dict) -> Any:
def _create_load_img_op(self, cfg: Optional[Dict]) -> Any:
"""Creates image loading operation."""
if cfg is None:
return self
return LoadImageFromOTXDataset(**cfg) # Should be overrided in task-specific implementation if needed

def _create_load_ann_op(self, cfg: Optional[Dict]) -> Optional[Any]:
Expand Down

0 comments on commit c6642cc

Please sign in to comment.