首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从文件加载权重时,层数不匹配。ImageAi自定义

从文件加载权重时,层数不匹配。ImageAi自定义
EN

Stack Overflow用户
提问于 2022-01-24 22:45:08
回答 1查看 1.1K关注 0票数 0

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

现在我们开始

代码语言:javascript
复制
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)

<...>

代码语言:javascript
复制
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()
代码语言:javascript
复制
ValueError: Layer count mismatch when loading weights from file. Model expected 24 layers, found 107 saved layers.
EN

回答 1

Stack Overflow用户

发布于 2022-01-25 10:12:52

解决了。我必须用imageai.Classification.Custom import CustomImageClassification代替f imageai.Detection import ObjectDetection

代码语言:javascript
复制
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)

在训练和预测过程中,存在不同的模型类型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70841394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档