Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix 🔧 Bypass ClsIncrSampler for tiling #3374

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 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,8 +101,18 @@ 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.
"""

times = 1
target_dataset = dataset
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"):
times = target_dataset.times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ def __init__(
annotation = [self.get_ann_info(i) for i in range(len(self))]
self.evaluator = Evaluator(annotation, self.dataset.domain, self.CLASSES)

@property
def img_indices(self) -> dict:
"""Get indices of old and new images."""
# TODO: Tiling currently does not support incremental learning.
return {"old": [], "new": [i for i in range(len(self))]}

def __len__(self) -> int:
"""Get the length of the dataset."""
return len(self.tile_dataset)
Expand Down
Loading