aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
9.8k stars 6.67k forks source link

object_detection_birds - numpy depency issue #4560

Open jacobscgc opened 4 months ago

jacobscgc commented 4 months ago

Link to the notebook https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/object_detection_birds/object_detection_birds.ipynb

Describe the bug In this notebook, it is using im2rec.py to create the RecordIO files. However, mxnet, used there, depends on an older version of numpy which is no longer supported. This leads to this error:

AttributeError: module 'numpy' has no attribute 'bool'

Change cell 1 from:

# These packages are needed to use OpenCV in Studio as of February 2022
! pip install distro
import distro
if "debian" in distro.linux_distribution()[0].lower():
    ! apt-get update
    ! apt-get install ffmpeg libsm6 libxext6  -y

To:

# These packages are needed to use OpenCV in Studio as of February 2022
! pip install distro
# We need to downgrade numpy because it otherwise interferes with mxnet, which is used in the im2rec.py script (generates model input):
!python -m pip install numpy==1.23.1
import distro
if "debian" in distro.name().lower():
    ! pip install --upgrade pip
    ! apt-get update
    ! apt-get install ffmpeg libsm6 libxext6  -y

Fixes the issue (and removes an error log on distro.linux_distribution).

To reproduce Load the repo into Sagemaker running the Data Science 3.0 python3 kernel using ml.t3.medium.

Logs If applicable, add logs to help explain your problem. You may also attach an .ipynb file to this issue if it includes relevant logs or output.

ps. mxnet has been archived and therefore I do not expect any updates there.