Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Deepstack Models #416

Closed
ghzgod opened this issue Jan 18, 2021 · 12 comments · Fixed by #417
Closed

Custom Deepstack Models #416

ghzgod opened this issue Jan 18, 2021 · 12 comments · Fixed by #417
Assignees
Labels
enhancement New feature or request

Comments

@ghzgod
Copy link

ghzgod commented Jan 18, 2021

Describe the solution you'd like
I have created a few custom deepstack models using this tutorial Deepstack Custom Models. I can then ask Deepstack to analyze an image via the custom model link EG: http://10.0.0.X:5000/v1/vision/custom/my_custom_model_name?image which will reply with the confidence of the detected object.

A good example of this would be not only detecting that a car is in the driveway, but who's car is in the driveway? Mine? My friend? etc.

I've been able to save triggered images from node-deepstack-ai by setting the purgeInterval to 0 (thanks for adding that) and then using those images I've collected overtime, to label and train.

So logically...I can see this as follows:

  1. My driveway has motion, image stores to aiinput folder
  2. Node-deepstack AI sends it to default deepstackUri for analysis.
  3. Another trigger config in triggers.json sends that same image to my custom deepstack model link for analysis.
  4. From there, I can take actions via MQTT.

Maybe allowing a deepstackUri override in triggers.json? And ignoring things like watchObjects as the only objects that will be detected are

  1. A car I know or
  2. Not a car I know

aka (A hot dog/not a hot dog 😄 ).

I am sure this is more complex but just an idea. I can't imagine if many people use custom models or not. Thank you in advance.

@neilenns
Copy link
Owner

Thank you for the suggestion, I have a build for you to try.

Change your docker-compose so instead of using latest it uses issue416. Then in your triggers.json add a customEndpoint property that points to the path for your custom model on each trigger that needs it:

"customEndpoint": "/v1/vision/custom/my_custom_model_name?image"

You still need to specify at least one watchObject but the code will ignore it.

I don't really have any way to test this so let me know if it works. If it does I'll figure out how to make the JSON schema not require watchObjects when customEndpoint is specified.

@neilenns neilenns self-assigned this Jan 18, 2021
@neilenns neilenns added the enhancement New feature or request label Jan 18, 2021
@ghzgod
Copy link
Author

ghzgod commented Jan 18, 2021

This is working beautifully and I am thankful because my node-red flow was more complex than it needed to be.

My mqtt alert shows the custom trained objects and their predicted values. Perfect! Thank you so much.

If you ever wanted to test this on your own, here is a custom license plate detector model if you have a camera facing a street with car traffic.

@neilenns
Copy link
Owner

neilenns commented Jan 18, 2021 via email

@ghzgod
Copy link
Author

ghzgod commented Jan 18, 2021

Sure, is this what you're looking for?

{
"analysisDurationMs": 4082,
"basename": "drivewayhd.20210118_195848070.jpg",
"fileName": "/aiinput/drivewayhd.20210118_195848070.jpg",
"formattedPredictions": "Toyota (60%), Nissan (67%)",
"name": "Driveway Custom",
"predictions": [
{
"confidence": 0.60056514,
"label": "Toyota",
"y_min": 26,
"x_min": 854,
"y_max": 1202,
"x_max": 1949
},
{
"confidence": 0.6700693,
"label": "Nissan",
"y_min": 78,
"x_min": 16,
"y_max": 1236,
"x_max": 630
}
],
"state": "on"
}

@neilenns
Copy link
Owner

Yep. That's super cool! I think I got the schema figured out, will have a pre-release build for you to try shortly.

@neilenns
Copy link
Owner

Ok this is now published under the dev image tag. Would you mind updating your config to that and verifying it still works? Also please also try various combinations of watchObjects and customEndpoint: it should complain if you specify both, complain if neither are specified, etc.

@ghzgod
Copy link
Author

ghzgod commented Jan 18, 2021

When you say "it should complain if you specify both" I thought earlier you mentioned that I had to have a value in there (watchObjects). Has that changed since issue416 image?

@neilenns
Copy link
Owner

Yes, I figured out how to enforce one or the other but not both via the JSON schema.

@ghzgod
Copy link
Author

ghzgod commented Jan 18, 2021

dev tag is working.

As far as triggers.json :

It does not complain if I have both watchObjects and customEndpoint set.

It does not complain if I have only customEndpoint and no watchObjects set.

It does not complain if I have only watchObjects and no customEndpoint set.

It does not complain if I have neither customEndpoint / watchObjects set.

The logs for all 4 of these conditions in triggers.json showed the image being analyzed. The only one that did not return results was when both customEndpoint watchObjects were unset which makes sense.

@neilenns
Copy link
Owner

Hmm. Ok, thanks. I'll have to do a bit more digging!

@neilenns
Copy link
Owner

neilenns commented Jan 19, 2021 via email

@ghzgod
Copy link
Author

ghzgod commented Jan 19, 2021

Haha the wonderful world of coding. Trust me, I know how you feel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants