Advertisement
Guest User

Untitled

a guest
May 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. def image_data_generator(image_paths, steering_angles, batch_size, is_training):
  2. while True:
  3. batch_images = []
  4. batch_steering_angles = []
  5.  
  6. for i in range(batch_size):
  7. random_index = random.randint(0, len(image_paths) - 1)
  8. image_path = image_paths[random_index]
  9. image = my_imread(image_paths[random_index])
  10. steering_angle = steering_angles[random_index]
  11. if is_training:
  12. # training: augment image
  13. image, steering_angle = random_augment(image, steering_angle)
  14.  
  15. image = img_preprocess(image)
  16. batch_images.append(image)
  17. batch_steering_angles.append(steering_angle)
  18.  
  19. yield( np.asarray(batch_images), np.asarray(batch_steering_angles))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement