Hi sabarim,
I think the assertion statement of
|
def apply_category_id_mapping(self, mapping): |
|
assert set(mapping.keys()) == set(self.instance_categories.keys()) |
|
self.instance_categories = { |
|
iid: mapping[current_cat_id] for iid, current_cat_id in self.instance_categories.items() |
|
} |
is not correct.
We use the mapping to rename the values of
self.instance_categories, so we should check if the values of
self.instance_categories are the same as the keys in the
mapping.
This can be illustrated by the following example
from stemseg.data.generic_video_dataset_parser import GenericVideoSequence
seq = GenericVideoSequence(base_dir="some/dir",
seq_dict={"image_paths": ["1.png", "2.png"],
"height": 128,
"width": 256,
"id": "some_id",
"categories": {1: "Person", 2: "Car", 3: "Car"}})
seq.apply_category_id_mapping({"Person":11, "Car":22})
that fails with the following assertion
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "stemseg/data/generic_video_dataset_parser.py", line 107, in apply_category_id_mapping
assert set(mapping.keys()) == set(self.instance_categories.keys())
AssertionError
While the following incorrect code passes the assertion check and fails with a KeyError:
from stemseg.data.generic_video_dataset_parser import GenericVideoSequence
seq = GenericVideoSequence(base_dir="some/dir",
seq_dict={"image_paths": ["1.png", "2.png"],
"height": 128,
"width": 256,
"id": "some_id",
"categories": {1: "Person", 2: "Car", 3: "Car"}})
seq.apply_category_id_mapping({1: 11, 2: 22, 3:33})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "stemseg/data/generic_video_dataset_parser.py", line 109, in apply_category_id_mapping
iid: mapping[current_cat_id] for iid, current_cat_id in self.instance_categories.items()
File "stemseg/data/generic_video_dataset_parser.py", line 109, in <dictcomp>
iid: mapping[current_cat_id] for iid, current_cat_id in self.instance_categories.items()
KeyError: 'Person'
Thanks,
Runinho
Hi sabarim,
I think the assertion statement of
STEm-Seg/stemseg/data/generic_video_dataset_parser.py
Lines 106 to 110 in 76e358f
is not correct.
We use the mapping to rename the values of
self.instance_categories, so we should check if the values ofself.instance_categoriesare the same as the keys in themapping.This can be illustrated by the following example
that fails with the following assertion
While the following incorrect code passes the assertion check and fails with a
KeyError:Thanks,
Runinho