当前位置: 代码迷 >> 综合 >> Ubuntu 环境下 DeepLab v3 在使用 eval.py 评估时报错 assertion failed: 'predictions' out of bound 解决方法
  详细解决方案

Ubuntu 环境下 DeepLab v3 在使用 eval.py 评估时报错 assertion failed: 'predictions' out of bound 解决方法

热度:97   发布时间:2023-12-16 10:30:09.0

看过有解释是说这是Label的问题,将Label改为 [m* n* 1] 的灰度图像即可,但有些情况下即使将Label图像改为灰度图像后仍然不行,这时候是代码本身的问题。

以下代码截取自GitHub:
https://github.com/tensorflow/models/issues/4203

Modify the code at line 145 in eval.py from:

    metric_map = {
    }metric_map[predictions_tag] = tf.metrics.mean_iou(predictions, labels, dataset.num_classes, weights=weights)

to:

    metric_map = {
    }# insert by trobrindices = tf.squeeze(tf.where(tf.less_equal(labels, dataset.num_classes - 1)), 1)labels = tf.cast(tf.gather(labels, indices), tf.int32)predictions = tf.gather(predictions, indices)# end of insertmetric_map[predictions_tag] = tf.metrics.mean_iou(predictions, labels, dataset.num_classes, weights=weights)

在中间插入该段后,评估可正常进行。

INFO:tensorflow:Starting evaluation at 2018-10-21-13:11:45
INFO:tensorflow:Evaluation [1/10]
INFO:tensorflow:Evaluation [2/10]
INFO:tensorflow:Evaluation [3/10]
INFO:tensorflow:Evaluation [4/10]
INFO:tensorflow:Evaluation [5/10]
INFO:tensorflow:Evaluation [6/10]
INFO:tensorflow:Evaluation [7/10]
INFO:tensorflow:Evaluation [8/10]
INFO:tensorflow:Evaluation [9/10]
INFO:tensorflow:Evaluation [10/10]
INFO:tensorflow:Finished evaluation at 2018-10-21-13:12:07
miou_1.0[0.594165504]
  相关解决方案