Blue Iris Long Delay with CodeProject Object Detection

curtis-r

n3wb
Dec 10, 2023
17
2
USA
Running Codeproject.AI Sever on Docker with YOLOv5.NET (but also tried YOLOv5 3.1).
Do NOT have AI using Main Stream. Applying to motion triggers only for all cams.

Codeproject responses typically take 400-1200ms (log attached) but you can see here, it detects A>B motion but AI doesn't identify a car for another 23 seconds!
BlueIris_9CheDjAlUF.jpg

I've also attached the .dat file (renamed to *.txt) if anyone wants to play with it, but here's a screenshot. I'm pretty new to BI, so not sure what in the .dat report I should be looking for.
BlueIris_dJ3mZtyB2z.jpg
 

Attachments

I assume you know you are running 5 custom models + default object detection for the above camera.
That's a lot models to run every time there is an event.
Your screenshot above shows that for every event, an image is sent to 6 models - 4 times; you can see how long each model takes.

You can speed things up and reduce your CP.AI load if you configure camera AI config to use ipcam-combined only (and turn off default object detection too).
 
Last edited:
Thanks! Well that explains my confusion on all those .dat entries, and might explain my slowdown, but I haven't specified any models, and the custom model area is grayed-out.

17-03-2024_18-18-33.jpg 17-03-2024_18-18-50.jpg
 
That is correct for the greyed out area - it pulls that directly from the CodeProject Custom Models folder with whatever models are in that folder.

So if you don't tell it not to use a model, it will use them all and thus the long times.

Go into the custom models and delete the models you don't plan to use at all, and then in each camera, you need to put in :0 to turn off the models you don't want.

Adding objects:0 disables the Default Object Detection.

From the help file:


1710431356216.png
 
Thanks! Well that explains my confusion on all those .dat entries, and might explain my slowdown, but I haven't specified any models, and the custom model area is grayed-out.

View attachment 189689 View attachment 189690
On the global AI settings, turn off the default detection because the default model has too many unnecessary objects. That will get of one unnecessary model check.

On your camera, it seems you only want people and vehicles. One option is to use the ipcam-general custom model which has two objects (vehicle and person). In the custom model field for the camera, type 'ipcam-general'. That will only run that one model cutting out the others. For the objects you want to detect, just type 'person,vehicle' and type 'vehicle' into the detect as vehicle field.
 
Yeah, I just found the Docker custom-models director, and indeed all five it's been trying to use are there. Instead of deleting them, I wonder if specifying in each camera like this will work. BTW, thanks!
BlueIris_model.jpg
 
Yeah, I just found the Docker custom-models director, and indeed all five it's been trying to use are there. Instead of deleting them, I wonder if specifying in each camera like this will work. BTW, thanks!
View attachment 189693
Check out the GitHub for the custom ipcam models. GitHub - MikeLud/CodeProject.AI-Custom-IPcam-Models

You need to know the specific name of the model you want to use. There isn't an ipcam-objects model. And the dark images have been incorporated in a few others, so you probably don't need it to be separate. The objects you pick must be from the model you pick.
 
So far a huge speed improvement. About 5 seconds for AI to process a trigger when it was well over 20 before. I removed the models I'm not interested in.

chrome_HiQTqFYqC5.jpg

But with ipcam-general AI, why all the red-circle 'X's when it returned >90% chance of being a vehicle? Objects clearly works...

chrome_WNlbsm5xf5.jpg
 
So far a huge speed improvement. About 5 seconds for AI to process a trigger when it was well over 20 before. I removed the models I'm not interested in.

View attachment 189764

But with ipcam-general AI, why all the red-circle 'X's when it returned >90% chance of being a vehicle? Objects clearly works...

View attachment 189765
First, you still have the default 'Objects' model enabled so that is running concurrently. I'd go to the global AI settings and turn that off.

As for the question about ipcam-general, it only detects two objects: 'vehicle' and 'person' but you are telling it to look for 'car', 'motorcycle', etc. which aren't labels it knows about.

Reread my post about how to find out what labels are supported in the custom models. In particular, you want 'to confirm' if the custom model sees "vehicle,person". Then for 'mark as vehicle' the only label that relates to a vehicle is "vehicle" so that's what you want in the 'mark as vehicle' field.
 
  • Like
Reactions: curtis-r
So, much improved with everyone's help. If you see the AI data and the Log, it's <5 sec from motion for AI to confirm a vehicle. But why is it another 8 seconds before the MQTT fires? It is the first item for Alert Actions.

Also, why in the global AI in the (grayed-out) custom models, I can see 'animalipcam' which I don't have installed? I only have ipcam-general in the folder. I realize the AI is currently only processing 'general' as it should, but just curious.

BlueIris_i8ZQ1i7vN9.jpg
BlueIris_BncWgje8vI.jpgBlueIris_a3uvg5nfIT.jpgBlueIris_LbH8yUAegK.jpg
 
@curtis-r Yeah, it's puzzling. MQTT 8 secs after AI confirm seems too long.

I checked my situation. From AI confirm to MQTT, it's 50-100ms.

In your cam "On alert" config screen, do you have anything running before MQTT?

performance.pngperformance.png
 
Last edited:
On one hand, I'm thrilled at the possibility that I could get an MQTT a second or so after motion. I just need to get there! Anyhow, the MQTT is first in line. I'm going to change Required to "vehicle" only and see what happens.
BlueIris_x6Pv1WOatD.jpg
 
Changing the MQTT to "vehicle" didn't help. Only 2 seconds for the AI to process, but another 12 for MQTT. Damn.

BlueIris_vqvALtSm1T.jpg
BlueIris_3iR41c5mMy.jpg
 
Last edited:
I also have another cam with an MQTT alert with similar lag. Disabling other Actions didn't help. Still large delays before the MQTT's fire. Weird.

BlueIris_YijXWRLPI6.jpg]
BlueIris_k15mBKHFjx.jpg
BlueIris_UKgnC0Ejtl.jpg
 
  • Sad
Reactions: actran
@curtis-r I do not know if your PC has old-generation CPU, is the CPU pegged at near 100% during AI confirm?

If it's not slow PC hardware, you may want to send an email to BI support to ask what else might cause the delay between AI confirm and MQTT.
 
  • Like
Reactions: curtis-r
CodeProject is on another box running Docker, and I think it's CPU load is reasonable.
The PC running BI is AMD Ryzen 7 5700G, 16GB RAM. Can't imagine the hardware is causing the MQTT delay.

The two cam's with the MQTT alerts are both duplicate cam's and I just realized on the primary cameras (which don't have any Alerts btw) I didn't specify Custom Models in AI and they are trying a bunch of models. First, not sure if that's slowing it down, so I just put in Custom Models "ipcam-general" for those 2 cams. But secondly, why are those cams even trying models I don't have installed anymore? I moved from the ObjectDetectionYOLOv5-3.1\custom-models everything but ipcam-general.pt.

BlueIris_hOCZAcUdsw.jpg
 
Specifying custom-models on the primary cameras did not help. Still taking 10-18 seconds after AI to MQTT. At least I'm down to 2 seconds for the AI process.

EDIT: I'm going to try disabling the 8 other cameras that I'm not using MQTT on to see if it's a CPU thing.
 
Turning off a bunch of cameras had zero impact. MQTT took 12 seconds after AI was done.
CPU with only 3 cams active: 2%. CPU with all cameras active: 4-8%.
Support @ BI wanted my .dat file, so we'll see what they have to say.