Unity-Technologies / com.unity.perception

Perception toolkit for sim2real training and validation in Unity
Other
910 stars 177 forks source link

KeyError: 'instances' when converting solo to coco using solo2coco #555

Closed YueYaoUoS closed 1 year ago

YueYaoUoS commented 1 year ago

There was an error calling when I was trying to use solo2coco to convert my solo dataset to coco. It said "KeyError: 'instances'". It happened in one specific solo dataset. Others were converted with no problem. I have compared the data and JSON files between them and they have no difference. Could someone please examine this issue and give me some advice? Thank you! Below is the error traceback:

Traceback (most recent call last): File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\Scripts\solo2coco.exe__main.py", line 7, in File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\converters\solo2coco.py", line 474, in cli converter.convert(output_path=args.coco_path, dataset_name=args.name) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\converters\solo2coco.py", line 443, in convert for idx, frame in enumerate(self._solo.frames()): File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\iterators\frame_iterator.py", line 85, in next return self.load_frame(self.frame_idx) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\iterators\frame_iterator.py", line 100, in __load_frame return self.parse_frame(files[0]) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\iterators\frame_iterator.py", line 75, in parse_frame frame = Frame.from_json(f.read()) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\api.py", line 65, in from_json return cls.from_dict(kvs, infer_missing=infer_missing) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\api.py", line 72, in from_dict return _decode_dataclass(cls, kvs, infer_missing) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\core.py", line 208, in _decode_dataclass return cls(init_kwargs) File "", line 9, in init File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 294, in __post_init__ self.captures = [DataFactory.cast_capture(capture) for capture in self.captures] File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 294, in self.captures = [DataFactory.cast_capture(capture) for capture in self.captures] File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 145, in cast_capture return klass.from_dict(data) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\api.py", line 72, in from_dict return _decode_dataclass(cls, kvs, infer_missing) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\core.py", line 208, in _decode_dataclass return cls(init_kwargs) File "", line 16, in init File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 36, in __post_init__ self.annotations = [ File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 39, in if DataFactory.cast_annotation(anno) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\pysolotools\core\models\solo.py", line 128, in cast_annotation return klass.from_dict(data) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\api.py", line 72, in from_dict return _decode_dataclass(cls, kvs, infer_missing) File "C:\Users\YueYao\anaconda3\envs\pysolotools_env\lib\site-packages\dataclasses_json\core.py", line 159, in _decode_dataclass field_value = kvs[field.name] KeyError: 'instances'

mark1ng123 commented 1 year ago

Hey, i faced the same issue a week ago, To convert your dataset you have to add 2d bbox labeler in your simulation, In my case i tried doing only segmentation dataset and its not yet supported probably, you can try to dig in the source code and maybe add it :) Hope i helped, Mark

YueYaoUoS commented 1 year ago

Hey, i faced the same issue a week ago, To convert your dataset you have to add 2d bbox labeler in your simulation, In my case i tried doing only segmentation dataset and its not yet supported probably, you can try to dig in the source code and maybe add it :) Hope i helped, Mark

Thank you Mark. My dataset included the 2d bbox labeler. So I think it's not the problem you mentioned. But it is indeed a problem related to segmentation labelling. I found that if the number of foreground components is low in the game scene, for example, only a corner of one component is included in the scene, this problem will happen. I tried decreasing the separation distance of the foreground (which means the number of components is increased), and the problem was solved.