Didn't detect the cat

:smile:

I’ve finally gotten my BI/Deepstack/AI Tool combo running decent, and not alerting too often, and mostly alerting on stuff that matters. It’s been fairly stable / reliable the last week, so yesterday I decided (in AI Tool) to try detecting Dogs and Cats.

This morning, I saw a cat…but, it wasn’t detected or alerted on.

I don’t know if this is a BI, an AI Tool, or a Deepstack issue, but I do know there were pics sent to Deepstack for processing, and Mr. Cat wasn’t detected.

So, @john, here’s a link to a OneDrive folder with all the detected photos and even a video clip showing Mr. Cat wandering around (I have my SD cam recording 24x7). https://1drv.ms/u/s!AgRu8KsUhmARkg3FO8wd9dGgsqrx?e=qznN67

Can you postulate on a)why Mr. Cat wasn’t detected, and b)what I could do to enhance that detection?

This is mostly for “fun”, as we don’t really have an “animal problem” in our yard. I just thought I’d experiment with some other detections, and am now curious if I’m doing something wrong.

Edit: Oh, DeepStack is running on a VM in a docker container; I use this to start it:

docker run --restart always -d -e VISION-DETECTION=True -e MODE=Low -v localstorage:/datastore -p 80:5000 --name deepstack deepquestai/deepstack:cpu-x6-beta

Thanks!

1 Like

@wilddoktor there are many factors which may affect why an object is not detected, or detected with a low confidence. I notice you set MODE=Low and suggest you try MODE=High
With High setting I quickly put one of your images through the Deepstack-ui and think we have identified an issue - cats and dogs are easily confused by the AI…

[
0:{
"confidence":0.60416687
"label":"dog"
"y_min":740
"x_min":1108
"y_max":900
"x_max":1292
}
]

However in another image it is detecting cat:

[
0:{
"confidence":0.533543
"label":"cat"
"y_min":457
"x_min":1464
"y_max":559
"x_max":1597
}
]
1 Like

I would suggest cropping the frame to reasonable area - say 2 or 3 slabs and the grit on the right as
you don’t really need to run the detection over the street, bushes or walls. You could actually cut the area in 3-4 squares and feed them to deepstack one after another in a loop.

Cat
In the above crop, deepstack discovers cat with 95% confidence.

Hope that helps.

1 Like

@sickidolderivative this is a good suggestion, and this ‘tiling’ (or ‘slabs’) approach is commonly taken by people with large images (e.g. satellite imagery) so as to take advantage of the full resolution of the image. The only edge case to consider is what happens if the cat happens to be on 2 tiles at the same time, in which case it is cut in half.

1 Like

Thanks to both of you for your responses!

@robmarkcole, I run in mode=low because in that mode the average detection rate is between 350 and 600ms. In high, I average well over a second. (Since I’m mainly interested in knowing ASAP when a person approaches the front of our house (or when a hoodlum walks in from the side yard to burn our American Flag at 11pm when we’re all asleep), I thought having a shorter detection time might be better. But…I have no clue if that logic is sound and am willing to be taught! :smiley: )

@sickidolderivative, that’s a cool concept, but I’ve no idea how to implement it? Do you have a link to a post somewhere that explains it? I’d love to give it a try! Again, i’m willing to be taught!

@wilddoktor there is a tradeoff between speed and accuracy. In your case it sounds like you need both so I suggest you also need to instance of Deepstack running - one low and one high accuracy

@wilddoktor, this is very simple. Conceptually, you’d be doing something along the lines:

#!/usr/bin/python3

import itertools, enum
import numpy as np
import cv2

class Areas(enum.Enum):
    Area_1 = 1
    Area_2 = 2
    Area_3 = 3

# iterate infinitly over areas
for area in itertools.cycle(Areas):

    # read new frame from cv2.VideoCapture
    ret, new_frame = cap.read()

    # create distinct slice for each area
    if area == Areas.Area_1:
        slice = new_frame[y_min_1: y_max_1, x_min_1: x_max_1]
    elif area == Areas.Area_2:
        slice = new_frame[y_min_2: y_max_2, x_min_2: x_max_2]
    else:
        slice = new_frame[y_min_3: y_max_3, x_min_3: x_max_3]

    # pass slice to deepstack for processing
    deepstack.process(slice)
1 Like

You could perhaps overlap the slices to some extend to account for the edge case.

My cat often gets detected as a bird for some odd reason!

1 Like