![](/img/trans.png)
[英]ValueError: Dimensions must be equal, but are 784 and 500 for 'Mul' (op: 'Mul') with input shapes: [?,784], [784,500]
[英]ValueError: Dimensions must be equal, but are 2 and 80 for 'mul_18' (op: 'Mul') with input shapes: [?,?,?,5,2], [?,?,?,5,80]
我正在嘗試在 Google Collab 中使用 Yolo 檢測對象。 這是我正在執行但出現值錯誤的一段代碼。 尋求幫助,卡在這里一個多星期。
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))
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
這是錯誤:
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].
我懷疑問題來自yolo_filter_boxes()
。 嘗試做這樣的事情:
final_yolo_outputs = (yolo_outputs[2], yolo_outputs[0], yolo_outputs[1], yolo_outputs[3])
接着,
scores, boxes, classes = yolo_eval(final_yolo_outputs , image_shape=(720,1280))
如上所述,如果您也可以提供所用函數的定義,那就太好了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.