Skip to main content

Deploy AI Systems Yourself (DAISY) Kit. DaisyKit Python is the wrapper of DaisyKit SDK, an AI framework focusing on the ease of deployment.

Project description

DaisyKit Python

https://pypi.org/project/daisykit/

Deploy AI Systems Yourself (DAISY) Kit. DaisyKit Python is the wrapper of DaisyKit SDK, an AI framework focusing on the ease of deployment. This package only supports Ubuntu Linux - Python 3 now. We will add support for other platforms and models in the future.

Install and run example

Install dependencies. Below commands are for Ubuntu. You can try other installation methods based on your OS.

sudo apt install pybind11-dev # Pybind11 - For Python/C++ Wrapper
sudo apt install libopencv-dev # For OpenCV
sudo apt install libvulkan-dev # Optional - For GPU support

Install DaisyKit

pip3 install --upgrade pip # Ensure pip is updated
pip3 install daisykit

Face Detection with mask recognition:

import cv2
import json
from daisykit.utils import get_asset_file
import daisykit

config = {
    "face_detection_model": {
        "model": get_asset_file("models/face_detection/yolo_fastest_with_mask/yolo-fastest-opt.param"),
        "weights": get_asset_file("models/face_detection/yolo_fastest_with_mask/yolo-fastest-opt.bin"),
        "input_width": 320,
        "input_height": 320,
        "score_threshold": 0.7,
        "iou_threshold": 0.5,
        "use_gpu": False
    },
    "with_landmark": True,
    "facial_landmark_model": {
        "model": get_asset_file("models/facial_landmark/pfld-sim.param"),
        "weights": get_asset_file("models/facial_landmark/pfld-sim.bin"),
        "input_width": 112,
        "input_height": 112,
        "use_gpu": False
    }
}

face_detector_flow = daisykit.FaceDetectorFlow(json.dumps(config))

# Open video stream from webcam
vid = cv2.VideoCapture(0)

while(True):

    # Capture the video frame
    ret, frame = vid.read()

    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    faces = face_detector_flow.Process(frame)
    # for face in faces:
    #     print([face.x, face.y, face.w, face.h,
    #           face.confidence, face.wearing_mask_prob])
    face_detector_flow.DrawResult(frame, faces)

    frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

    # Display the resulting frame
    cv2.imshow('frame', frame)

    # The 'q' button is set as the
    # quitting button you may use any
    # desired button of your choice
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()

Background Matting:

import cv2
import json
from daisykit.utils import get_asset_file
from daisykit import BackgroundMattingFlow

config = {
    "background_matting_model": {
        "model": get_asset_file("models/background_matting/erd/erdnet.param"),
        "weights": get_asset_file("models/background_matting/erd/erdnet.bin")
    }
}

# Load background
default_bg_file = get_asset_file("images/background.jpg")
background = cv2.imread(default_bg_file)
background = cv2.cvtColor(background, cv2.COLOR_BGR2RGB)

background_matting_flow = BackgroundMattingFlow(json.dumps(config), background)

# Open video stream from webcam
vid = cv2.VideoCapture(0)

while(True):

    # Capture the video frame
    ret, frame = vid.read()

    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    mask = background_matting_flow.Process(frame)
    background_matting_flow.DrawResult(frame, mask)

    frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

    # Display the resulting frame
    cv2.imshow('frame', frame)

    # The 'q' button is set as the
    # quitting button you may use any
    # desired button of your choice
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()

Human Pose Detection:

import cv2
import json
from daisykit.utils import get_asset_file
from daisykit import HumanPoseMoveNetFlow

config = {
  "person_detection_model": {
    "model": get_asset_file("models/human_detection/ssd_mobilenetv2.param"),
    "weights": get_asset_file("models/human_detection/ssd_mobilenetv2.bin")
  },
  "human_pose_model": {
    "model": get_asset_file("models/human_pose_detection/movenet/lightning.param"),
    "weights": get_asset_file("models/human_pose_detection/movenet/lightning.bin"),
    "input_width": 192,
    "input_height": 192
  }
}

human_pose_flow = HumanPoseMoveNetFlow(json.dumps(config))

# Open video stream from webcam
vid = cv2.VideoCapture(0)

while(True):

    # Capture the video frame
    ret, frame = vid.read()

    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    poses = human_pose_flow.Process(frame)
    human_pose_flow.DrawResult(frame, poses)

    print(poses)

    frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

    # Display the resulting frame
    cv2.imshow('frame', frame)

    # The 'q' button is set as the
    # quitting button you may use any
    # desired button of your choice
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()

Barcode Detection:

import cv2
import json
from daisykit.utils import get_asset_file
from daisykit import BarcodeScannerFlow

config = {
  "try_harder": True,
  "try_rotate": True
}

barcode_scanner_flow = BarcodeScannerFlow(json.dumps(config))

# Open video stream from webcam
vid = cv2.VideoCapture(0)

while(True):

    # Capture the video frame
    ret, frame = vid.read()

    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    result = barcode_scanner_flow.Process(frame, draw=True)

    frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

    # Display the resulting frame
    cv2.imshow('frame', frame)

    # The 'q' button is set as the
    # quitting button you may use any
    # desired button of your choice
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()

Build Python package

Build environment: Ubuntu.

sudo apt install ninja-build
python3 -m pip install --user --upgrade twine

Build package:

python3 setup.py sdist

or

bash scripts/build_python.sh

Upload to Pypi (for DaisyKit authors only)

twine upload dist/*

TODO

  • Multiplatform build.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daisykit-0.1.20211116.tar.gz (15.4 MB view details)

Uploaded Source

Built Distributions

daisykit-0.1.20211116-cp310-cp310-win_amd64.whl (23.9 MB view details)

Uploaded CPython 3.10 Windows x86-64

daisykit-0.1.20211116-cp39-cp39-win_amd64.whl (23.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

daisykit-0.1.20211116-cp37-cp37m-win_amd64.whl (23.9 MB view details)

Uploaded CPython 3.7m Windows x86-64

daisykit-0.1.20211116-cp36-cp36m-win_amd64.whl (23.9 MB view details)

Uploaded CPython 3.6m Windows x86-64

daisykit-0.1.20211116-cp35-cp35m-win_amd64.whl (23.9 MB view details)

Uploaded CPython 3.5m Windows x86-64

File details

Details for the file daisykit-0.1.20211116.tar.gz.

File metadata

  • Download URL: daisykit-0.1.20211116.tar.gz
  • Upload date:
  • Size: 15.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116.tar.gz
Algorithm Hash digest
SHA256 2d6f564187a67ad922777379adc86903b5f3dc9edbaf4d500fb8a69bb4dee986
MD5 32c991050b759b34cc461bd2ed0cdb1c
BLAKE2b-256 a7b2a82805e7100ff2ae6b3b4463f0850af56c328f33e160cb6cc324653cee40

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211116-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211116-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 23.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7b171649413ae1fc3c2802c7726f55ca2a3ed4572fb30b279ec8b24ec7b8e5a1
MD5 9a70c026afccf6f1dfa47069c5720347
BLAKE2b-256 cf6a4807d3ae1ea946b8ee7fc444859e5270cfc43a1e59b24f3dfb968e1847e6

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211116-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211116-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 23.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6c9f0f5243a9d8b9a0dd7b0901b595a393e6cc77776cf08358e30646c46dccb7
MD5 ff87cbbbdce644a35c464478b26055aa
BLAKE2b-256 55715ba0f5c7049a5ac6678d2a9c6db17f50f9294f45a7fcc954ab7057b98f77

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211116-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211116-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 23.9 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 49abe01308beee7d61fdb7fc2c688acc27a96123f71b1078d81d8dc05852e568
MD5 77017f3d6dbdabf291fb956c3fcba762
BLAKE2b-256 eb16ed02dd873a0017facfaca9bb111d04e51bbfb2f9636865cf14e56e34d91a

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211116-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211116-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 23.9 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f0a1c07988acbd61c7bd3fc8ef0c3d0dde4e17f2352075ccff12473f1bd4c8b7
MD5 88a115e62015b5aad2b8af3769f71a51
BLAKE2b-256 42a2457ce296e45e7b5ccee200ae8ba7151e692fa296edcbeb666ba186fb97c3

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211116-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211116-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 23.9 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for daisykit-0.1.20211116-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 d5b0b3f61f92639e7ee7e7208821e6b2524faa69d57c4d7d474adb49f127a8bf
MD5 91e8ebae9ab55dfed90dc7333251fb19
BLAKE2b-256 fe3db5ee9a81d72f422907a5f1571c9ee302c62ab2a6a0cc9400bfd168c26668

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page