How to manually specify class labels in keras flow_from_directory?

前端 未结 3 1145
不知归路
不知归路 2021-02-01 19:38

Problem: I am training a model for multilabel image recognition. My images are therefore associated with multiple y labels. This is conflicting with the conveni

3条回答
  •  眼角桃花
    2021-02-01 20:05

    You could simply use the flow_from_directory and extend it to a multiclass in a following manner:

    def multiclass_flow_from_directory(flow_from_directory_gen, multiclasses_getter):
        for x, y in flow_from_directory_gen:
            yield x, multiclasses_getter(x, y)
    

    Where multiclasses_getter is assigning a multiclass vector / your multiclass representation to your images. Note that x and y are not a single examples but batches of examples, so this should be included in your multiclasses_getter design.

提交回复
热议问题