Viredery / tf-eager-fasterrcnn

Faster R-CNN R-101-FPN model was implemented with TensorFlow2.0 eager execution.
MIT License
89 stars 46 forks source link

载入模型报错 #25

Open lhcezx opened 2 years ago

lhcezx commented 2 years ago

博主你好,

我在运行你的train_model的时候在已经将模型放到weights后,运行到model.load_weights('weights/faster_rcnn.h5', by_name = True)这行报错 ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not created its variables yet. Call the Model first, then load the weights. 可以请教您一下吗?

lhcezx commented 2 years ago

我尝试使用model.built = True使这个问题不再报错,但是接下来在训练的 model((batch_imgs, batch_metas, batch_bboxes, batch_labels), training=True)这行会报错, indices[192] = [192, -1] does not index into shape [256,81,4] [Op:TensorScatterUpdate]

During handling of the above exception, another exception occurred:

File "C:\Users\lhcez\Desktop\tf-eager-fasterrcnn-master\tf-eager-fasterrcnn-master\detection\core\bbox\bbox_target.py", line 179, in _build_single_target delta_targets = tf.tensor_scatter_nd_update(tile_delta_targets, ids, delta_targets) # [num_rois, self.num_classes, 4] File "C:\Users\lhcez\Desktop\tf-eager-fasterrcnn-master\tf-eager-fasterrcnn-master\detection\core\bbox\bbox_target.py", line 72, in build_targets rois, labels, label_weights, delta_targets, delta_weights = self._build_single_target( File "C:\Users\lhcez\Desktop\tf-eager-fasterrcnn-master\tf-eager-fasterrcnn-master\detection\models\detectors\faster_rcnn.py", line 126, in call self.bbox_target.build_targets( File "C:\Users\lhcez\Desktop\tf-eager-fasterrcnn-master\tf-eager-fasterrcnn-master\train.py", line 63, in model((batch_imgs, batch_metas, batch_bboxes, batch_labels), training=True)