[英]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.