Skip to main content

A simple tool for Computer Vision Inference

Project description

PeekingDuck

Python version PyPI version License

What is PeekingDuck?

PeekingDuck is an open-source, modular framework in Python, built for Computer Vision (CV) inference. It helps to significantly cut down development time when building CV pipelines. The name "PeekingDuck" is a play on these words: "Peeking" in a nod to CV; and "Duck" in duck typing.

Install and Run PeekingDuck

  1. Install PeekingDuck from PyPI.

    > pip install peekingduck
    

    Note: if installing on a device with an ARM processor such as a Raspberry Pi, include the --no-dependencies flag.

  2. Create a project folder at a convenient location, and initialize a PeekingDuck project.

    > mkdir <project_dir>
    > cd <project_dir>
    > peekingduck init
    

    The following files and folders will be created upon running peekingduck init:

    <project_dir>
     ├── run_config.yml
     └── src
          └── custom_nodes
    
  3. Run a demo.

    > peekingduck run
    

    If you have a webcam, you should see the demo running live:

    The previous command looks for a run_config.yml in the current directory. You can also specify the path of a different config file to be used, as follows:

    > peekingduck run --config_path <path_to_config>
    

    Terminate the program by clicking on the output screen and pressing q.

  4. For more help on how to use PeekingDuck's command line interface, you can use peekingduck --help.

How PeekingDuck Works

Nodes are the building blocks of PeekingDuck. Each node is a wrapper for a Python function, and contains information on how other PeekingDuck nodes may interact with it.

PeekingDuck has 5 types of nodes:

A pipeline governs the behavior of a chain of nodes. The diagram below shows the pipeline used in the previous demo. Nodes in a pipeline are called in sequential order, and the output of one node will be the input to another. For example, input.live produces "img", which is taken in by model.yolo, and model.yolo produces "bboxes", which is taken in by draw.bbox.

Changing Nodes and Settings

Earlier on, the peekingduck init command created the run_config.yml file, which is PeekingDuck's main configuration file and is responsible for:

  • Selecting which nodes to include in the pipeline
  • Configuring node behaviour

1. Selecting which nodes to include in the pipeline:

  • In the earlier object detection demo, run_config.yml used the following nodes:

    nodes:
      - input.live
      - model.yolo
      - draw.bbox
      - output.screen
    
  • Now, let's modify it to run a pose estimation demo using the following nodes:

    nodes:
      - input.live
      - model.posenet
      - draw.poses
      - output.screen
    
  • If you have a webcam, you should see the demo running live:

    Terminate the program by clicking on the output screen and pressing q.

2. Configuring node behaviour:

  • If you're not using a webcam, don't worry about missing out! PeekingDuck is also able to work on recorded videos or saved images, and we'll use the input.recorded and output.media_writer nodes for that. You can use any video or image file as long as it's a supported format, or download a short sample video (credit: PoseTrack) to test it.

  • We'll need to change the settings of these 2 nodes, in order to set the input and output directories, as follows:

    nodes:
      - input.recorded:   # note the ":"
          input_dir: <directory where videos/images are stored>
      - model.posenet
      - draw.poses
      - output.media_writer:  # note the ":"
          output_dir: <directory to save results>
    
  • Once PeekingDuck has finished running, the processed files will be saved to the specified output directory. If you've used the short sample video, open the processed file and you should get this:

  • To find out what other settings can be tweaked for different nodes, check out PeekingDuck's node glossary.

Explore PeekingDuck Nodes

AI models are cool and fun, but we're even more interested to use them to solve real-world problems. We've combined heuristic nodes with model nodes to create use cases, such as social distancing and group size checking to help combat COVID-19. For more details, click on the heading of each use case below.

Social Distancing Zone Counting
Group Size Checking Object Counting

We're constantly developing new nodes to increase PeekingDuck's capabilities. You've gotten a taste of some of our commonly used nodes in the previous demos, but PeekingDuck can do a lot more. To see what other nodes available, check out the node glossary.

Create Custom Nodes

You may need to create your own custom nodes. Perhaps you'd like to take a snapshot of a video frame, and post it to your API endpoint; perhaps you have a model trained on a custom dataset, and would like to use PeekingDuck's input, draw, and output nodes.

We've designed PeekingDuck to be very flexible - you can create your own nodes and use them with ours. This guide provides more details on how to do that.

Acknowledgements

This project is supported by the National Research Foundation, Singapore under its AI Singapore Programme (AISG-RP-2019-050). Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not reflect the views of National Research Foundation, Singapore.

License

PeekingDuck is under the open source Apache License 2.0 (:

Even so, your organisation may require legal proof of its right to use PeekingDuck, due to circumstances such as the following:

  • Your organisation is using PeekingDuck in a jurisdiction that does not recognise this license
  • Your legal department requires a license to be purchased
  • Your organisation wants to hold a tangible legal document as evidence of the legal right to use and distribute PeekingDuck

Contact us if any of these circumstances apply to you.

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

peekingduck-0.3.1.tar.gz (68.7 kB view hashes)

Uploaded Source

Built Distribution

peekingduck-0.3.1-py3-none-any.whl (143.1 kB view hashes)

Uploaded Python 3

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