template_ffd icon indicating copy to clipboard operation
template_ffd copied to clipboard

Questions about KeyError

Open little-Paul-3 opened this issue 3 years ago • 4 comments

Hi @jackd , I encountered a problem when I was learning your code. I read it in issues for a long time, and no one encountered this problem. I think I made a mistake in which step, but I didn't know about it, so I want to consult you, I would appreciate it if you could help me T^T I encountered the following problem when I was training create_voxel.py:

Traceback (most recent call last):
  File "create_voxels.py", line 35, in <module>
    cat_desc=args.cat)
  File "create_voxels.py", line 19, in create_voxels
    overwrite=overwrite)
  File "/home/louise/FFD/template_ffd/inference/voxels.py", line 137, in create_voxel_data
    _create_unfilled_voxel_data(**kwargs)
  File "/home/louise/FFD/template_ffd/inference/voxels.py", line 77, in _create_unfilled_voxel_data
    model_id, edge_length_threshold)
  File "/home/louise/FFD/template_ffd/inference/meshes.py", line 46, in get_inferred_mesh_dataset
    return manager.get_lazy_dataset()
  File "/home/louise/FFD/template_ffd/inference/meshes.py", line 32, in get_lazy_dataset
    self._edge_length_threshold)
  File "/home/louise/FFD/template_ffd/model/template_ffd_builder.py", line 450, in get_prediction_to_mesh_fn
    edge_length_threshold=edge_length_threshold) as d:
  File "/home/louise/FFD/template_ffd/templates/ffd.py", line 94, in get_ffd_dataset
    datasets = {c: _get_ffd_dataset(c, **kwargs) for c in cat_ids}
  File "/home/louise/FFD/template_ffd/templates/ffd.py", line 94, in <dictcomp>
    datasets = {c: _get_ffd_dataset(c, **kwargs) for c in cat_ids}
  File "/home/louise/FFD/template_ffd/templates/ffd.py", line 83, in _get_ffd_dataset
    return manager.get_saved_dataset()
  File "/home/louise/FFD/dids/auto_save.py", line 81, in get_saved_dataset
    self.save_all()
  File "/home/louise/FFD/dids/auto_save.py", line 77, in save_all
    with self.get_auto_saving_dataset('a') as ds:
  File "/home/louise/FFD/dids/auto_save.py", line 69, in get_auto_saving_dataset
    self.get_lazy_dataset(),
  File "/home/louise/FFD/template_ffd/templates/ffd.py", line 58, in get_lazy_dataset
    self._cat_id, self._edge_length_threshold)
  File "/home/louise/FFD/template_ffd/templates/mesh_ffd.py", line 68, in get_template_mesh_dataset
    return _get_template_mesh_dataset(cat_id, edge_length_threshold)
  File "/home/louise/FFD/template_ffd/templates/mesh_ffd.py", line 58, in _get_template_mesh_dataset
    edge_length_threshold=edge_length_threshold)
  File "/home/louise/FFD/template_ffd/templates/mesh_ffd.py", line 48, in get_split_template_mesh_dataset
    cat_id, edge_length_threshold).get_saved_dataset()
  File "/home/louise/FFD/dids/auto_save.py", line 81, in get_saved_dataset
    self.save_all()
  File "/home/louise/FFD/dids/auto_save.py", line 77, in save_all
    with self.get_auto_saving_dataset('a') as ds:
  File "/home/louise/FFD/dids/core.py", line 45, in __enter__
    self.open()
  File "/home/louise/FFD/dids/core.py", line 70, in open
    self.open_connection(self)
  File "/home/louise/FFD/dids/core.py", line 56, in open_connection
    self._open_resource()
  File "/home/louise/FFD/dids/auto_save.py", line 47, in _open_resource
    self.src.open_connection(self)
  File "/home/louise/FFD/dids/core.py", line 56, in open_connection
    self._open_resource()
  File "/home/louise/FFD/dids/core.py", line 369, in _open_resource
    self._base.open_connection(self)
  File "/home/louise/FFD/dids/core.py", line 56, in open_connection
    self._open_resource()
  File "/home/louise/FFD/dids/core.py", line 630, in _open_resource
    self._check_keys()
  File "/home/louise/FFD/dids/core.py", line 594, in _check_keys
    raise KeyError('key %s not present in base' % str(key))
KeyError: 'key 9c1b448ec62cb9fb36dd029536673b0b not present in base'

Hope you can give me some advice, I've been stuck in preprocessing for a long time. Thanks a lot!

little-Paul-3 avatar Mar 20 '21 02:03 little-Paul-3

Well this is a blast from the past. Afraid I haven't worked on this for quite a while, but I'd suggest deleting any cached intermediaries. If a process that creates these cached files is interrupted while running, subsequent runs may see the partially processed files and interpret their presence as meaning the process finished, then run into trouble later. Not a perfect solution, but sufficed at the time. If you've done this and the error persists then I'll look into it further.

jackd avatar Mar 20 '21 08:03 jackd

Hi @jackd, I'm really glad to receive your reply! Thanks for your advice! I followed your advice to delete all cached files and reran the codes, but this key errors problem still exist......

However, I notice that the .hdf5 file generated by generate_mesh_data is unreadable code, which cannot be opened with any tool that reads such a file. I think maybe I use the wrong version of python or tensorflow. Would you please tell me the version of python and tensorflow? Thanks a lot!

little-Paul-3 avatar Mar 31 '21 16:03 little-Paul-3

hmm... I've learned a lot about distributing code in the last 3 years, including the importance of specifying versions of things... alas that means I didn't know it when I wrote this repo. Can you try python 2.7 and tf 1.4? Pretty confident on the python version, not so much on the tf side of things.

jackd avatar Mar 31 '21 23:03 jackd

Thanks!!! I will try it!!

little-Paul-3 avatar Apr 01 '21 00:04 little-Paul-3