阿三先生 2018-10-23 13:36 采纳率: 0%
浏览 3713
已结题

模型训练后,进行识别时,权重不一致,怎么修改?

通过ModelTraining 训练的生成模型

 from imageai.Prediction.Custom import ModelTraining
model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory("datasets")

# batch_size  训练类别的整除数
model_trainer.trainModel(num_objects=4, num_experiments=10, enhance_data=True, batch_size=2, show_network_summary=True)

当与imageai的模型世界时报错

 # from imageai.Detection import ObjectDetection
# import os
# import time
# #计时
# start = time.time()
# execution_path = os.getcwd()
#
# detector = ObjectDetection()
# detector.setModelTypeAsRetinaNet()
#
# #载入已训练好的文件
# detector.setModelPath( os.path.join(execution_path , "model_weights.h5"))
# detector.loadModel('fastest')
#
# #将检测后的结果保存为新图片
# detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "./img/one.jpg"), output_image_path=os.path.join(execution_path , "./img/image3new.jpg"))
#
# #结束计时
# end = time.time()
#
# for eachObject in detections:
#     print(eachObject["name"] + " : " + eachObject["percentage_probability"] )
#     print("--------------------------------")
#
# print ("\ncost time:",end-start)


#!/usr/bin/env python3
from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(execution_path , "./models/model_ex-010_acc-0.250000.h5"))
detector.loadModel()

detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "img/one.jpg"), output_image_path=os.path.join(execution_path , "image3new.jpg"), minimum_percentage_probability=30)

for eachObject in detections:
    print(eachObject["name"] , " : ", eachObject["percentage_probability"])
    print("--------------------------------")

运行时报错:
ValueError: You are trying to load a weight file containing 107 layers into a model with 116 layers.

应该怎么修改让他们可以进行识别

  • 写回答

3条回答 默认 最新

  • devmiao 2018-10-24 04:57
    关注

    你是不是保存了模型以后又修改了模型,两个不一致,只能重新训练了。

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误