Skip to content

Commit

Permalink
add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene123tw committed Apr 22, 2024
1 parent 3de767e commit 94f47fd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/otx/algorithms/common/utils/task_adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
#

import warnings

import numpy as np

from otx.utils.logger import get_logger
Expand Down Expand Up @@ -99,12 +101,17 @@ def unwrap_dataset(dataset):
:param dataset: dataset object, an instance of a dataset.
:return: tuple of dataset object and int, the base dataset and the number of times to repeat the dataset.
"""
from otx.algorithms.detection.adapters.mmdet.datasets import ImageTilingDataset

times = 1
target_dataset = dataset
if isinstance(target_dataset, ImageTilingDataset):
return target_dataset, times
try:
from otx.algorithms.detection.adapters.mmdet.datasets import ImageTilingDataset

if isinstance(target_dataset, ImageTilingDataset):
return target_dataset, times
except ImportError as err:
warnings.warn(f"ImageTilingDataset is not supported for {dataset}", stacklevel=2)
warnings.warn(f"Error: {err}, {type(err)}", stacklevel=2)

while hasattr(target_dataset, "dataset"):
if hasattr(target_dataset, "times"):
Expand Down

0 comments on commit 94f47fd

Please sign in to comment.