onnx / onnx/models

Numpy deprecating alias np.bool when running 'python imagenet_inference.py'

Open
#648 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Which model does this pertain to?

https://github.com/onnx/models/tree/main/validated/vision/classification/squeezenet

Describe the bug

Describe the problem with the model and the results you are seeing.

Reproduction instructions

Convert https://github.com/onnx/models/blob/main/validated/vision/classification/imagenet_inference.ipynb into a python file and then run 'python imagenet_inference.py' you receive the following error:

Admin:~/environment/squeezenet1.1 $ python3 imagenet_inference.py
/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/numpy/utils.py:37: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  bool = onp.bool
Traceback (most recent call last):
  File "/home/ec2-user/environment/squeezenet1.1/imagenet_inference.py", line 34, in <module>
    import mxnet as mx
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/__init__.py", line 33, in <module>
    from . import contrib
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/contrib/__init__.py", line 30, in <module>
    from . import text
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/contrib/text/__init__.py", line 23, in <module>
    from . import embedding
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/contrib/text/embedding.py", line 36, in <module>
    from ... import numpy as _mx_np
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/numpy/__init__.py", line 23, in <module>
    from .multiarray import *  # pylint: disable=wildcard-import
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/numpy/multiarray.py", line 47, in <module>
    from .utils import _get_np_op
  File "/home/ec2-user/.local/lib/python3.9/site-packages/mxnet/numpy/utils.py", line 37, in <module>
    bool = onp.bool
  File "/home/ec2-user/.local/lib/python3.9/site-packages/numpy/__init__.py", line 324, 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

System Information

OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Amazon Linux 2023
ONNX version (e.g. 1.6): 1.7
Backend/Runtime version (e.g. ONNX Runtime 1.1, PyTorch 1.2):

Provide a code snippet to reproduce your errors.

import onnx
model = onnx.load('model.onnx')
...
Notes

Any additional information

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with validated/vision/classification/imagenet_inference.ipynb, convert it as described, and run python imagenet_inference.py. Trace the NumPy/MXNet compatibility failure shown in the report; done means the SqueezeNet inference example runs without the np.bool AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.