SamsungLabs / ritm_interactive_segmentation

Reviving Iterative Training with Mask Guidance for Interactive Segmentation
MIT License
632 stars 125 forks source link

Incompatible with NumPy 1.24+ #36

Open SpecLad opened 1 year ago

SpecLad commented 1 year ago

NumPy 1.24 removed np.object, np.bool, np.float, np.complex, np.str, and np.int. Some of them are used in this project, so it no longer works when NumPy 1.24+ is installed:

$ python3 demo.py --checkpoint=./coco_lvis_h18_itermask.pth
Traceback (most recent call last):
  File "/tmp/ritm_interactive_segmentation/demo.py", line 57, in <module>
    main()
  File "/tmp/ritm_interactive_segmentation/demo.py", line 16, in main
    model = utils.load_is_model(checkpoint_path, args.device, cpu_dist_maps=True)
  File "/tmp/ritm_interactive_segmentation/isegm/inference/utils.py", line 33, in load_is_model
    return load_single_is_model(state_dict, device, **kwargs)
  File "/tmp/ritm_interactive_segmentation/isegm/inference/utils.py", line 37, in load_single_is_model
    model = load_model(state_dict['config'], **kwargs)
  File "/tmp/ritm_interactive_segmentation/isegm/utils/serialization.py", line 64, in load_model
    return model_class(**model_args)
  File "/tmp/ritm_interactive_segmentation/isegm/utils/serialization.py", line 39, in new_init
    init(self, *args, **kwargs)
  File "/tmp/ritm_interactive_segmentation/isegm/model/is_hrnet_model.py", line 15, in __init__
    self.feature_extractor = HighResolutionNet(width=width, ocr_width=ocr_width, small=small,
  File "/tmp/ritm_interactive_segmentation/isegm/model/modeling/hrnet_ocr.py", line 208, in __init__
    last_inp_channels = np.int(np.sum(pre_stage_channels))
  File "/tmp/venv/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
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: 'inf'?

This should be easy to fix - just remove the np. prefix.