Skip to content

Commit 6d37984

Browse files
author
ChrisMaunder
committed
Issues with mutli-TPU
1 parent 4e5de76 commit 6d37984

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

src/modules/ObjectDetectionCoral/install.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,18 @@ elif [ "$os" = "macos" ]; then
189189
# move_recursive "${moduleDirPath}/edgetpu_runtime_temp/edgetpu_runtime" "${moduleDirPath}/edgetpu_runtime"
190190
# rm -rf "${moduleDirPath}/edgetpu_runtime_temp"
191191

192+
if [ "$full_speed" = true ]; then
193+
checkForAdminAndWarn "sudo bash install.sh max"
194+
else
195+
checkForAdminAndWarn "sudo bash install.sh throttle"
196+
fi
197+
192198
sudo chmod -R a+rwX "${moduleDirPath}/edgetpu_runtime"
193199
pushd "${moduleDirPath}/edgetpu_runtime" >/dev/null
194200
if [ "$full_speed" = true ]; then
195-
source "install.sh" "max"
201+
source "install.sh" "max" "install"
196202
else
197-
source "install.sh" "throttle"
203+
source "install.sh" "throttle" "install"
198204
fi
199205
set +e # Remove the -e set in install.sh because it kills our error handling ability
200206

src/modules/ObjectDetectionCoral/modulesettings.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"ObjectDetectionCoral": {
55
"Name": "Object Detection (Coral)",
6-
"Version": "2.0.0",
6+
"Version": "2.0.1",
77

88
// Publishing info
99
"Description": "The object detection module uses the Coral TPU to locate and classify the objects the models have been trained on.",
@@ -25,7 +25,8 @@
2525
"Queue": "objectdetection_queue", // We make all Object detectors use the same queue.
2626

2727
"EnvironmentVariables": {
28-
"CPAI_CORAL_MULTI_TPU": "true",
28+
"CPAI_CORAL_MULTI_TPU": "false",
29+
"CPAI_CORAL_USE_YOLO": "true", // Use the YOLO models rather than the efficientnet etc models
2930
"MODELS_DIR": "%CURRENT_MODULE_PATH%/assets",
3031
"MODEL_SIZE": "Small"
3132
},
@@ -57,9 +58,21 @@
5758
{ "ModuleVersion": "1.7.4", "ServerVersionRange": [ "2.4.2", "" ], "ReleaseDate": "2023-12-21", "ReleaseNotes": "Installer updates" },
5859
{ "ModuleVersion": "1.7.5", "ServerVersionRange": [ "2.4.2", "" ], "ReleaseDate": "2023-12-23", "ReleaseNotes": "Installer updates for Docker" },
5960
{ "ModuleVersion": "1.8.0", "ServerVersionRange": [ "2.5.0", "" ], "ReleaseDate": "2024-01-06", "ReleaseNotes": "Additions for dynamic explorer UI" },
60-
{ "ModuleVersion": "2.0.0", "ServerVersionRange": [ "2.5.0", "" ], "ReleaseDate": "2024-01-11", "ReleaseNotes": "Multi-TPU support" }
61+
{ "ModuleVersion": "2.0.0", "ServerVersionRange": [ "2.5.0", "" ], "ReleaseDate": "2024-01-11", "ReleaseNotes": "Multi-TPU support" },
62+
{ "ModuleVersion": "2.0.1", "ServerVersionRange": [ "2.5.0", "" ], "ReleaseDate": "2024-01-13", "ReleaseNotes": "Changes to SDK" }
6163
],
6264

65+
"Menus": [
66+
{
67+
"Label": "Model Size",
68+
"Options": [
69+
{ "Label": "Tiny", "Setting": "MODEL_SIZE", "Value": "tiny" },
70+
{ "Label": "Small", "Setting": "MODEL_SIZE", "Value": "small" },
71+
{ "Label": "Medium", "Setting": "MODEL_SIZE", "Value": "medium" },
72+
{ "Label": "Large", "Setting": "MODEL_SIZE", "Value": "large" }
73+
]
74+
}],
75+
6376
"RouteMaps": [
6477
{
6578
"Name": "Object Detector",

src/modules/ObjectDetectionCoral/objectdetection_coral_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def initialise(self) -> None:
4343
device = odcm.init_detect(opts)
4444
else:
4545
if self.enable_GPU:
46-
print("Using TPU")
46+
print("Using Edge TPU")
4747
else:
4848
print("Using CPU")
4949
import objectdetection_coral as odc

src/modules/ObjectDetectionCoral/options.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self):
2020
# https://coral.ai/models/object-detection/
2121
# https://github.com/MikeLud/CodeProject.AI-Custom-IPcam-Models/
2222
self.MODEL_SETTINGS = {
23-
"yolov5l": Settings(448, 'yolov5l-int8.tflite', # 49Mb # CPU model
23+
"yolov5_large": Settings(448, 'yolov5l-int8.tflite', # 49Mb # CPU model
2424
'yolov5l-int8_edgetpu.tflite', # TPU model
2525
'coco80_labels.txt', # labels
2626
['yolov5l-int8_segment_0_of_7_edgetpu.tflite', # TPU model segments
@@ -31,20 +31,20 @@ def __init__(self):
3131
'yolov5l-int8_segment_5_of_7_edgetpu.tflite',
3232
'yolov5l-int8_segment_6_of_7_edgetpu.tflite']),
3333

34-
"yolov5m": Settings(448, 'yolov5m-int8.tflite', # 22.7Mb
34+
"yolov5_medium": Settings(448, 'yolov5m-int8.tflite', # 22.7Mb
3535
'yolov5m-int8_edgetpu.tflite',
3636
'coco80_labels.txt',
3737
['yolov5m-int8_segment_0_of_4_edgetpu.tflite',
3838
'yolov5m-int8_segment_1_of_4_edgetpu.tflite',
3939
'yolov5m-int8_segment_2_of_4_edgetpu.tflite',
4040
'yolov5m-int8_segment_3_of_4_edgetpu.tflite']),
4141

42-
"yolov5s": Settings(448, 'yolov5s-int8.tflite', # 7.9Mb
42+
"yolov5_small": Settings(448, 'yolov5s-int8.tflite', # 7.9Mb
4343
'yolov5s-int8_edgetpu.tflite',
4444
'coco80_labels.txt',
4545
[]),
4646

47-
"yolov5n": Settings(448, 'yolov5n-int8.tflite', # 2.3Mb
47+
"yolov5_tiny": Settings(448, 'yolov5n-int8.tflite', # 2.3Mb
4848
'yolov5n-int8_edgetpu.tflite',
4949
'coco80_labels.txt',
5050
[]),
@@ -136,16 +136,31 @@ def __init__(self):
136136

137137
# Check input
138138
self.model_size = self.model_size.lower()
139+
140+
"""
141+
Let's simplify things here. The *_lo models are probably redundant, and
142+
so we can stick to tiny, small, medium, large if we split between YOLO
143+
and non-YOLO
144+
139145
if self.use_multi_tpu:
140146
model_valid = self.model_size in [ "yolov5l", "yolov5m", "yolov5s", "yolov5n", \
141147
"tiny", "small", "medium", "large", \
142148
"small_lo", "tiny_lo" ]
143149
else:
144150
model_valid = self.model_size in [ "tiny", "small", "medium", "large" ]
145-
151+
"""
152+
model_valid = self.model_size in [ "tiny", "small", "medium", "large" ]
146153
if not model_valid:
147154
self.model_size = "small"
148155

156+
self.use_YOLO = ModuleOptions.getEnvVariable("CPAI_CORAL_USE_YOLO", "false").lower() == "true"
157+
# if not self.use_multi_tpu: # Doesn't seem to work on non-multi-TPU code
158+
# self.use_YOLO = False
159+
self.use_YOLO = False # Doesn't seem to work at all for me :(
160+
161+
if self.use_YOLO:
162+
self.model_size = "yolov5_" + self.model_size
163+
149164
# Get settings
150165
settings = self.MODEL_SETTINGS[self.model_size]
151166
self.cpu_model_name = settings.cpu_model_name

src/setup.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ REM Installs a module in the 'moduleDirName' directory, and returns success
532532
REM Excluded?
533533
if /i "!item!" == "^!!platform!" (
534534
set can_install=false
535-
echo FOUND NEGATER
536535
goto :end_platform_loop
537536
)
538537

@@ -703,7 +702,7 @@ REM Installs a module in the 'moduleDirName' directory, and returns success
703702
REM !Runtime! "!moduleStartFilePath!" --selftest
704703

705704
set "exePath=.\"
706-
if /i "!executionEnvironment!" == "Development" set "exePath=.\bin\Debug\net7.0\"
705+
REM if /i "!executionEnvironment!" == "Development" set "exePath=.\bin\Debug\net7.0\"
707706

708707
if exist "!exePath!!moduleStartFilePath!" (
709708
set testRun=true

0 commit comments

Comments
 (0)