digitalpathologybern / hover_next_inference

Inference code for HoVer-NeXt
GNU General Public License v3.0
14 stars 4 forks source link

Fix KeyError in create_geojson function by correctly handling cid #5

Closed neelrajpatil closed 3 weeks ago

neelrajpatil commented 3 weeks ago

Description:

This pull request fixes the KeyError issue in the create_geojson function found in viz_utils.py. The error occurs because the cid value is always a list or tuple, which leads to an incorrect key lookup in the lookup dictionary.

Changes Made:

Issue Reference:

This pull request addresses issue #4, where the KeyError was reported.

Error Message:

Traceback (most recent call last):
  File "path/to/main.py", line 232, in <module>
    main(params)
  File "path/to/main.py", line 117, in main
    z_pp = post_process_main(
           ^^^^^^^^^^^^^^^^^^
  File "path/to/src/post_process.py", line 95, in post_process_main
    create_polygon_output(pinst_out, pcls_out, params["output_dir"], params)
  File "path/to/src/viz_utils.py", line 118, in create_polygon_output
    create_geojson(
  File "path/to/src/viz_utils.py", line 34, in create_geojson
    "name": lookup[cid],
            ~~~~~~^^^^^
KeyError: (6, (1248.144578313253, 9795.885542168675))