/DeepStackPython

Official Python SDK for DeepStack

Primary LanguagePythonMIT LicenseMIT

DeepStackPython

Official Python SDK for DeepStack

DevTest

DeepStack

(DeepStack)[https://deepstack.cc] is an AI server that allows deploying object detection, face detection, face recognition, image enhance, scene recognition and detection of custom objects on the edge and in production servers. DeepStack Runs on Docker, Windows, Linux, Mac and Nvidia Jetson devices. And it is entirely free and Open Source

The DeepStack Python SDK makes it easy to perform all of the above awesome AI magic on Images and Videos in few lines of code, Just Install DeepStack and the Python SDK and you are good to go!

Installation Instructions

Install DeepStack on Windows

You can install DeepStack via docker on windows, note that this does not support GPU acceleration

docker pull deepquestai/deepstack:cpu-2021.02.1

You can also install the Native Windows Version of DeepStack, this supports GPU acceleration

CPU Version

Download and run DeepStack CPU Installer

GPU Version

Install DeepStack on Linux

Linux Support is via Docker, hence you must install docker first

sudo apt-get update && sudo apt-get install docker.io

CPU Version

sudo docker pull deepquestai/deepstack:cpu-2021.02.1

GPU Version

sudo docker pull deepquestai/deepstack:gpu-2021.02.1

Install DeepStack on MacOS

MacOS support is via Docker, install docker on Mac and run

sudo docker pull deepquestai/deepstack:cpu-2020.02.1 Note that GPU acceleration is not available for Mac at the moment

Install DeepStack on Nvidia Jetson

sudo docker pull deepquestai/deepstack:jetpack-2021.02.1

Install DeepStack Python SDK

pip3 install deepstack-sdk

Examples

Object Detection

  1. Run DeepStack Object Detection API

    • Docker CPU: docker run -e VISION-DETECTION=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack

    • Docker GPU: sudo docker run --gpus all -e VISION-DETECTION=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack:gpu

    • Windows CPU & GPU: deepstack --VISION-DETECTION True --PORT 80

    • NVIDIA Jetson: sudo docker run --runtime nvidia -e VISION-DETECTION=True -p 80:5000 deepquestai/deepstack:jetpack

  2. Sample code

    object detection

     from deepstack_sdk import ServerConfig, Detection
    
     config = ServerConfig("http://localhost:80")
     detection = Detection(config)
    
     response = detection.detectObject("detection.jpg",output="detection_output.jpg", draw_bounding_box=True,show_label=True,show_conf=True)
    
     for obj in response:
         print("Name: {}, Confidence: {}".format(obj.label, obj.confidence))
    
     

    Result

    object detection output

  1. Find more code samples in examples folder of this repository.

Face

  1. Run DeepStack Face API

    • Docker CPU: docker run -e VISION-FACE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack

    • Docker GPU: sudo docker run --gpus all -e VISION-FACE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack:gpu

    • Windows CPU & GPU: deepstack --VISION-FACE True --PORT 80

    • NVIDIA Jetson: sudo docker run --runtime nvidia -e VISION-FACE=True -p 80:5000 deepquestai/deepstack:jetpack

  2. Sample code: Face Detection

    object detection

     from deepstack_sdk import ServerConfig, Face
    
     config = ServerConfig("http://localhost:80")
     face = Face(config)
    
     response = face.detectFace("got.jpg",output="got_detected.jpg")
    
     for obj in response:
         print("Face Detected, Confidence: {}".format(obj.confidence))
    
     

    object detection output

  3. Sample code: Face Recognition

    i. Register Face object detection

     from deepstack_sdk import ServerConfig, Face
    
     config = ServerConfig("http://localhost:80")
     face = Face(config)
    
     images = ["thanos.jpg"]
     response = face.registerFace(images=images,userid="Thanos")
     print(response)
     

    ii. Perform Face Recognition object detection output

     from deepstack_sdk import ServerConfig, Face
    
     config = ServerConfig("http://localhost:80")
     face = Face(config)
    
     response = face.recognizeFace(image=r"thanos2.jpg", output="face_recognized.jpg",draw_bounding_box=True,show_label=True,show_conf=True)
     print(response)
     

    object detection output

Enhance (4X)

  1. Run DeepStack Enhance API

    • Docker CPU: docker run -e VISION-ENHANCE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack

    • Docker GPU: sudo docker run --gpus all -e VISION-ENHANCE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack:gpu

    • Windows CPU & GPU: deepstack --VISION-ENHANCE True --PORT 80

    • NVIDIA Jetson: sudo docker run --runtime nvidia -e VISION-ENHANCE=True -p 80:5000 deepquestai/deepstack:jetpack

  2. Sample code

    enhance

Input Image dimension (Width: 460px, Height :259px)

   from deepstack_sdk import ServerConfig, Enhance
   
   config = ServerConfig("http://localhost:80")
   enhance = Enhance(config)
   
   response = enhance.enhanceObject("supermarket.jpg", output="supermarket_4X.jpg")
   
   for obj in response:
       print("Base64: {}, width: {}, height: {}".format(obj.base64, obj.width, obj.height))
 

Output Image dimension (Width: 1840px, Height : 1036px)

enhance output

  1. Find more code samples in examples folder of this repository.