问题
I am using my own image data generator. It generates 0 ,90, 180 and 270 degrees rotated versions of image batches and returns them with their classes. I use built in ImageDataGenerator
function to test the model. However flow_from_directory
generates different class indices. Output of train_generator.class_indices
is {'0': 0, '90': 1, '180': 2, '270': 3}
. But test_generator.class_indices
returns {'0': 0, '180': 1, '270': 2, '90': 3}
. Simply I can change order of rotation angles but this problem is caused by the file system of operating system and I will run the code on a different operating system. In this case I need an automated solution. Is there a way to change the class indices of flow_from_directory
method?
回答1:
looks like you can do
flow_from_directory(directory,
classes={'0': 0,
'90': 1,
'180': 2,
'270': 3}
)
来源:https://stackoverflow.com/questions/53892271/is-it-possible-to-change-class-indices-of-keras-flow-from-directory