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.
Other
565 stars 135 forks source link

An error while starting ObjectDetectionCoral with multi-file models #106

Open serg987 opened 2 months ago

serg987 commented 2 months ago

Area of Concern

Describe the bug Steps to repro: Download YOLOv5 Medium or YOLOv8 Medium Models through UI Restart ObjectDetectionCoral

Actual behavior Failed to load the model, cannot find asset files Logs for YOLOv8 Medium

22:39:54:CPAI_CORAL_MODEL_NAME = YOLOv8
22:39:54:CPAI_CORAL_MULTI_TPU  = True
22:39:54:MODELS_DIR            = <root>/modules/ObjectDetectionCoral/assets
22:39:54:MODEL_SIZE            = medium
22:39:54:
22:39:54:Started Object Detection (Coral) module
22:39:55:objectdetection_coral_adapter.py: ERROR:root:TFLite file /app/modules/ObjectDetectionCoral/assets/yolov8m__segment_0_of_2_edgetpu.tflite doesn't exist
22:39:55:objectdetection_coral_adapter.py: WARNING:root:Model file not found: [Errno 2] No such file or directory: '/app/modules/ObjectDetectionCoral/assets/yolov8m__segment_0_of_2_edgetpu.tflite'
22:39:55:objectdetection_coral_adapter.py: WARNING:root:No Coral TPUs found or able to be initialized. Using CPU.
22:39:55:objectdetection_coral_adapter.py: ERROR:root:TFLite file /app/modules/ObjectDetectionCoral/assets/yolov8m-416_640px.tflite doesn't exist
22:39:55:objectdetection_coral_adapter.py: WARNING:root:Unable to create interpreter for CPU using edgeTPU library: [Errno 2] No such file or directory: '/app/modules/ObjectDetectionCoral/assets/yolov8m-416_640px.tflite'

Logs for YOLOv5 Medium:

23:04:00:CPAI_CORAL_MODEL_NAME = YOLOv5
23:04:00:CPAI_CORAL_MULTI_TPU  = True
23:04:00:MODELS_DIR            = <root>/modules/ObjectDetectionCoral/assets
23:04:00:MODEL_SIZE            = medium
23:04:00:
23:04:00:Started Object Detection (Coral) module
23:04:01:objectdetection_coral_adapter.py: ERROR:root:TFLite file /app/modules/ObjectDetectionCoral/assets/yolov5m-int8_edgetpu_segment_0_of_4_edgetpu.tflite doesn't exist
23:04:01:objectdetection_coral_adapter.py: WARNING:root:Model file not found: [Errno 2] No such file or directory: '/app/modules/ObjectDetectionCoral/assets/yolov5m-int8_edgetpu_segment_0_of_4_edgetpu.tflite'
23:04:01:objectdetection_coral_adapter.py: WARNING:root:No Coral TPUs found or able to be initialized. Using CPU.
23:04:01:objectdetection_coral_adapter.py: WARNING:root:Unable to load delegate for TPU cpu: Failed to load delegate from libedgetpu.so.1
23:04:01:objectdetection_coral_adapter.py: WARNING:root:Unable to create interpreter for CPU using edgeTPU library: cpu

Looks like there's a discrepancy between what the module wants and what is actually in assets;

there's no yolov8m__segment_0_of_2_edgetpu.tflite, but yolov8m_416_640px_segment_0_of_2_edgetpu.tflite

no yolov8m-416_640px.tflite, but yolov8m_416_640px.tflite

no yolov5m-int8_edgetpu_segment_0_of_4_edgetpu.tflite, but yolov5m-int8_segment_0_of_4.tflite

After manually renaming the files it works well.

Though interesting - as it wants yolov8m__segment_0_of_2_edgetpu.tflite for the first segment, for the second one it wants the existing yolov8m_416_640px_segment_1_of_2_edgetpu.tflite. For YOLOv5 all files were renamed to make it work.

Expected behavior ObjectDetectionCoral should start with the multi-file model

Screenshots YOLOv5 logs: 240418-2

YOLOv8 logs; 240418-1

ls assets/: 240418-3

Your System (please complete the following information):