[英]Layer count mismatch when loading weights from file. ImageAi Custom
I need help... Im using imageai Custom Class to create my own detection...我需要帮助...我使用 imageai Custom Class 创建我自己的检测...
And here we go在这里我们 go
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.
Solved.解决了。 I have to use
imageai.Classification.Custom import CustomImageClassification
instead o f imageai.Detection import ObjectDetection
我必须使用
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)
The problem was in different model type while training and prediction.问题在于训练和预测时不同的 model 类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.