diff --git a/chainercv/datasets/__init__.py b/chainercv/datasets/__init__.py index 6ecea75ca5..da0d25a635 100644 --- a/chainercv/datasets/__init__.py +++ b/chainercv/datasets/__init__.py @@ -28,7 +28,6 @@ from chainercv.datasets.sbd.sbd_instance_segmentation_dataset import SBDInstanceSegmentationDataset # NOQA from chainercv.datasets.sbd.sbd_utils import sbd_instance_segmentation_label_names # NOQA from chainercv.datasets.siamese_dataset import SiameseDataset # NOQA -from chainercv.datasets.transform_dataset import TransformDataset # NOQA from chainercv.datasets.voc.voc_bbox_dataset import VOCBboxDataset # NOQA from chainercv.datasets.voc.voc_instance_segmentation_dataset import VOCInstanceSegmentationDataset # NOQA from chainercv.datasets.voc.voc_semantic_segmentation_dataset import VOCSemanticSegmentationDataset # NOQA diff --git a/chainercv/datasets/transform_dataset.py b/chainercv/datasets/transform_dataset.py deleted file mode 100644 index 8e4f878cc7..0000000000 --- a/chainercv/datasets/transform_dataset.py +++ /dev/null @@ -1,61 +0,0 @@ -import warnings - - -class TransformDataset(object): - - """Dataset that indexes data of a base dataset and transforms it. - - This dataset wraps a base dataset by modifying the behavior of the base - dataset's :meth:`__getitem__`. Arrays returned by :meth:`__getitem__` of - the base dataset with an integer index are transformed by the given - function :obj:`transform`. - - The function :obj:`transform` takes, as an argument, :obj:`in_data`, which - is output of the base dataset's :meth:`__getitem__`, and returns - transformed arrays as output. Please see the following example. - - >>> from chainer.datasets import get_mnist - >>> from chainercv.datasets import TransformDataset - >>> dataset, _ = get_mnist() - >>> def transform(in_data): - >>> img, label = in_data - >>> img -= 0.5 # scale to [-0.5, -0.5] - >>> return img, label - >>> dataset = TransformDataset(dataset, transform) - - .. note:: - - The index used to access data is either an integer or a slice. If it - is a slice, the base dataset is assumed to return a list of outputs - each corresponding to the output of the integer indexing. - - .. note:: - This class is deprecated. Please use - :class:`chainer.datasets.TransformDataset` instead. - - Args: - dataset: Underlying dataset. The index of this dataset corresponds - to the index of the base dataset. - transform (callable): A function that is called to transform values - returned by the underlying dataset's :meth:`__getitem__`. - - """ - - def __init__(self, dataset, transform): - warnings.warn( - 'chainercv.datasets.TransformDataset is deprecated. ' - 'Please use chainer.datasets.TransformDataset instead.', - DeprecationWarning) - - self._dataset = dataset - self._transform = transform - - def __getitem__(self, index): - in_data = self._dataset[index] - if isinstance(index, slice): - return [self._transform(in_data_elem) for in_data_elem in in_data] - else: - return self._transform(in_data) - - def __len__(self): - return len(self._dataset) diff --git a/tests/datasets_tests/test_transform_dataset.py b/tests/datasets_tests/test_transform_dataset.py deleted file mode 100644 index 3ef6b47ee9..0000000000 --- a/tests/datasets_tests/test_transform_dataset.py +++ /dev/null @@ -1,27 +0,0 @@ -import unittest - -import numpy as np - -from chainer import testing -from chainercv.datasets import TransformDataset - - -class TestTransformDataset(unittest.TestCase): - - def test_transform_dataset(self): - dataset = np.random.uniform(size=(10, 3, 32, 32)) - first_img = dataset[0] - - def transform(in_data): - return in_data * 3 - - transformed_dataset = TransformDataset(dataset, transform) - out = transformed_dataset[0] - np.testing.assert_equal(out, first_img * 3) - - outs = transformed_dataset[:2] - np.testing.assert_equal( - [transform(elem) for elem in dataset[:2]], outs) - - -testing.run_module(__name__, __file__)