In machine learning we can struggle with problems like not enough memory. There is a good solution, for that, and you can load the data without running out of RAM memory. The problem starts, when you load the data in one step and you holding it in a variable. That can full your memory easy. It is better to use the keras flow_from_directory method.