简体   繁体   English

ValueError:尺寸必须相等,但对于具有输入形状的“mul_18”(操作:“Mul”)为 2 和 80:[?,?,?,5,2], [?,?,?,5,80]

[英]ValueError: Dimensions must be equal, but are 2 and 80 for 'mul_18' (op: 'Mul') with input shapes: [?,?,?,5,2], [?,?,?,5,80]

I am trying to detect objects in an using in Yolo in google collab.我正在尝试在 Google Collab 中使用 Yolo 检测对象。 Here is the piece of code I am executing but getting value error.这是我正在执行但出现值错误的一段代码。 Looking for help, Stuck here for more than a week.寻求帮助,卡在这里一个多星期。

img = plt.imread('/content/drive/My Drive/Social_distance/img.jpg')
imshow(img)
image_shape = float(img.shape[0]), float(img.shape[1])
print(image_shape)
scores, boxes, classes = yolo_eval(yolo_outputs, image_shape=(720,1280))

definition of yolo_eval() yolo_eval() 的定义

def yolo_eval(yolo_outputs, image_shape = (720., 1280.), max_boxes=10, score_threshold=.6, iou_threshold=.5):
   print(image_shape)
   box_confidence, box_xy, box_wh, box_class_probs = yolo_outputs
   boxes = yolo_boxes_to_corners(box_xy, box_wh)
   scores, boxes, classes = yolo_filter_boxes(box_confidence, boxes, box_class_probs, threshold = 
   score_threshold)
   boxes = scale_boxes(boxes, image_shape)
   scores, boxes, classes = yolo_non_max_suppression(scores, boxes, classes, max_boxes, iou_threshold)

   return scores, boxes, classes

Here is the error:这是错误:

   1606   try:
  -> 1607     c_op = c_api.TF_FinishOperation(op_desc)
   1608   except errors.InvalidArgumentError as e:

  InvalidArgumentError: Dimensions must be equal, but are 2 and 80 for 
  'mul_19' (op: 'Mul') with input shapes: [?,?,?,5,2], [?,?,?,5,80].

  During handling of the above exception, another exception occurred:

  ValueError                                Traceback (most recent call last)
  11 frames
  /tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py in 
  _create_c_op(graph, node_def, inputs, control_inputs)
  1608   except errors.InvalidArgumentError as e:
  1609     # Convert to ValueError for backwards compatibility.
  -> 1610     raise ValueError(str(e))
   1611 
  1612   return c_op

  ValueError: Dimensions must be equal, but are 2 and 80 for 'mul_19' (op: 
  'Mul') with input shapes: [?,?,?,5,2], [?,?,?,5,80].

I suspect that the problem comes from the yolo_filter_boxes() .我怀疑问题来自yolo_filter_boxes() Try doing something like this:尝试做这样的事情:

final_yolo_outputs = (yolo_outputs[2], yolo_outputs[0], yolo_outputs[1], yolo_outputs[3])

And then,接着,

scores, boxes, classes = yolo_eval(final_yolo_outputs , image_shape=(720,1280))

It would be good if you could provide the definition of the functions used as well, as suggested above.如上所述,如果您也可以提供所用函数的定义,那就太好了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:尺寸必须相等,但对于'Mul'(op:'Mul'),输入形状为784和500:[?,784],[784,500] - ValueError: Dimensions must be equal, but are 784 and 500 for 'Mul' (op: 'Mul') with input shapes: [?,784], [784,500] ValueError:尺寸必须相等,但对于输入形状为 [?,3]、[?,3072] 的“loss/output_1_loss/mul”(操作:“Mul”),尺寸为 3 和 3072 - ValueError: Dimensions must be equal, but are 3 and 3072 for 'loss/output_1_loss/mul' (op: 'Mul') with input shapes: [?,3], [?,3072] ValueError:尺寸必须相等,但对于输入形状为 [?,13]、[?,13,3076] 的“loss/dense_1_loss/mul”(操作:“Mul”),尺寸必须是 13 和 3076 - ValueError: Dimensions must be equal, but are 13 and 3076 for 'loss/dense_1_loss/mul' (op: 'Mul') with input shapes: [?,13], [?,13,3076] ValueError:尺寸必须相等,但对于“activation_2/p_re_lu_l/mul”(操作:“Mul”)分别为 16 和 28 - ValueError: Dimensions must be equal, but are 16 and 28 for 'activation_2/p_re_lu_l/mul' (op: 'Mul') ValueError:尺寸必须相等,但对于'mul'来说必须为4096和9。 为什么这里没有广播? - ValueError: Dimensions must be equal, but are 4096 and 9 for 'mul'. Why no broadcasting here? ValueError:尺寸必须相等,但对于'MatMul_1'(op:'MatMul'),输入形状为784和500:[?,784],[500,500] - ValueError: Dimensions must be equal, but are 784 and 500 for 'MatMul_1' (op: 'MatMul') with input shapes: [?,784], [500,500] ValueError:尺寸必须相等,输入形状 - ValueError: Dimensions must be equal, with input shapes ValueError:尺寸必须相等,但输入形状为[?,64],[4 ,?]的'MatMul'(op:'MatMul')的尺寸必须为64和4 - ValueError: Dimensions must be equal, but are 64 and 4 for 'MatMul' (op: 'MatMul') with input shapes: [?,64], [4,?] ValueError:尺寸必须相等,但对于具有输入形状的“p_softmax/truediv”(操作:“RealDiv”)为 3 和 300:[?,300,300,3]、[?,300,300] - ValueError: Dimensions must be equal, but are 3 and 300 for 'p_softmax/truediv' (op: 'RealDiv') with input shapes: [?,300,300,3], [?,300,300] InvalidArgumentError:需要广播形状 [Op:Mul] - InvalidArgumentError: required broadcastable shapes [Op:Mul]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM