codeproject / CodeProject.AI-Server

CodeProject.AI Server is a self contained service that software developers can include in, and distribute with, their applications in order to augment their apps with the power of AI.
https://codeproject.github.io/codeproject.ai
Other
732 stars 160 forks source link

CPAI 2.8 docker image for arm64 unable to run module Object Detection (Yolo v5 RKNN) on Orange Pi 5 #131

Closed boxofrox closed 3 days ago

boxofrox commented 2 months ago

Area of Concern

Describe the bug Clicked install for module Object Detection Yolo v5 RKNN. Install proceeded, but failed to start module. Python runtime reports a traceback error (see below).

Expected behavior Expected Object Detection Yolo v5 RKNN to start and remain running and operational.

Screenshots If applicable, add screenshots to help explain your problem.

Your System (please complete the following information):

Additional context Logs for module installation. Python traceback is at the end of the logs. Reports two errors: AttributeError and ModuleNotFoundError.

Sep 22 01:29:07 orangepi5 ai-server[713227]: Infor Preparing to install module 'ObjectDetectionYoloRKNN'
Sep 22 01:29:07 orangepi5 ai-server[713227]: Infor Downloading module 'ObjectDetectionYoloRKNN'
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor Installing module 'ObjectDetectionYoloRKNN'
Sep 22 01:29:08 orangepi5 ai-server[713227]: Debug Installer script at '/app/setup.sh'
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting verbosity to quiet
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Hi Docker! We will disable shared python installs for downloaded modules
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: (No schemas means: we can't detect if you're in light or dark mode)
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:              Installing CodeProject.AI Analysis Module      
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: ======================================================================
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:                    CodeProject.AI Installer                 
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: ======================================================================
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: 9.01 GiB of 14.06 GiB available on Orange Pi
Sep 22 01:29:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing xz-utils...
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: General CodeProject.AI setup                                
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting permissions on runtimes folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting permissions on downloads folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting permissions on modules download folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Creating models download folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting permissions on models download folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Setting permissions on persisted data folder...done
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: GPU support                                                 
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: CUDA (NVIDIA) Present: No
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: ROCm (AMD) Present:    No
Sep 22 01:29:10 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: MPS (Apple) Present:   No
Sep 22 01:29:11 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Reading module settings.......done
Sep 22 01:29:11 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Processing module ObjectDetectionYoloRKNN 1.7.1             
Sep 22 01:29:11 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing Python 3.9
Sep 22 01:29:11 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Python 3.9 is already installed
Sep 22 01:29:16 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Ensuring PIP in base python install...  done
Sep 22 01:29:19 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Upgrading PIP in base python install... done
Sep 22 01:29:19 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing Virtual Environment tools for Linux...
Sep 22 01:29:24 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Searching for python3-pip python3-setuptools python3.9...All good.
Sep 22 01:29:34 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Creating Virtual Environment (Local)... done
Sep 22 01:29:34 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Checking for Python 3.9...(Found Python 3.9.19) All good
Sep 22 01:29:38 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Upgrading PIP in virtual environment... done
Sep 22 01:29:40 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing updated setuptools in venv... done
Sep 22 01:29:48 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Downloading Standard YOLOv5 RKNN models...Expanding... done.
Sep 22 01:29:48 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Moving contents of objectdetect-rknn-models.zip to assets...done.
Sep 22 01:29:54 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Downloading Custom YOLOv5 RKNN models...Expanding... done.
Sep 22 01:29:54 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Moving contents of objectdetect-rknn-custom-models.zip to custom-models...done.
Sep 22 01:29:54 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing Python packages for Object Detection (YOLOv5 RKNN)
Sep 22 01:29:54 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing GPU-enabled libraries: If available
Sep 22 01:29:55 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Searching for python3-pip...All good.
Sep 22 01:29:58 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Ensuring PIP compatibility... done
Sep 22 01:29:58 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Python packages will be specified by requirements.txt
Sep 22 01:33:57 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing the RK NPU specific FastDeploy 1.4... (not checked) done
Sep 22 01:33:58 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing NumPy, a package for scientific computing...Already installed
Sep 22 01:33:59 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing Pillow, a Python Image Library... (❌ failed check) done
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module License Plate Reader has version 3.2.2, but ModelReleases has max version as 3.3.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module License Plate Reader (RKNN) has version 1.4.1, but ModelReleases has max version as 1.5.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Background Remover has version 1.10.1, but ModelReleases has max version as 1.11.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Cartoonizer has version 1.6.0, but ModelReleases has max version as 1.7.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Face Processing has version 1.11.0, but ModelReleases has max version as 1.12.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module LlamaChat has version 1.6.0, but ModelReleases has max version as 1.7.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (Coral) has version 2.3.4, but ModelReleases has max version as 2.4.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (YOLOv5 RKNN) has version 1.7.1, but ModelReleases has max version as 1.8.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (YOLOv8) has version 1.5.0, but ModelReleases has max version as 1.6.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Optical Character Recognition has version 2.1.1, but ModelReleases has max version as 2.2.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Portrait Filter has version 2.0.0, but ModelReleases has max version as 2.1.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Scene Classification has version 1.7.0, but ModelReleases has max version as 1.8.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Sentiment Analysis has version 2.0.0, but ModelReleases has max version as 2.1.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Sound Classifier (TensorFlow) has version 1.3.3, but ModelReleases has max version as 1.4.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Super Resolution has version 2.1.2, but ModelReleases has max version as 2.2.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Text to Image has version 1.2.2, but ModelReleases has max version as 1.3.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Text Summary has version 1.8.1, but ModelReleases has max version as 1.9.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (YOLOv5 .NET) has version 1.10.2, but ModelReleases has max version as 1.11.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (YOLOv5 6.2) has version 1.9.2, but ModelReleases has max version as 1.10.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Object Detection (YOLOv5 3.1) has version 1.10.0, but ModelReleases has max version as 1.11.0
Sep 22 01:34:02 orangepi5 ai-server[713227]: ERROR: Module Training for YoloV5 6.2 has version 1.6.5, but ModelReleases has max version as 1.7.0
Sep 22 01:34:08 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing OpenCV, the Open source Computer Vision library... (✅ checked) done
Sep 22 01:34:16 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing the CodeProject.AI SDK... (✅ checked) done
Sep 22 01:34:16 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Installing Python packages for the CodeProject.AI Server SDK
Sep 22 01:34:18 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Searching for python3-pip...All good.
Sep 22 01:34:20 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Ensuring PIP compatibility... done
Sep 22 01:34:20 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Python packages will be specified by requirements.txt
Sep 22 01:34:21 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing Pillow, a Python Image Library...Already installed
Sep 22 01:34:21 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing Charset normalizer...Already installed
Sep 22 01:34:21 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing aiohttp, the Async IO HTTP library...Already installed
Sep 22 01:34:22 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing aiofiles, the Async IO Files library...Already installed
Sep 22 01:34:22 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing py-cpuinfo to allow us to query CPU info...Already installed
Sep 22 01:34:23 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:   - Installing Requests, the HTTP library...Already installed
Sep 22 01:34:23 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Scanning modulesettings for downloadable models...No models specified
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: A module that was compiled using NumPy 1.x cannot be run in
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: NumPy 2.0.2 as it may crash. To support both 1.x and 2.x
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: versions of NumPy, modules must be compiled with NumPy 2.0.
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: If you are a user of the module, the easiest solution will be to
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: downgrade to 'numpy<2' or try to upgrade the affected module.
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: We expect that some modules will need time to support NumPy 2.
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: Traceback (most recent call last):  File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn_adapter.py", line 7, in <module>
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from codeproject_ai_sdk import RequestData, ModuleRunner, LogMethod, JSON
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/__init__.py", line 4, in <module>
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from .module_runner import ModuleRunner
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/module_runner.py", line 36, in <module>
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from .request_data   import RequestData
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/request_data.py", line 15, in <module>
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     import cv2 as cv
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/cv2/__init__.py", line 5, in <module>
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from .cv2 import *
Sep 22 01:34:23 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: AttributeError: _ARRAY_API not found
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: Traceback (most recent call last):
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn_adapter.py", line 14, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from objectdetection_fd_rknn import init_detect, do_detect
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:   File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn.py", line 26, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN:     from module_logging import LogMethod
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error ObjectDetectionYoloRKNN: ModuleNotFoundError: No module named 'module_logging'
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Self test: Self-test failed
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Module setup time 00:05:15
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN:                 Setup complete                              
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ObjectDetectionYoloRKNN: Total setup time 00:05:17
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor Module ObjectDetectionYoloRKNN installed successfully.
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor Installer exited with code 0
Sep 22 01:34:25 orangepi5 ai-server[713227]: Trace Running module using: /app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/bin/python3
Sep 22 01:34:25 orangepi5 ai-server[713227]: Debug
Sep 22 01:34:25 orangepi5 ai-server[713227]: Debug Attempting to start ObjectDetectionYoloRKNN with /app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/bin/python3 "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn_adapter.py"
Sep 22 01:34:25 orangepi5 ai-server[713227]: Trace Starting /app...oloRKNN/bin/linux/python39/venv/bin/python3 "/app...loRKNN/objectdetection_fd_rknn_adapter.py"
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Module 'Object Detection (YOLOv5 RKNN)' 1.7.1 (ID: ObjectDetectionYoloRKNN)
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Valid:            True
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Module Path:      &lt;root&gt;/modules/ObjectDetectionYoloRKNN
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Module Location:  Internal
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** AutoStart:        True
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Queue:            objectdetection_queue
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Runtime:          python3.9
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Runtime Location: Local
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** FilePath:         objectdetection_fd_rknn_adapter.py
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Start pause:      1 sec
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Parallelism:      1
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** LogVerbosity:
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Platforms:        orangepi,radxarock
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** GPU Libraries:    installed if available
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** GPU:              use if supported
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Accelerator:
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Half Precision:   enable
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Environment Variables
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** CUSTOM_MODELS_DIR = &lt;root&gt;/modules/ObjectDetectionYoloRKNN/custom-models
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** MODELS_DIR        = &lt;root&gt;/modules/ObjectDetectionYoloRKNN/assets
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** MODEL_SIZE        = Small
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor Started Object Detection (YOLOv5 RKNN) module
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: A module that was compiled using NumPy 1.x cannot be run in
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: NumPy 2.0.2 as it may crash. To support both 1.x and 2.x
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: versions of NumPy, modules must be compiled with NumPy 2.0.
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: If you are a user of the module, the easiest solution will be to
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: downgrade to 'numpy<2' or try to upgrade the affected module.
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: We expect that some modules will need time to support NumPy 2.
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: Traceback (most recent call last):  File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn_adapter.py", line 7, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from codeproject_ai_sdk import RequestData, ModuleRunner, LogMethod, JSON
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/__init__.py", line 4, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from .module_runner import ModuleRunner
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/module_runner.py", line 36, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from .request_data   import RequestData
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/request_data.py", line 15, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     import cv2 as cv
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/cv2/__init__.py", line 5, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from .cv2 import *
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: AttributeError: _ARRAY_API not found
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: Traceback (most recent call last):
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor objectdetection_fd_rknn_adapter.py: Using PIL for image manipulation (Either OpenCV or numpy not available for this module)
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn_adapter.py", line 14, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from objectdetection_fd_rknn import init_detect, do_detect
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:   File "/app/modules/ObjectDetectionYoloRKNN/objectdetection_fd_rknn.py", line 26, in <module>
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py:     from module_logging import LogMethod
Sep 22 01:34:25 orangepi5 ai-server[713227]: Error objectdetection_fd_rknn_adapter.py: ModuleNotFoundError: No module named 'module_logging'
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor ** Module ObjectDetectionYoloRKNN has shutdown
Sep 22 01:34:25 orangepi5 ai-server[713227]: Infor objectdetection_fd_rknn_adapter.py: has exited
Sep 22 01:34:26 orangepi5 ai-server[713227]: Infor Module ObjectDetectionYoloRKNN started successfully.
boxofrox commented 2 months ago

Attempted to troubleshoot. Round 1.

  1. Entered docker shell. docker exec -it ai-server /bin/bash.
  2. Found python environment for module. cd /app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/.
  3. Noticed two things in site-packages of python environment. ls lib/python3.9/site-packages a. codeproject_ai_sdk appears to be version 0.0.21 b. numpy appears to be version 2.0.2
  4. Entered python environment. source bin/activate.
  5. Run interactive python repl. python3.9 -i.
  6. Tried to import codeproject_ai_sdk. import codeproject_ai_sdk a. This caused the same AttributeError shown in the logs above.
>>> import codeproject_ai_sdk
Unable to read module info in /app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/__init__.py", line 4, in <module>
    from .module_runner import ModuleRunner
  File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/module_runner.py", line 36, in <module>
    from .request_data   import RequestData
  File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/codeproject_ai_sdk/request_data.py", line 15, in <module>
    import cv2 as cv
  File "/app/modules/ObjectDetectionYoloRKNN/bin/linux/python39/venv/lib/python3.9/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
AttributeError: _ARRAY_API not found
Info: Using PIL for image manipulation (Either OpenCV or numpy not available for this module)

It would appear that the Object Detection Yolov5 RKNN module is not compatible with numpy 2.

So... downgrade numpy to 1.x, or rebuild module to use numpy 2?

No idea how to do either one, yet.

boxofrox commented 2 months ago

With the module's python environment active, I decided to check out the requirements.txt for the module, found it had a numpy<2 version requirement (which begs the question, "why didn't numpy 1.x install?"). Then tried to do a pip install -r requirements.txt and pip installed numpy 1.26 and removed numpy 2.0.2.

Q. Was the requirements.txt not used to set up the python environment?

(venv) root@857ed486c15c:/app/modules/ObjectDetectionYoloRKNN# cat requirements.txt
#! Python3.9

# Note that this wheel was built on, and for, an Orange Pi. It will not run on a Raspberry Pi
https://github.com/MikeLud/CodeProject.AI-Custom-IPcam-Models/raw/main/RKNN_Models/fastdeploy_python-1.4.2b0-cp39-cp39-linux_aarch64.whl # Installing the RK NPU specific FastDeploy 1.4

# numpy>=1.16.0               # Installing NumPy, the fundamental package for array computing with Python.
numpy<2.0                     # Installing NumPy, a package for scientific computing
Pillow>=4.0.0,<10.0           # Installing Pillow, a Python Image Library

#OpenCV-Python                # Installing OpenCV, the Open source Computer Vision library
# See https://raspberrypi-guide.github.io/programming/install-opencv
opencv-python==4.5.3.56       # Installing OpenCV, the Open source Computer Vision library

CodeProject-AI-SDK            # Installing the CodeProject.AI SDK

# last line empty test(venv) root@857ed486c15c:/app/modules/ObjectDetectionYoloRKNN# pip -r requirements.txt

Usage:
  pip <command> [options]

no such option: -r
(venv) root@857ed486c15c:/app/modules/ObjectDetectionYoloRKNN# pip install -r requirements.txt
Collecting fastdeploy-python==1.4.2b0 (from -r requirements.txt (line 4))
  Using cached https://github.com/MikeLud/CodeProject.AI-Custom-IPcam-Models/raw/main/RKNN_Models/fastdeploy_python-1.4.2b0-cp39-cp39-linux_aarch64.whl (29.2 MB)
Collecting numpy<2.0 (from -r requirements.txt (line 7))
  Downloading numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB)
Collecting Pillow<10.0,>=4.0.0 (from -r requirements.txt (line 8))
  Downloading Pillow-9.5.0-cp39-cp39-manylinux_2_28_aarch64.whl.metadata (9.5 kB)
Requirement already satisfied: opencv-python==4.5.3.56 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from -r requirements.txt (line 12)) (4.5.3.56)
Requirement already satisfied: CodeProject-AI-SDK in ./bin/linux/python39/venv/lib/python3.9/site-packages (from -r requirements.txt (line 14)) (0.0.21)
Requirement already satisfied: fastapi in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.115.0)
Requirement already satisfied: fastdeploy-tools>=0.0.5 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.0.5)
Requirement already satisfied: pyyaml in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (6.0.2)
Requirement already satisfied: requests in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (2.32.3)
Requirement already satisfied: tqdm in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (4.66.5)
Requirement already satisfied: wheel in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.44.0)
Requirement already satisfied: charset-normalizer in ./bin/linux/python39/venv/lib/python3.9/site-packages (from CodeProject-AI-SDK->-r requirements.txt (line 14)) (3.3.2)
Requirement already satisfied: commentjson in ./bin/linux/python39/venv/lib/python3.9/site-packages (from CodeProject-AI-SDK->-r requirements.txt (line 14)) (0.9.0)
Requirement already satisfied: aiohttp in ./bin/linux/python39/venv/lib/python3.9/site-packages (from CodeProject-AI-SDK->-r requirements.txt (line 14)) (3.10.5)
Requirement already satisfied: aiofiles in ./bin/linux/python39/venv/lib/python3.9/site-packages (from CodeProject-AI-SDK->-r requirements.txt (line 14)) (24.1.0)
Requirement already satisfied: py-cpuinfo in ./bin/linux/python39/venv/lib/python3.9/site-packages (from CodeProject-AI-SDK->-r requirements.txt (line 14)) (9.0.0)
Requirement already satisfied: uvicorn==0.16.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastdeploy-tools>=0.0.5->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.16.0)
Requirement already satisfied: asgiref>=3.4.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from uvicorn==0.16.0->fastdeploy-tools>=0.0.5->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (3.8.1)
Requirement already satisfied: click>=7.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from uvicorn==0.16.0->fastdeploy-tools>=0.0.5->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (8.1.7)
Requirement already satisfied: h11>=0.8 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from uvicorn==0.16.0->fastdeploy-tools>=0.0.5->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.14.0)
Requirement already satisfied: aiohappyeyeballs>=2.3.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (2.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (1.3.1)
Requirement already satisfied: attrs>=17.3.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (24.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (1.4.1)
Requirement already satisfied: multidict<7.0,>=4.5 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (6.1.0)
Requirement already satisfied: yarl<2.0,>=1.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (1.11.1)
Requirement already satisfied: async-timeout<5.0,>=4.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from aiohttp->CodeProject-AI-SDK->-r requirements.txt (line 14)) (4.0.3)
Requirement already satisfied: lark-parser<0.8.0,>=0.7.1 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from commentjson->CodeProject-AI-SDK->-r requirements.txt (line 14)) (0.7.8)
Requirement already satisfied: starlette<0.39.0,>=0.37.2 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.38.5)
Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (2.9.2)
Requirement already satisfied: typing-extensions>=4.8.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (4.12.2)
Requirement already satisfied: idna<4,>=2.5 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from requests->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from requests->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from requests->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (2024.8.30)
Requirement already satisfied: annotated-types>=0.6.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4->fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (0.7.0)
Requirement already satisfied: pydantic-core==2.23.4 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4->fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (2.23.4)
Requirement already satisfied: anyio<5,>=3.4.0 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from starlette<0.39.0,>=0.37.2->fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (4.6.0)
Requirement already satisfied: sniffio>=1.1 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from anyio<5,>=3.4.0->starlette<0.39.0,>=0.37.2->fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (1.3.1)
Requirement already satisfied: exceptiongroup>=1.0.2 in ./bin/linux/python39/venv/lib/python3.9/site-packages (from anyio<5,>=3.4.0->starlette<0.39.0,>=0.37.2->fastapi->fastdeploy-python==1.4.2b0->-r requirements.txt (line 4)) (1.2.2)
Downloading numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.2/14.2 MB 11.1 MB/s eta 0:00:00
Downloading Pillow-9.5.0-cp39-cp39-manylinux_2_28_aarch64.whl (3.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 11.4 MB/s eta 0:00:00
Installing collected packages: Pillow, numpy
  Attempting uninstall: Pillow
    Found existing installation: pillow 10.4.0
    Uninstalling pillow-10.4.0:
      Successfully uninstalled pillow-10.4.0
  Attempting uninstall: numpy
    Found existing installation: numpy 2.0.2
    Uninstalling numpy-2.0.2:
      Successfully uninstalled numpy-2.0.2
Successfully installed Pillow-9.5.0 numpy-1.26.4
boxofrox commented 2 months ago

AttributeError appears to be fixed by manually running pip install -r requirements.txt in the module's python environment.

Still getting the ModuleNotFoundError.

Some playing in the python repl and it seems the method for importing from module_logging must change.

(venv) root@857ed486c15c:/app/modules/ObjectDetectionYoloRKNN# python -i
Python 3.9.19 (main, Apr  6 2024, 17:57:55)
[GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import codeproject_ai_sdk
>>> import module_logging
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'module_logging'
>>>
(venv) root@857ed486c15c:/app/modules/ObjectDetectionYoloRKNN# python -i
Python 3.9.19 (main, Apr  6 2024, 17:57:55)
[GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from codeproject_ai_sdk.module_logging import LogMethod
>>> LogMethod
<enum 'LogMethod'>
>>>

And I'm assuming that this python virtual environment is important and actively used by the CPAI server to run the module in a sane/compatible python environment. If it's not, then the effort thus far is wasted.

boxofrox commented 2 months ago

My docker container bind mounts the modules folder to a host folder /srv/ai-server/modules. With this I can edit the code with the following patch, restart the module, and no error appear in the log.

--- objectdetection_fd_rknn.py.old      2024-09-24 00:54:33.836210697 +0000
+++ objectdetection_fd_rknn.py  2024-09-24 00:52:28.538719973 +0000
@@ -23,7 +23,7 @@
 from numpy import array
 from PIL import UnidentifiedImageError

-from module_logging import LogMethod
+from codeproject_ai_sdk.module_logging import LogMethod
 from options import Options

 # import fastdeploy as fd # rknn

Then used the CodeProject.AI Explorer link to test the RKNN Object Detection module. And it seems to work now. Logs from CPAI server.

21:08:54:Object Detection (YOLOv5 RKNN): Detecting using ipcam-dark-small
21:08:54:Response rec'd from Object Detection (YOLOv5 RKNN) command 'custom' (...1b6942) ['Found Person']  took 88ms
21:08:56:Object Detection (YOLOv5 RKNN): Detecting using ipcam-dark-small
21:08:56:Response rec'd from Object Detection (YOLOv5 RKNN) command 'custom' (...5df34e) ['Found Person']  took 82ms
21:08:58:Object Detection (YOLOv5 RKNN): Detecting using ipcam-dark-small
21:08:58:Response rec'd from Object Detection (YOLOv5 RKNN) command 'custom' (...3c47e9) ['Found Person']  took 60ms
boxofrox commented 2 months ago

Not sure whether the numpy 2.0.2 issue is a problem with the CPAI server install process. I haven't found any code in the module that tries to run pip install -r requirements.txt and the changelog for the last release of CPAI server updates the docs for module installation, and it seems from there that the CPAI server will determine which requirements file to use if one better suited to the platform is available.

@ChrisMaunder should I be looking at the CPAI server code for module installation to figure out why the wrong version of numpy was installed?

The ModuleNotFoundError seems to be an issue with the module. Will follow up in it's issue tracker later.

boxofrox commented 2 months ago

Looking through SDK/Scripts/utils.sh, it appears that the function installRequiredPythonPackages only uses pip install -r requirements.txt when the flag $oneStepPIP is true, otherwise, the packages are installed individually by the script to (I assume) facilitate logging of the progress of each python package installed.

The problem with this is the lack of version resolution among transitive dependencies. Take this log snippet from a recent reinstall of the RKNN Object Detector.

10:24:10:ObjectDetectionYoloRKNN:   - Installing OpenCV, the Open source Computer Vision library... package name = 'opencv-python==4.5.3.56'Checking ...Check done...Installing opencv-python==4.5.3.56...Collecting opencv-python==4.5.3.56
10:24:10:ObjectDetectionYoloRKNN:   Using cached opencv_python-4.5.3.56-cp39-cp39-manylinux2014_aarch64.whl.metadata (17 kB)
10:24:11:ObjectDetectionYoloRKNN: Collecting numpy>=1.19.3 (from opencv-python==4.5.3.56)
10:24:11:ObjectDetectionYoloRKNN:   Using cached numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB)

When the opencv_python package is installed, it requires numpy>=1.19.3 (which numpy-2.0.2 satisfies) and immediately installs numpy-2.0.2 instead of a) recognizing that a later version requirement will require numpy<2, b) recognizing there is a numpy version (1.26) that satisfies both version restrictions, and c) installing the correct version of numpy.

This would be an example of a "roll your own" solution failing to achieve the correct behavior already implemented by an existing tool.

boxofrox commented 2 months ago

Current work around for numpy<2 in CPAI Server Docker arm64.

  1. Start CPAI server container
  2. Enter container shell environment
  3. Install text editor
  4. Edit /app/setup.sh
    --- setup.sh.orig       2024-09-26 15:47:54.805517844 +0000
    +++ setup.sh    2024-09-26 15:48:08.531988124 +0000
    @@ -677,7 +677,7 @@
    # bad (and potentially unnneeded) module. Turning one-step off means you get a
    # more granular set of error messages should things go wrong, and a nicer UX.
    if [ "$inDocker" = true ]; then
    -    oneStepPIP=false
    +    oneStepPIP=true
    elif [ "$os" = "linux" ] || [ "$os" = "macos" ]; then
     oneStepPIP=false
    elif [ "$os" = "windows" ]; then
  5. Save setup.sh
  6. Exit container shell environment
  7. Install RKNN Object Detector module via CPAI server webpage.

Note: still need to resolve the import error in the RKNN module wrt module_logging separately.

ChrisMaunder commented 1 month ago

There are two options here:

  1. Add set oneStepPIP=true at the start of the install.sh install script in the RKNN YOLO project and/or
  2. Move the numpy item in the requirements.txt file to the top

Turning on one-step will allow proper version resolution (but if one pacakge fails they all fail), or making the numpy package the first item with onestep=false means numpy<2 will be installed first, then everything else should follow. Except if a subsequent package has forced a 'numpy > 2' which I've not seen yet.

I'll try get a new release out in the next few days.