Skip to content

Commit 7eb2922

Browse files
committed
improve aligned_dataset
1 parent cbe0857 commit 7eb2922

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

data/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
"""This package """
1+
"""This package includes all the modules related to data loading and Preprocessing
2+
3+
To add a custom dataset class called dummy, you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset.
4+
You need to implement four functions:
5+
-- <__init__> (initialize the class, first call BaseDataset.__init__(self, opt))
6+
-- <__len__> (return the size of dataset)
7+
-- <__getitem__> (get a data point)
8+
-- (optionally) <modify_commandline_options> (add dataset-specific options and set default options).
9+
Now you can use the dataset class by specifying flag '--dataset_mode dummy'.
10+
See our template dataset class 'template_dataset.py' for an example.
11+
"""
212
import importlib
313
import torch.utils.data
414
from data.base_dataset import BaseDataset

data/aligned_dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ class AlignedDataset(BaseDataset):
1010
"""A dataset class for paired image dataset.
1111
1212
It assumes that the directory '/path/to/data/train' contains image pairs in the form of {A,B}.
13-
During test time, you need to prepare a directory /path/to/data/test.
13+
During test time, you need to prepare a directory '/path/to/data/test'.
1414
"""
1515

1616
def __init__(self, opt):
1717
"""Initialize this dataset class."""
1818
BaseDataset.__init__(self, opt)
1919
self.dir_AB = os.path.join(opt.dataroot, opt.phase) # get the image directory
2020
self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) # get image paths
21-
assert(opt.resize_or_crop == 'resize_and_crop') # only support this mode
2221
assert(self.opt.load_size >= self.opt.crop_size) # crop_size should be smaller than the size of loaded image
2322
input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc
2423
output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc

data/template_dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
The filename should be <dataset_mode>_dataset.py
77
The class name should be <Dataset_mode>Dataset.py
88
You need to implement the following functions:
9-
<modify_commandline_options>: Add dataset-specific options and rewrite default values for existing options.
10-
<__init__>: Initialize this dataset class.
11-
<__getitem__>: Return a data point and its metadata information.
12-
<__len__>: Return the number of images.
9+
-- <modify_commandline_options>: Add dataset-specific options and rewrite default values for existing options.
10+
-- <__init__>: Initialize this dataset class.
11+
-- <__getitem__>: Return a data point and its metadata information.
12+
-- <__len__>: Return the number of images.
1313
"""
1414
from data.base_dataset import BaseDataset, get_transform
1515
# from data.image_folder import make_dataset

0 commit comments

Comments
 (0)