cocodataset / panopticapi

COCO 2018 Panoptic Segmentation Task API (Beta version)
Other
420 stars 185 forks source link

Error when extracting semantic segmentation json from panoptic segmentation json #43

Open matteosodano opened 3 years ago

matteosodano commented 3 years ago

Following these indications, I am trying to obtain the json file for semantic segmentation, starting from the json file for panoptic segmentation.

The command that I used: python converters/panoptic2semantic_segmentation.py --input_json_file /path/to/json/panoptic_<train, val>2017.json --output_json_file /path/to/json/semantic_<train, val>2017.json

The error:

  File "converters/panoptic2semantic_segmentation.py", line 210, in <module>
    extract_semantic(args.input_json_file,
  File "converters/panoptic2semantic_segmentation.py", line 174, in extract_semantic
    json.dump(d_coco, out)
  File "/usr/lib/python3.8/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable

Other information: I successfully used the converter for the images (from panoptic json to folder with semantic segmentation png) with both the training and validation set.

Python version: 3.8.5

italosalgado14 commented 3 years ago

Use "python2" insted of "python" in your command. Saludos!

dokunima commented 2 years ago

@matteosodano did you find a solution?