Python 类型错误:';浮动';在实时对象检测中,对象是不可编辑的

Python 类型错误:';浮动';在实时对象检测中,对象是不可编辑的,python,Python,我是Python新手,在从事GitHub项目的实时对象检测时遇到了这个错误 File "C:\Users\pankaj\Documents\models\object_detection\utils\visualization_utils.py", line 759, in visualize_boxes_and_labels_on_image_array box = tuple(boxes[i].tolist()) TypeError: 'float' object is not i

我是Python新手,在从事GitHub项目的实时对象检测时遇到了这个错误

File "C:\Users\pankaj\Documents\models\object_detection\utils\visualization_utils.py", line 759, in visualize_boxes_and_labels_on_image_array
    box = tuple(boxes[i].tolist())

TypeError: 'float' object is not iterable
这是我的密码:

# Create a display string (and color) for every box location, group any boxes
# that correspond to the same location.
box_to_display_str_map = collections.defaultdict(list)
box_to_color_map = collections.defaultdict(str)
box_to_instance_masks_map = {}
box_to_instance_boundaries_map = {}
box_to_keypoints_map = collections.defaultdict(list)
box_to_track_ids_map = {}
if not max_boxes_to_draw:
    max_boxes_to_draw = boxes.shape[0]
for i in range(min(max_boxes_to_draw, boxes.shape[0])):
    if scores is None or scores[i] > min_score_thresh:
        box = tuple(boxes[i].tolist())  # **This is the line error is referencing to**
    if instance_masks is not None:
        box_to_instance_masks_map[box] = instance_masks[i]
    if instance_boundaries is not None:
        box_to_instance_boundaries_map[box] = instance_boundaries[i]
    if keypoints is not None:
        box_to_keypoints_map[box].extend(keypoints[i])
    if track_ids is not None:
        box_to_track_ids_map[box] = track_ids[i]
    if scores is None:
        box_to_color_map[box] = groundtruth_box_visualization_color
    else:
        display_str = ''
我如何解决这个问题以及它的实际含义是什么?

框[I]。tolist()
返回一个浮点值,但
tuple()
要求其参数是可iterable,而单个浮点值是不可iterable的

给定函数名
tolist()
,函数似乎应该以列表的形式返回单个项

一个快速解决方案可能是强制结果为列表,如下所示:

box = tuple([boxes[i].tolist()])
但这似乎是一个糟糕的解决方案,因为如果
tolist()
确实返回了一个实际的列表,这将迫使它成为一个列表列表,这可能不是您想要的


看起来真正的解决方案是修改
tolist()
始终返回一个列表,即使它只是一个项目。

欢迎使用python!您能告诉我们如何实例化
变量吗。