MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / BaseDataset

Class BaseDataset

data/base_dataset.py:13–61  ·  view source on GitHub ↗

This class is an abstract base class (ABC) for datasets. To create a subclass, you need to implement the following four functions: -- <__init__>: initialize the class, first call BaseDataset.__init__(self, opt). -- <__len__>: return the size of

Source from the content-addressed store, hash-verified

11
12
13class BaseDataset(data.Dataset, ABC):
14 """This class is an abstract base class (ABC) for datasets.
15
16 To create a subclass, you need to implement the following four functions:
17 -- <__init__>: initialize the class, first call BaseDataset.__init__(self, opt).
18 -- <__len__>: return the size of dataset.
19 -- <__getitem__>: get a data point.
20 -- <modify_commandline_options>: (optionally) add dataset-specific options and set default options.
21 """
22
23 def __init__(self, opt):
24 """Initialize the class; save the options in the class
25
26 Parameters:
27 opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions
28 """
29 self.opt = opt
30 self.root = opt.dataroot
31 self.current_epoch = 0
32
33 @staticmethod
34 def modify_commandline_options(parser, is_train):
35 """Add new dataset-specific options, and rewrite default values for existing options.
36
37 Parameters:
38 parser -- original option parser
39 is_train (bool) -- whether training phase or test phase. You can use this flag to add training-specific or test-specific options.
40
41 Returns:
42 the modified parser.
43 """
44 return parser
45
46 @abstractmethod
47 def __len__(self):
48 """Return the total number of images in the dataset."""
49 return 0
50
51 @abstractmethod
52 def __getitem__(self, index):
53 """Return a data point and its metadata information.
54
55 Parameters:
56 index - - a random integer for data indexing
57
58 Returns:
59 a dictionary of data with their names. It ususally contains the data itself and its metadata information.
60 """
61 pass
62
63
64def get_params(opt, size):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected