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()

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.20211111.tar.gz (15.6 MB view details)

Uploaded Source

Built Distribution

daisykit-0.1.20211111-cp38-cp38-win_amd64.whl (23.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

File details

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

File metadata

  • Download URL: daisykit-0.1.20211111.tar.gz
  • Upload date:
  • Size: 15.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.9

File hashes

Hashes for daisykit-0.1.20211111.tar.gz
Algorithm Hash digest
SHA256 9102279d0131d6252a36a94daf9e26703937bb26f0188956ec855f6c3ae96e83
MD5 c25206f6ce14054925e3172f1dc383c3
BLAKE2b-256 3aa3e1c7baa21f4be36db4fa9c9052bd83395cc909fb7fb73c37d544a79c6082

See more details on using hashes here.

File details

Details for the file daisykit-0.1.20211111-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: daisykit-0.1.20211111-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 23.5 MB
  • Tags: CPython 3.8, 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for daisykit-0.1.20211111-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 24f2c2ffafe4e04e4b896afc95aa1b6efff4ae4be9fbedc9183f99b041d11878
MD5 244fa1fc730fb711c14d623f83c71c5a
BLAKE2b-256 7d75eacb7cbedb87d63152e03847653bbeff1718f1ecdcc5f89f5a59c5c50e3d

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