IDEA-Research/Grounded-SAM-2

Correct masks but wrong classes over time

rmarcuzzi opened this issue · 1 comments

Hi, and thanks a lot for the great work!
I'm using the model to perform segmentation and tracking on a sequence of images. I'm using the grounded_sam2_tracking_demo_with_continuous_id_plus.py.
The consecutive images look like this:

000003

I'm using as prompt text = "car. road. truck. person. building. tree. grass." and the result looks very good!

000003

However, after a couple of steps, the masks and IDs are consistent but the classes change as shown here:

000013

For example, the road is correctly segmented and keeps the ID 2 but the class changes to person. The same happens with mask 11 which changes from truck (correct class) to road.

For the following predictions, the same happens. The masks and IDs are correct but some the classes change again.

000020

I was wondering how to solve this problem or whether is a problem when saving the classes for visualization.

Thanks a lot!

The problem was in common_utils.py.
The lists all_object_ids and all_object_boxes are sorted but the list all_class_names is not. Pairing id, box and class here and later also sorting the all_class_names list solves the issue.