Object class_name BUG?
Opened this issue · 0 comments
I found that when executing ‘grounded_sam2_tracking_demo_with_continuous_id.py’, the resulting segmented image has an incorrect correspondence between id and class_name, but the mask file it produces is correct . After checking, I found that there is a problem with the functions in the ‘common_ultils.py’ file, and I need to make the following changes: Original code: sam2_tracking_demo_with_continuous_id.py
Original code:
Sort object IDs and boxes, but not class names
paired_id_and_box = zip(all_object_ids, all_object_boxes)
sorted_pair = sorted(paired_id_and_box, key=lambda pair: pair[0])
After sorting, reorder only IDs and boxes
all_object_ids = [pair[0] for pair in sorted_pair] all object identifiers
all_object_boxes = [pair[1] for pair in sorted_pair] all object boxes
Fixed code:
Sort object IDs, boxes and class names together for consistency
paired_id_and_box_and_class = zip(all_object_ids, all_object_boxes, all_class_names)
sorted_pair = sorted(paired_id_and_box_and_class, key=lambda pair: pair[0]) # Sort based on object IDs
After sorting, reorder IDs, boxes and class names together
all_object_ids = [pair[0] for pair in sorted_pair] all object IDs
all_object_boxes = [pair[1] for pair in sorted_pair] all object boxes
all_class_names = [pair[2] for pair in sorted_pair] all class names