Using Python SDK | DeepStack v1.2.1 documentation

Hi new to all this,
Aim to get my agent dvr ip camera to “alert/ sound” unknown faces
All working with no AI being used.
Now I have installed everything in the following doc
I have deepstack running.
And py loaded, tried to get the py paste commands to work in the above doc .


PS C:\Users\roy> py
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.


Python SDK | DeepStack v1.2.1 documentation
And just trying to use the first py paste in my admin power shell
from deepstack_sdk import ServerConfig, Detection

config = ServerConfig(“http://localhost:80”)
detection = Detection(config)

response = detection.detectObject(“image.jpg”,output=“image_output.jpg”)

for obj in response:
print(“Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}”.format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max, obj.y_max))

I do not understand how my images are seen by the above paste command, there is no mention of amending the above to work on my windows pc.
do i need to alter all the red section ?

what do I need to amend in this “doc paste” so it will work in my admin powershell window
there is no help in the doc as to what I need to enter,
please can you help ?
after pasting above i get below


Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\WINDOWS\system32> py
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

from deepstack_sdk import ServerConfig, Detection

config = ServerConfig(“http://localhost:80”)
detection = Detection(config)

response = detection.detectObject(“image.jpg”,output=“image_output.jpg”)
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\roy\AppData\Local\Programs\Python\Python39\lib\site-packages\deepstack_sdk\detection.py”, line 38, in detectObject
raise Exception(“file {} does not exist”.format(image))
Exception: file image.jpg does not exist

for obj in response:
… print(“Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}”.format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max, obj.y_max))

Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘response’ is not defined


all so keep getting flag provided but not defined: -port
+++++++++++++++++++++++++++++++++++++++++++++++++
DeepStack: Version 2021.02.1
flag provided but not defined: -port
Usage of C:\DeepStack\server\deepstack.exe:
-ADMIN-KEY string
admin key to secure admin endpoints
-API-KEY string
api key to secure endpoints
-MODE string
performance mode (default “Medium”)
-MODELSTORE-DETECTION string
path to custom detection models (default “/modelstore/detection/”)
-PORT int
port (default 5000)
-TIMEOUT float
request timeout in seconds (default 60)
-VISION-DETECTION string
enable object detection
-VISION-FACE string
enable face detection
-VISION-SCENE string
enable scene recognition
above in powershell window
++++++++++++++++++++++++++++++++++++++++
image
task manger showing deepstack running
+++++++++++++++++++++++++++++++++++++++
power script being used


++++++++++++++++++++++++++++++++++++++++
regards roy

no idea, a dvr setup might be difficult? but i would try…

capitalized --PORT 80
remove --vision-detection=true and remove --vision-scene=true api’s, (if you are just doing face recognition).
i haven’t done face, but you’ll need to train your faces somehow. check documention on this
your code above looks like the ‘object detection’ code, not sure if you can use the same for face. but yes, you’ll need to adjust according to your setup. (like what is the name of the images being sent to and from deepstack, etc. such as this line:
response = detection.detectObject(“image.jpg”,output=“image_output.jpg”)

you can download postman and send images to deepstack to test the setup.

thank you for the advice, getting there slowly, cheers
hi just put cap --PORT 80 and got below looooooking good , thank you very much
why does there have to be only caps for some items, and other work upper and lower
GGRR, big learning skill this scripting.

PS D:\BATCHFILES\workingscript> D:\BATCHFILES\workingscript\POWERSHELLSCRIPTS 2.ps1
DeepStack: Version 2021.02.1
/v1/vision/face

/v1/vision/face/recognize

/v1/vision/face/register

/v1/vision/face/match

/v1/vision/face/list

/v1/vision/face/delete

/v1/vision/detection

/v1/vision/scene


v1/backup

v1/restore

Waiting for 2 seconds, press a key to continue …10
finished
Press Enter to continue…:

lol, no idea. I find the most important part is juicing as much info as you can from the error messages. they usually tell you everything, but it’s not obvious, until (after many many looks) it’s obvious.

let us know how the rest goes, or if you get stuck

hi just doing objects at the moment, and have pasted python pastes into powershell editor, and loads of errors happen, all sorts .
example


deep stack is running power, window with deep stack command open

i have all the pictures in the folders as per doc i am following

Python SDK | DeepStack v1.2.1 documentation
i have copied from powershell into a new admin power shell window and pasted in
no joy, have had the object picture up once but thats it,
task manger shows three deepstack programs running
any ideas would be a help
roy

fix the errors-

reading the errors it says…
missing ‘)’, missing parameter, doesnt like the ‘:’, response line has a single ‘/’ amongst mostly doubles…
did something go wrong with the formatting when you pasted? doesn’t look like the example code…

i have used this python code successfully for a custom model, maybe it will help?

import requests

import os

import PIL


# Importing Image class from PIL module

from PIL import Image


input_directory = 'J:\\BlueIris\\LPR_Alerts'                          #where BlueIris saves jpg from motion trigger

output_directory = 'J:\\BlueIris\\Deepstack_LPR_dataset\\results'    #where python will save the cropped plates


#cleanup variables before run, just in case

left = 0

top = 0

right = 0

bottom = 0

label = 0

confidence = 0.0


#goes through entire directory and processes each file

for filename in os.listdir('J:\\BlueIris\\LPR_Alerts'):

 

    filepath = os.path.join(input_directory, filename)

 

    image_data = open(filepath,"rb").read()


    #posts to deepstack custom server and logs result

    response = requests.post("[URL unfurl="true"]http://localhost:80/v1/vision/custom/best[/URL]",files={"image":image_data}).json()     #change port 80 to whatever your deepstack custom server is on


    #log result for debugging

    for detection in response["predictions"]:

        label = detection["label"]

        confidence = detection["confidence"]

      

        print(label)

 

    print(response)

thank you for that, found running windows ise power shell, from example doc, does not like it, just, done another guide, got pictures, face recog, and cropped, face, so things are looking up, now i have found correct format to get from my pc to the scripts, found the \ should use \ , or use r’ in quotes , r for raw,
done a guide into notepad for alterations, and past into open py window things are good, now, thank for your help
caps --PORT 80 was great,
why cannot guides stipulate upper or lower case to be used on certain words , had "image " and “imageDraw”, did not work found , it should have been " image " and ImageDraw , cap I , madness this scripting.
roy

hi just found this in py, in windows power shell.
image

caps import cause’s syntax error on wrong item, mis led me for ages that did,

roy