Skip to content

Commit

Permalink
v2.5: Dynamic explorer UI, multi-TPU Coral, Jetson, Windows on Arm
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMaunder committed Jan 13, 2024
1 parent 51984c1 commit 78e24c3
Show file tree
Hide file tree
Showing 195 changed files with 8,949 additions and 3,667 deletions.
28 changes: 15 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@
},
"name": "Object Detect Coral",
"type": "python",
"python": "${workspaceFolder}/src/modules/ObjectDetectionCoral/bin/linux/python39/venv/bin/python",
"python": "${workspaceFolder}/src/modules/ObjectDetectionCoral/bin/windows/python39/venv/Scripts/python.exe",
"request": "launch",
"program": "objectdetection_coral_adapter.py",
// "args": [ "--selftest" ],
"args": [ "--selftest" ],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/modules/ObjectDetectionCoral",
"justMyCode": false,
Expand All @@ -456,7 +456,7 @@
"CPAI_MODULE_QUEUENAME": "objectdetection_queue"
},
"windows": {
"python": "${workspaceFolder}/src/modules/ObjectDetectionCoral/bin/windows/python37/venv/Scripts/python.exe",
"python": "${workspaceFolder}/src/modules/ObjectDetectionCoral/bin/windows/python39/venv/Scripts/python.exe",
},
"linux": {
"python": "${workspaceFolder}/src/modules/ObjectDetectionCoral/bin/linux/python39/venv/bin/python",
Expand Down Expand Up @@ -565,7 +565,7 @@
},
"name": "Object Detect YOLOv5 3.1 Jetson",
"type": "python",
"python": "${workspaceFolder}/src/modules/ObjectDetectionYOLOv5-3.1/bin/linux/python36/venv/bin/python",
"python": "${workspaceFolder}/src/modules/ObjectDetectionYOLOv5-3.1/bin/linux/python38/venv/bin/python",
"request": "launch",
"program": "detect_adapter.py",
// "args": [ "--selftest" ],
Expand Down Expand Up @@ -736,7 +736,7 @@
},
"name": "Sound Classifier",
"type": "python",
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/linux/python39/venv/bin/python3.8",
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/linux/python39/venv/bin/python3",
"request": "launch",
"program": "sound_classification_adapter.py",
// "args": [ "--selftest" ],
Expand All @@ -746,16 +746,17 @@
"env": {
"DEBUG_IN_VSCODE": "True",
"RUNNING_IN_VSCODE": "True",
"CPAI_PORT": "32168"
"CPAI_PORT": "32168",
"MODELS_DIR": "${workspaceFolder}/src/modules/SoundClassifierTF/assets"
},
"windows": {
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/windows/python39/venv/Scripts/python",
},
"linux": {
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/linux/python39/venv/bin/python3.8",
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/linux/python38/venv/bin/python3",
},
"osx": {
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/macos/python39/venv/bin/python",
"python": "${workspaceFolder}/src/modules/SoundClassifierTF/bin/macos/python38/venv/bin/python",
}
},

Expand Down Expand Up @@ -833,7 +834,7 @@
"RUNNING_IN_VSCODE": "True",
"CPAI_PORT": "32168",

"NLTK_DATA": "/app/modules/TextSummary/nltk_data"
"NLTK_DATA": "${workspaceFolder}/src/modules/TextSummary/nltk_data"
},
"windows": {
"python": "${workspaceFolder}/src/modules/TextSummary/bin/windows/python37/venv/Scripts/python.exe"
Expand Down Expand Up @@ -868,16 +869,17 @@
"YOLOv5_AUTOINSTALL": "false",
"YOLOv5_VERBOSE": "false",

"CPAI_MODULE_REQUIRED_MB": "7000",
"CPAI_MODULE_REQUIRED_MB": "1000",

"YOLO_DATASETS_DIRNAME": "datasets",
"YOLO_TRAINING_DIRNAME": "training",
"YOLO_TRAINING_DIRNAME": "train", // compatible with tutorials and default
"YOLO_WEIGHTS_DIRNAME": "weights",
"YOLO_MODELS_DIRNAME": "assets",
"YOLO_DATASET_ZOO_DIRNAME": "zoo"
"YOLO_DATASET_ZOO_DIRNAME": "zoo",
"FIFTYONE_DATABASE_DIRNAME": "fiftyone"
},
"windows": {
"python": "${workspaceFolder}/src/modules/TrainingObjectDetectionYOLOv5/bin/windows/python39/venv/Scripts/python.exe"
"python": "${workspaceFolder}/src/modules/TrainingObjectDetectionYOLOv5/bin/windows/python37/venv/Scripts/python.exe"
},
"linux": {
"python": "${workspaceFolder}/src/modules/TrainingObjectDetectionYOLOv5/bin/linux/python38/venv/bin/python",
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"csharp.debug.logging.moduleLoad": false,
// "dotnet.server.trace":"Trace",

"cSpell.words": [
"alpr",
"APPDIR",
Expand All @@ -24,6 +27,7 @@
"deskew",
"Dgram",
"downloadables",
"downsampling",
"dtype",
"edgetpu",
"endtimer",
Expand All @@ -46,6 +50,8 @@
"intelligencelayer",
"Jetson",
"keypair",
"labelledby",
"Lanczos",
"licence",
"logvals",
"memused",
Expand All @@ -62,6 +68,7 @@
"orangepi",
"otsu",
"paddleocr",
"peasy",
"platenumber",
"pluralise",
"postinst",
Expand Down Expand Up @@ -103,6 +110,7 @@
"wavfile",
"wslconfig",
"wwwroot",
"xlink",
"YOLO",
"yolov5"
]
Expand Down
1 change: 1 addition & 0 deletions CodeProject.AI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A8B76501-496A-4011-9C37-8308A1EBDFA7}"
ProjectSection(SolutionItems) = preProject
src\create_packages.bat = src\create_packages.bat
src\create_packages.sh = src\create_packages.sh
src\setup.bat = src\setup.bat
src\setup.sh = src\setup.sh
EndProjectSection
Expand Down
12 changes: 6 additions & 6 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,24 +564,24 @@ for which you have or can give appropriate copyright permission.
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

a) Disclaiming warranty or limiting liability differently from the
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or

b) Requiring preservation of specified reasonable legal notices or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or

c) Prohibiting misrepresentation of the origin of that material, or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or

d) Limiting the use for publicity purposes of names of licensors or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or

e) Declining to grant rights under trademark law for use of some
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or

f) Requiring indemnification of licensors and authors of that
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
Expand Down
Binary file added demos/TestData/Sounds/klaxon.wav
Binary file not shown.
67 changes: 35 additions & 32 deletions demos/dotNet/CodeProject.AI.Explorer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ private void ImageSelect_Click(object sender, EventArgs e)
bool enable = !string.IsNullOrWhiteSpace(_imageFileName);
DetectFaceBtn.Enabled = DetectSceneBtn.Enabled = DetectObjectsBtn.Enabled = enable;
}

private void ImageFileName_TextChanged(object sender, EventArgs e)
{
_imageFileName = ImageFileName.Text;

bool enable = !string.IsNullOrWhiteSpace(_imageFileName);
DetectFaceBtn.Enabled = DetectSceneBtn.Enabled = DetectObjectsBtn.Enabled = enable;
}

private void FaceImage1Select_Click(object sender, EventArgs e)
{
CompareFacesBtn.Enabled = false;
Expand Down Expand Up @@ -176,16 +178,16 @@ private async void DetectFaceBtn_Click(object sender, EventArgs e)

List<string> lines = new();

if (detectedFaces.predictions is not null)
if (detectedFaces.Predictions is not null)
{
foreach (var (face, index) in detectedFaces.predictions
foreach (var (face, index) in detectedFaces.Predictions
.Select((face, index) => (face, index)))
{
lines.Add($"{index}: Confidence: {Math.Round(face.confidence, 3)}");
lines.Add($"{index}: Confidence: {Math.Round(face.Confidence*100.0, 2)}");

var rect = Rectangle.FromLTRB(face.x_min, face.y_min, face.x_max, face.y_max);
var rect = Rectangle.FromLTRB(face.X_min, face.Y_min, face.X_max, face.Y_max);
canvas.DrawRectangle(_boundingBoxPen, rect);
canvas.DrawString(index.ToString(), _textFont, _textBrush, face.x_min, face.y_min);
canvas.DrawString(index.ToString(), _textFont, _textBrush, face.X_min, face.Y_min);
}

detectionResult.Lines = lines.ToArray();
Expand Down Expand Up @@ -219,7 +221,7 @@ private async void CompareFacesBtn_Click(object sender, EventArgs e)
var result = await _serverClient.MatchFaces(_faceImageFileName1, _faceImageFileName2);
if (result is MatchFacesResponse matchedFaces)
{
detectionResult.Text = $"Similarity: {Math.Round(matchedFaces.similarity, 4)}";
detectionResult.Text = $"Similarity: {Math.Round(matchedFaces.Similarity, 4)}";
SetStatus("Face Comparison complete");
}
else
Expand All @@ -245,7 +247,7 @@ private async void DetectSceneBtn_Click(object sender, EventArgs e)
var image = GetImage(_imageFileName);
pictureBox1.Image = image;

detectionResult.Text = $"Confidence: {Math.Round(detectedScene.confidence, 3)} Label: {detectedScene.label}";
detectionResult.Text = $"Confidence: {Math.Round(detectedScene.Confidence*100.0, 2)} Label: {detectedScene.Label}";
SetStatus("Scene Detection complete");
}
else
Expand Down Expand Up @@ -275,14 +277,14 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
try
{
lines.Add(stopwatch.Elapsed.ToString());
if (detectedObjects.predictions is not null)
foreach (var (detectedObj, index) in detectedObjects.predictions
if (detectedObjects.Predictions is not null)
foreach (var (detectedObj, index) in detectedObjects.Predictions
.Select((detected, index) => (detected, index)))
{
lines.Add($"{index}: Conf: {Math.Round(detectedObj.confidence, 3)} {detectedObj.label}");
lines.Add($"{index}: Conf: {Math.Round(detectedObj.Confidence*100.0, 2)} {detectedObj.Label}");

var rect = Rectangle.FromLTRB(detectedObj.x_min, detectedObj.y_min,
detectedObj.x_max, detectedObj.y_max);
var rect = Rectangle.FromLTRB(detectedObj.X_min, detectedObj.Y_min,
detectedObj.X_max, detectedObj.Y_max);
}

detectionResult.Lines = lines.ToArray();
Expand All @@ -296,16 +298,16 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)

Graphics canvas = Graphics.FromImage(image);

if (detectedObjects.predictions is not null)
if (detectedObjects.Predictions is not null)
{
foreach (var (detectedObj, index) in detectedObjects.predictions
foreach (var (detectedObj, index) in detectedObjects.Predictions
.Select((detected, index) => (detected, index)))
{
var rect = Rectangle.FromLTRB(detectedObj.x_min, detectedObj.y_min,
detectedObj.x_max, detectedObj.y_max);
var rect = Rectangle.FromLTRB(detectedObj.X_min, detectedObj.Y_min,
detectedObj.X_max, detectedObj.Y_max);
canvas.DrawRectangle(_boundingBoxPen, rect);
canvas.DrawString($"{index}:{detectedObj.label}", _textFont, _textBrush,
detectedObj.x_min, detectedObj.y_min);
canvas.DrawString($"{index}:{detectedObj.Label}", _textFont, _textBrush,
detectedObj.X_min, detectedObj.Y_min);
}
}

Expand All @@ -314,7 +316,7 @@ private async void DetectObjectsBtn_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
ProcessError(new ErrorResponse (ex.Message));
ProcessError(new ServerErrorResponse (ex.Message));
detectionResult.Lines = lines.ToArray();
}
}
Expand All @@ -328,6 +330,7 @@ private void OnUserIdTextboxChanged(object sender, EventArgs e)
{
DeleteFaceBtn.Enabled = !string.IsNullOrWhiteSpace(UserIdTextbox.Text);
}

private async void RegisterFaceBtn_Click(object sender, EventArgs e)
{
ClearResults();
Expand Down Expand Up @@ -376,18 +379,18 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
Graphics canvas = Graphics.FromImage(image);

List<string> lines = new();
if (recognizeFace.predictions is not null)
if (recognizeFace.Predictions is not null)
{
var predictionMap = recognizeFace.predictions
var predictionMap = recognizeFace.Predictions
.Select((prediction, Index) => (prediction, Index));
foreach (var (prediction, index) in predictionMap)
{
lines.Add($"{index}: Conf: {Math.Round(prediction.confidence, 3)} {prediction.userid}");
var rect = Rectangle.FromLTRB(prediction.x_min, prediction.y_min,
prediction.x_max, prediction.y_max);
lines.Add($"{index}: Conf: {Math.Round(prediction.Confidence*100.0, 2)} {prediction.Userid}");
var rect = Rectangle.FromLTRB(prediction.X_min, prediction.Y_min,
prediction.X_max, prediction.Y_max);
canvas.DrawRectangle(_boundingBoxPen, rect);
canvas.DrawString($"{index}:{prediction.userid}", _textFont, _textBrush,
prediction.x_min, prediction.y_min);
canvas.DrawString($"{index}:{prediction.Userid}", _textFont, _textBrush,
prediction.X_min, prediction.Y_min);
}

detectionResult.Lines = lines.ToArray();
Expand All @@ -398,7 +401,7 @@ private async void RecognizeFaceBtn_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
ProcessError(new ErrorResponse($"{filename} caused: {ex.Message}"));
ProcessError(new ServerErrorResponse($"{filename} caused: {ex.Message}"));
}
}
else
Expand All @@ -410,15 +413,15 @@ private async void ListFacesBtn_Click(object sender, EventArgs e)
ClearResults();
SetStatus("Listing known faces");

var result = await _serverClient.ListRegisteredFaces() as ModuleResponseBase;
var result = await _serverClient.ListRegisteredFaces();
if (result is ListRegisteredFacesResponse registeredFaces)
{
if (result?.Success ?? false)
{
List<string> lines = new();
if (registeredFaces.faces != null)
if (registeredFaces.Faces != null)
{
var faceMap = registeredFaces.faces.Select((face, Index) => (face, Index));
var faceMap = registeredFaces.Faces.Select((face, Index) => (face, Index));
foreach (var (face, index) in faceMap)
{
lines.Add($"{index}: {face}");
Expand Down Expand Up @@ -455,7 +458,7 @@ private async void DeleteFaceBtn_Click(object sender, EventArgs e)
ClearResults();
SetStatus("Deleting registered face");

var result = await _serverClient.DeleteRegisteredFace(UserIdTextbox.Text) as ModuleResponseBase;
var result = await _serverClient.DeleteRegisteredFace(UserIdTextbox.Text);
if (result?.Success ?? false)
SetStatus("Completed Face deletion");
else
Expand Down Expand Up @@ -545,7 +548,7 @@ private void ProcessError(ServerResponse? result)
pictureBox1.Image = null;
detectionResult.Text = string.Empty;

if (result is ErrorResponse response)
if (result is ServerErrorResponse response)
ShowError($"Error: {response.Code} - {response.Error ?? "No Error Message"}");
else if (result is null)
ShowError("Null result");
Expand Down

0 comments on commit 78e24c3

Please sign in to comment.