MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_data

Function get_data

examples/GAN/CycleGAN.py:160–181  ·  view source on GitHub ↗
(datadir, isTrain=True)

Source from the content-addressed store, hash-verified

158
159
160def get_data(datadir, isTrain=True):
161 if isTrain:
162 augs = [
163 imgaug.Resize(int(SHAPE * 1.12)),
164 imgaug.RandomCrop(SHAPE),
165 imgaug.Flip(horiz=True),
166 ]
167 else:
168 augs = [imgaug.Resize(SHAPE)]
169
170 def get_image_pairs(dir1, dir2):
171 def get_df(dir):
172 files = sorted(glob.glob(os.path.join(dir, '*.jpg')))
173 df = ImageFromFile(files, channel=3, shuffle=isTrain)
174 return AugmentImageComponent(df, augs)
175 return JoinData([get_df(dir1), get_df(dir2)])
176
177 names = ['trainA', 'trainB'] if isTrain else ['testA', 'testB']
178 df = get_image_pairs(*[os.path.join(datadir, n) for n in names])
179 df = BatchData(df, BATCH if isTrain else TEST_BATCH)
180 df = MultiProcessRunnerZMQ(df, 2 if isTrain else 1)
181 return df
182
183
184class VisualizeTestSet(Callback):

Callers 2

_before_trainMethod · 0.70
CycleGAN.pyFile · 0.70

Calls 4

get_image_pairsFunction · 0.85
BatchDataClass · 0.85
joinMethod · 0.80

Tested by

no test coverage detected