qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solution:[ValueError: You are trying to load a weight file containing 1 layers into a model with 147 layers.]

wuwou opened this issue · comments

commented

在我使用yolo.py文件时,generate模块会显示load_weight过程中保存的模型为read only模式,我直接注释掉了load_model这一行,将try...except...中的内容改为except中的语句。这时不再使用load_model,而是先建立一个yolo_body,再load_weights。

再次运行,会显示之前save_weights与load过程不匹配,ValueError: You are trying to load a weight file containing 1 layers into a model with 147 layers.在load_weight代码中加入, by_name=True就能解决问题。

但是这时候又会有新的错误,显示batch_normalization为uninitiated,在lt_yolo.py中44行改为:self.sess = K.get_session().run(tf.global_variables_initializer()) 就可以了。

我不确定自己做法是否正确,但能成功解决遇到的问题。: )