MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / get_per_pixel_mean

Method get_per_pixel_mean

tensorpack/dataflow/dataset/cifar.py:130–149  ·  view source on GitHub ↗

Args: names (tuple[str]): the names ('train' or 'test') of the datasets Returns: a mean image of all images in the given datasets, with size 32x32x3

(self, names=('train', 'test'))

Source from the content-addressed store, hash-verified

128 yield self.data[k]
129
130 def get_per_pixel_mean(self, names=('train', 'test')):
131 """
132 Args:
133 names (tuple[str]): the names ('train' or 'test') of the datasets
134
135 Returns:
136 a mean image of all images in the given datasets, with size 32x32x3
137 """
138 for name in names:
139 assert name in ['train', 'test'], name
140 train_files, test_files, _ = get_filenames(self.dir, self.cifar_classnum)
141 all_files = []
142 if 'train' in names:
143 all_files.extend(train_files)
144 if 'test' in names:
145 all_files.extend(test_files)
146 all_imgs = [x[0] for x in read_cifar(all_files, self.cifar_classnum)]
147 arr = np.array(all_imgs, dtype='float32')
148 mean = np.mean(arr, axis=0)
149 return mean
150
151 def get_label_names(self):
152 """

Callers 1

get_per_channel_meanMethod · 0.95

Calls 3

get_filenamesFunction · 0.85
read_cifarFunction · 0.85
meanMethod · 0.80

Tested by

no test coverage detected