SoccerNet / sn-gamestate

[CVPRW'24] SoccerNet Game State Reconstruction: End-to-End Athlete Tracking and Identification on a Minimap (CVPR24 - CVSports workshop)
240 stars 51 forks source link

TypeError: Object of type float32 is not JSON serializable when saving json file with results #3

Closed Tengoles closed 8 months ago

Tengoles commented 8 months ago

There is an error when saving the json file at the end of running tracklab -cn soccernet with eval_tracking: True

Traceback (most recent call last):
  File "/home/enzo/conda_envs/GameStateChallenge/bin/tracklab", line 8, in <module>
    sys.exit(main())
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "/home/enzo/GameStateChallenge/src/tracklab/tracklab/main.py", line 62, in main
    evaluate(cfg, evaluator, tracker_state)
  File "/home/enzo/GameStateChallenge/src/tracklab/tracklab/main.py", line 108, in evaluate
    evaluator.run(tracker_state)
  File "/home/enzo/GameStateChallenge/src/tracklab/tracklab/wrappers/eval/trackeval_evaluator.py", line 35, in run
    self.tracking_dataset.save_for_eval(
  File "/home/enzo/GameStateChallenge/src/tracklab/tracklab/wrappers/datasets/soccernet/soccernet_game_state.py", line 80, in save_for_eval
    json.dump({"predictions": video_predictions}, fp, indent=2)
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/home/enzo/conda_envs/GameStateChallenge/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type float32 is not JSON serializable

Seems like video_predictions requires some conversions before dumping it to a json

VlSomers commented 8 months ago

Hi @Tengoles, this error should have been fixed in this Tracklab commit, can you make sure Tracklab is up to date? Do not forget to "pip install -e ../tracklab" after pulling the latest changes, as discussed in sn-gamestate README. Let me know if this fixes your issue!