rafaelpadilla / review_object_detection_metrics

Object Detection Metrics. 14 object detection metrics: mean Average Precision (mAP), Average Recall (AR), Spatio-Temporal Tube Average Precision (STT-AP). This project supports different bounding box formats as in COCO, PASCAL, Imagenet, etc.
Other
1.08k stars 215 forks source link

np.bool is deprecated #132

Closed jdede closed 1 year ago

jdede commented 1 year ago

Fix the code according to https://numpy.org/devdocs/release/1.19.0-notes.html

np.bool -> bool
rafaelpadilla commented 1 year ago

Hi @jdede

thank you for opening this issue.

can you please describe if the actual code is raising an exception or this is a nice to have for a higher numpy version?

jdede commented 1 year ago

Installed and fixed using the issue as described in #131 . UI is starting without any issues. Set up a run with the following settings:

run results into the following error:

(venv) jd@tokio:~/src/github/review_object_detection_metrics$ python3 run.py 
/home/jd/src/github/review_object_detection_metrics/src/evaluators/coco_evaluator.py:76: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  acc["matched"] = np.concatenate(acc["matched"]).astype(np.bool)
Traceback (most recent call last):
  File "/home/jd/src/github/review_object_detection_metrics/src/ui/run_ui.py", line 336, in btn_run_clicked
    coco_res = get_coco_summary(gt_annotations, det_annotations)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jd/src/github/review_object_detection_metrics/src/evaluators/coco_evaluator.py", line 92, in get_coco_summary
    full = {
           ^
  File "/home/jd/src/github/review_object_detection_metrics/src/evaluators/coco_evaluator.py", line 93, in <dictcomp>
    i: _evaluate(iou_threshold=i, max_dets=100, area_range=(0, np.inf))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jd/src/github/review_object_detection_metrics/src/evaluators/coco_evaluator.py", line 76, in _evaluate
    acc["matched"] = np.concatenate(acc["matched"]).astype(np.bool)
                                                           ^^^^^^^
  File "/home/jd/src/github/review_object_detection_metrics/venv/lib/python3.11/site-packages/numpy/__init__.py", line 319, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

PR #133 fixes this issue

rafaelpadilla commented 1 year ago

Which numpy version were you using to raise this error? Is it the same version referenced in environment.yml?

jdede commented 1 year ago
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.