我正在尝试在Google合作实验室的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].
答案 0 :(得分:0)
我怀疑问题来自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))
如果您还可以提供上面所建议的功能的定义,那将是很好的。