MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / train

Function train

CV/astar2019/reader.py:282–316  ·  view source on GitHub ↗
(settings,
          file_list,
          batch_size,
          shuffle=True,
          num_workers=8,
          enable_ce=False)

Source from the content-addressed store, hash-verified

280
281
282def train(settings,
283 file_list,
284 batch_size,
285 shuffle=True,
286 num_workers=8,
287 enable_ce=False):
288 file_path = os.path.join(settings.data_dir, file_list)
289 readers = []
290 if 'coco' in settings.dataset:
291 # cocoapi
292 from pycocotools.coco import COCO
293 coco_api = COCO(file_path)
294 image_ids = coco_api.getImgIds()
295 images = coco_api.loadImgs(image_ids)
296 np.random.shuffle(images)
297 n = int(math.ceil(len(images) // num_workers))
298 image_lists = [images[i:i + n] for i in range(0, len(images), n)]
299
300 if '2014' in file_list:
301 sub_dir = "train2014"
302 elif '2017' in file_list:
303 sub_dir = "train2017"
304 data_dir = os.path.join(settings.data_dir, sub_dir)
305 for l in image_lists:
306 readers.append(
307 coco(settings, coco_api, l, 'train', batch_size, shuffle,
308 data_dir))
309 else:
310 images = [line.strip() for line in open(file_path)]
311 np.random.shuffle(images)
312 n = int(math.ceil(len(images) // num_workers))
313 image_lists = [images[i:i + n] for i in range(0, len(images), n)]
314 for l in image_lists:
315 readers.append(pascalvoc(settings, l, 'train', batch_size, shuffle))
316 return paddle.reader.multiprocess_reader(readers, False)
317
318
319def test(settings, file_list, batch_size):

Callers

nothing calls this directly

Calls 3

cocoFunction · 0.85
pascalvocFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected