Every line of 'keras imagedatagenerator' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
99 def get_batches(dirname, gen=image.ImageDataGenerator(), shuffle=True, batch_size=4, class_mode='categorical', 100 target_size=(224,224)): 101 return gen.flow_from_directory(dirname, target_size=target_size, 102 class_mode=class_mode, shuffle=shuffle, batch_size=batch_size)
336 def generator(data, batch_size=cfg.BATCH_SIZE): 337 num_records = len(data) 338 339 while True: 340 #shuffle again for good measure 341 shuffle(data) 342 343 for offset in range(0, num_records, batch_size): 344 batch_data = data[offset:offset+batch_size] 345 346 if len(batch_data) != batch_size: 347 break 348 349 b_inputs_img = [] 350 b_inputs_imu = [] 351 b_labels = [] 352 353 for seq in batch_data: 354 inputs_img = [] 355 labels = [] 356 for record in seq: 357 #get image data if we don't already have it 358 if record['img_data'] is None: 359 record['img_data'] = np.array(Image.open(record['image_path'])) 360 361 inputs_img.append(record['img_data']) 362 labels.append(seq[-1]['target_output']) 363 364 b_inputs_img.append(inputs_img) 365 b_labels.append(labels) 366 367 #X = [np.array(b_inputs_img), np.array(b_inputs_imu)] 368 X = [np.array(b_inputs_img)] 369 y = np.array(b_labels).reshape(batch_size, 2) 370 371 yield X, y