【问题标题】:In Keras how to get the `class_indices` or prediction labels for an existing model在 Keras 中,如何获取现有模型的“class_indices”或预测标签
【发布时间】:2018-05-06 00:48:26
【问题描述】:

我知道 keras 提供了一个 .class_indicies 字典,其中包含从类名到类的映射,作为其 ImageDataGenerator 类 (https://keras.io/preprocessing/image/) 中 .flow_from_directory() 的一部分。

但是,有没有办法从现有的 保存 模型(保存为 .h5 文件的模型)访问相应的类标签?这在将我的模型投入生产和提供预测服务时似乎很重要,因为预先不知道这些类,因此图像不会在预先标记的目录中分开。

【问题讨论】:

    标签: keras prediction


    【解决方案1】:

    它在火车生成器的 class_indices 属性中。

    train_generator_example = ImageDataGenerator.flow_from_dataframe( 数据框, 目录=无, ………… )

    标签可以从作为“train_generator_example”属性的字典中获取

    train_generator_example.class_indices。

    【讨论】:

      猜你喜欢
      • 2020-03-07
      • 2016-06-19
      • 2019-01-31
      • 2019-05-29
      • 2020-03-13
      • 2017-09-15
      • 2016-12-22
      • 1970-01-01
      • 2017-12-19
      相关资源
      最近更新 更多