【问题标题】:Layer count mismatch when loading weights from file. ImageAi Custom从文件加载权重时层数不匹配。 ImageAi 自定义
【发布时间】:2023-01-23 22:28:18
【问题描述】:

我需要帮助... 我正在使用 imageai 自定义类来创建我自己的检测...

现在我们开始

from imageai.Classification.Custom import ClassificationModelTrainer
model_trainer = ClassificationModelTrainer()
model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory("leads_test")

model_trainer.trainModel(num_objects=1, num_experiments=1, enhance_data=True, batch_size=1, show_network_summary=True)

<...>

from imageai.Detection import ObjectDetection

detector = ObjectDetection()
model_path = "leads_test/models/model_ex-001_acc-1.000000.h5"
input_path = "ECG/IMG_0239.jpg"
output_path = "./output/newimage.jpg"

detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()
ValueError: Layer count mismatch when loading weights from file. Model expected 24 layers, found 107 saved layers.

【问题讨论】:

  • 这个问题似乎与tensorflowkeras 无关。如果您使用的是开源包,您可以尝试在他们的存储库中打开一个问题。

标签: python tensorflow keras imageai


【解决方案1】:

解决了。 我必须使用imageai.Classification.Custom import CustomImageClassification 而不是f imageai.Detection import ObjectDetection

from imageai.Classification.Custom import CustomImageClassification
prediction = CustomImageClassification()
prediction.setModelTypeAsResNet50()
prediction.setModelPath('leads_test/models/model_ex-001_acc-1.000000.h5')
prediction.setJsonPath('leads_test/json/model_class.json')
prediction.loadModel(num_objects=1)

在训练和预测时,问题出在不同的模型类型中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-05
    • 2017-03-19
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2014-05-03
    相关资源
    最近更新 更多