Is it possible to change class indices of Keras flow from directory

被刻印的时光 ゝ 提交于 2020-01-24 15:26:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!