Skip to content

Error when trying to visualize synthetic dataset #3

@tensarflow

Description

@tensarflow

Hey everyone!

Thanks for the great work and thanks for sharing the code.

I have an issue when trying to visualize the dataset I generated synthetically with the synthetic data generation tool provided by this repo. I run the notebook inspect_dataset and get following error in the second cell:

---------------------------------------------------------------------------
ConstructorError                          Traceback (most recent call last)
Cell In [5], line 3
      1 # ds_name = 'ycbv.train.real'
      2 ds_name = 'synthetic.ycbv-1M.train'
----> 3 scene_ds = make_scene_dataset(ds_name)

File ~/cosypose/cosypose/datasets/datasets_cfg.py:139, in make_scene_dataset(ds_name, n_frames)
    137     is_train = 'train' in ds_name.split('.')[-1]
    138     ds_name = ds_name.split('.')[1]
--> 139     ds = SyntheticSceneDataset(ds_dir=LOCAL_DATA_DIR / 'synt_datasets' / ds_name, train=is_train)
    141 else:
    142     raise ValueError(ds_name)

File ~/cosypose/cosypose/datasets/synthetic_dataset.py:22, in SyntheticSceneDataset.__init__(self, ds_dir, train)
     20 keys_path = ds_dir / (('train' if train else 'val') + '_keys.pkl')
     21 keys = pkl.loads(keys_path.read_bytes())
---> 22 self.cfg = yaml.load((ds_dir / 'config.yaml').read_text(), Loader=yaml.FullLoader)
     23 self.object_set = self.cfg.scene_kwargs['urdf_ds']
     24 self.keys = keys

File ~/anaconda3/envs/cosypose/lib/python3.10/site-packages/yaml/__init__.py:81, in load(stream, Loader)
     79 loader = Loader(stream)
     80 try:
---> 81     return loader.get_single_data()
     82 finally:
     83     loader.dispose()

File ~/anaconda3/envs/cosypose/lib/python3.10/site-packages/yaml/constructor.py:51, in BaseConstructor.get_single_data(self)
     49 node = self.get_single_node()
     50 if node is not None:
---> 51     return self.construct_document(node)
     52 return None

File ~/anaconda3/envs/cosypose/lib/python3.10/site-packages/yaml/constructor.py:55, in BaseConstructor.construct_document(self, node)
     54 def construct_document(self, node):
---> 55     data = self.construct_object(node)
     56     while self.state_generators:
     57         state_generators = self.state_generators

File ~/anaconda3/envs/cosypose/lib/python3.10/site-packages/yaml/constructor.py:100, in BaseConstructor.construct_object(self, node, deep)
     98             constructor = self.__class__.construct_mapping
     99 if tag_suffix is None:
--> 100     data = constructor(self, node)
    101 else:
    102     data = constructor(self, tag_suffix, node)

File ~/anaconda3/envs/cosypose/lib/python3.10/site-packages/yaml/constructor.py:427, in SafeConstructor.construct_undefined(self, node)
    426 def construct_undefined(self, node):
--> 427     raise ConstructorError(None, None,
    428             "could not determine a constructor for the tag %r" % node.tag,
    429             node.start_mark)

ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object:argparse.Namespace'
  in "<unicode string>", line 1, column 1:
    !!python/object:argparse.Namespace
    ^

I think there is a problem with the structure of the YAML file. When I delete !!python/object:argparse.Namespace in the first line and !!python/object/apply:pathlib.PosixPath in the third line inside the YAML file of the dataset, I get following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [6], line 3
      1 # ds_name = 'ycbv.train.real'
      2 ds_name = 'synthetic.ycbv-1M.train'
----> 3 scene_ds = make_scene_dataset(ds_name)

File ~/cosypose/cosypose/datasets/datasets_cfg.py:139, in make_scene_dataset(ds_name, n_frames)
    137     is_train = 'train' in ds_name.split('.')[-1]
    138     ds_name = ds_name.split('.')[1]
--> 139     ds = SyntheticSceneDataset(ds_dir=LOCAL_DATA_DIR / 'synt_datasets' / ds_name, train=is_train)
    141 else:
    142     raise ValueError(ds_name)

File ~/cosypose/cosypose/datasets/synthetic_dataset.py:23, in SyntheticSceneDataset.__init__(self, ds_dir, train)
     21 keys = pkl.loads(keys_path.read_bytes())
     22 self.cfg = yaml.load((ds_dir / 'config.yaml').read_text(), Loader=yaml.FullLoader)
---> 23 self.object_set = self.cfg.scene_kwargs['urdf_ds']
     24 self.keys = keys
     26 urdf_ds_name = self.cfg.scene_kwargs['urdf_ds']

AttributeError: 'dict' object has no attribute 'scene_kwargs'

When I try to validate the content of the YAML file with https://codebeautify.org/yaml-validator, I get errors in both versions. I think there is something with the !! expressions. While python seems to not have a problem with these expressions when I remove the two lines mentioned above, but rather has a problem with the content of file, it cant find the scene_kwargs attribute.

Any help is appreciated. Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions