Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CocoAnnotationsWriter generating different categories across breaking "append_to_existing_output" option #43

Closed
travis575757 opened this issue Jul 16, 2020 · 2 comments

Comments

@travis575757
Copy link

I am trying to run CocoAnnotationsWriter repeatedly to produce a dataset, however sometimes an exception is raised "The existing coco annotations file contains different categories/objects than the current scene. Merging the two lists is not implemented yet" even though I haven't changed the dataset. I would expect that running the config would generate the same categories as without this functionality there wouldn't be much use is using "append_to_existing_output".

If this is expected behavior what should I do to prevent this from happening? I would like to execute this config N times and get N*number_of_samples annotated images contained in ./testing_multi/output/coco_data/coco_annotations.json where number_of_samples comes from the argument of camera.CameraSampler. See the config below for where these values are coming from.

Reproduce

To reproduce go into the config of the coco_annotations example and replace the camera.CameraLoader with

    {
      "module": "camera.CameraSampler",
      "config": {
        "cam_poses": [
          {
            "number_of_samples": 2,
            "location": {
              "provider":"sampler.Uniform3d",
              "max":[10, 10, 8],
              "min":[-10, -10, 12]
            },
            "rotation": {
              "format": "look_at",
              "value": {
                "provider": "getter.POI"
              },          
              "inplane_rot": {
                "provider": "sampler.Value",
                "type": "float",
                "min": -0.7854,
                "max": 0.7854
              }
            }
          }
        ]
      }
    },

and also enable appending annotations

    {
      "module": "writer.CocoAnnotationsWriter",
      "config": {
        "append_to_existing_output": True,
      }
    }

My full config is below, I've also hardcoded the arguments used in the example

# Args: <cam_file> <obj_file> <output_dir>
{
  "version": 3,
  "setup": {
    "blender_install_path": "/home_local/<env:USER>/blender/",
    "pip": [
      "h5py",
      "scikit-image"
    ]
  },
  "modules": [
    {
      "module": "main.Initializer",
      "config": {
        "global": {
          "output_dir": "./testing_multi/output"
        }
      }
    },
    {
      "module": "loader.BlendLoader",
      "config": {
        "path": "./testing_multi/scene.blend",
        "load_from": "/Object"  # load all objects from the scene file
      }
    },
    {
      "module": "manipulators.WorldManipulator",
      "config": {
        "cf_set_world_category_id": 0  # this sets the worlds background category id to 0
      }
    },
    {
      "module": "lighting.LightLoader",
      "config": {
        "lights": [
          {
            "type": "POINT",
            "location": [5, -5, 5],
            "energy": 1000
          }
        ]
      }
    },
    {
      "module": "camera.CameraSampler",
      "config": {
        "cam_poses": [
          {
            "number_of_samples": 2,
            "location": {
              "provider":"sampler.Uniform3d",
              "max":[10, 10, 8],
              "min":[-10, -10, 12]
            },
            "rotation": {
              "format": "look_at",
              "value": {
                "provider": "getter.POI"
              },          
              "inplane_rot": {
                "provider": "sampler.Value",
                "type": "float",
                "min": -0.7854,
                "max": 0.7854
              }
            }
          }
        ]
      }
    },
    {
      "module": "renderer.RgbRenderer",
      "config": {
        "output_key": "colors"
      }
    },
    {
      "module": "renderer.SegMapRenderer",
      "config": {
        "map_by": ["instance","class"],
      }
    },
    {
      "module": "writer.CocoAnnotationsWriter",
      "config": {
        "append_to_existing_output": True,
      }
    }
  ]
}

Running multiple times should raise the error previously mentioned and replicated below. You might need to delete the dataset and reattempt a few times to get the problem to occur.

"The existing coco annotations file contains different categories/objects than the current scene. Merging the two lists is not implemented yet."

Which occurs raised at line 102 of src/utility/CocoUtility.py

@MartinSmeyer
Copy link
Member

Thanks, the fix will be merged and probably released today in 1.5.1.

@MartinSmeyer
Copy link
Member

It should be fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants