MCPcopy Create free account
hub / github.com/chenhaoxing/HDNet / BaseDataset

Class BaseDataset

data/base_dataset.py:13–60  ·  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.dataset_root #mia
31
32 @staticmethod
33 def modify_commandline_options(parser, is_train):
34 """Add new dataset-specific options, and rewrite default values for existing options.
35
36 Parameters:
37 parser -- original option parser
38 is_train (bool) -- whether training phase or test phase. You can use this flag to add training-specific or test-specific options.
39
40 Returns:
41 the modified parser.
42 """
43 return parser
44
45 @abstractmethod
46 def __len__(self):
47 """Return the total number of images in the dataset."""
48 return 0
49
50 @abstractmethod
51 def __getitem__(self, index):
52 """Return a data point and its metadata information.
53
54 Parameters:
55 index - - a random integer for data indexing
56
57 Returns:
58 a dictionary of data with their names. It ususally contains the data itself and its metadata information.
59 """
60 pass
61
62
63def get_params(opt, size):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected