Taxonomy Icon

Artificial Intelligence

Developers can build apps with computer vision and object detection by leveraging deep learning frameworks. A lot of the effort and expertise required to do this can be avoided by using PowerAI Vision to train and deploy your model. PowerAI Vision provides a UI where you can train, deploy and test your own object detection model without needing any prior knowledge of deep learning.

In this how-to, you’ll learn how to use the PowerAI Vision UI to turn your example images into a REST endpoint that can be used in an object detection app.

As of December 2017, PowerAI Vision is a Tech Preview which can be installed on Power Systems or used with a trial account in the cloud.

Note: This how-to was written assuming the PowerAI Vision Technology Preview v3.0.

Learning objectives

The goal of this tutorial is to show you the basics of deep learning for object detection while also making it extremely easy by using the PowerAI Vision UI. This is a hands-on approach to accomplish the following:

  • Create and label a dataset for object detection
  • Train and deploy a model based on the dataset
  • Test the model via REST calls

The details of setting up the frameworks, leveraging GPU power, and serving up your model as a REST endpoint are mostly hidden, because PowerAI Vision handles that.

The end result is a ready-to-use custom-built object detection API.

Prerequisites

  • A collection of example images: You can choose your own collection of images. Keep in mind the object detection use case. You want a use case where one or both of these are interesting:

    • Where are the target objects in the image?
    • How many of the target objects are in the image?

    In the example images, you’ll see that we collected images of Coca-Cola bottles. This allows us to create an app that can count the bottles as well as locate them.

  • Preview access to PowerAI Vision: Go to Try Power AI and use On Premise to download an installer to deploy the preview on your Power Systems, or use SuperVessel and register for access to the SuperVessel cloud where you can try the preview.

    try-powerai

Note: The steps and examples in this how-to assume you are using SuperVessel.

Estimated time

The interactive steps take less than an hour, but when you start the training task it may take over an hour to complete (estimate 90 minutes but it will depend on your dataset and other factors). So plan to start this exercise, take a break, and finish it later.

Steps

  1. Login to PowerAI Vision
  2. Create a dataset
  3. Create tags and label objects
  4. Create a DL task
  5. Deploy and test

Login to PowerAI Vision

If you are using SuperVessel, login here: https://ny1.ptopenlab.com/AIVision/index.html

Create a dataset

PowerAI Vision Object Detection discovers and labels objects within an image, enabling users and developers to count instances of objects within an image based on customized training.

To create a new dataset for object detection training:

  • From the My Data Sets view, click the Add Dataset button and then select For Object Detection in the pull-down.

    add_dataset

  • Provide a DataSet Name and click Add Dataset.

    add_dataset_name

  • Upload one or more images using drag-and-drop or Select some. You can use a zip file to upload many files at once, or use multi-select. Click here if you want to download the coke bottles example dataset.

    update_dataset

    Note: If you are using your own zip file and do not see file thumbnails after the upload, then the upload failed. Use lowercase file names without special characters or spaces. You can also upload individual files or multi-select several at a time to determine which file caused the upload to fail.

Create tags and label objects

  • Create one or more tags by clicking the + icon to add a new tag. Each tag will represent the training objects within the image based on specific use cases).

  • Label the objects in each image by selecting a tag and dragging a bounding box around the object in the image. Press Save when done with each image.

  • Repeat this process for all tags and all images.

    add_dataset

    Tip: Use the Only Show Unlabeled Files pull-down to help you see when you are done.

  • Click Export As Zip File to save a copy of your work. Now that you’ve spent some time labeling, this zip will let you start over without losing your work.

Create a DL task

  • Click on My DL Tasks under My Workspace and then click the Create New Task button. Click on Object Detection.

  • Give the Object Detector a name and make sure your dataset is selected, then click Build Model.

    build_model

  • A confirmation dialog will give you a time estimate. Click Create New Task to get it started.

    create_task_confirm

Deploy and test

  • When the model is built, click on Deploy and Test.

    model_built

  • Test your model in the PowerAI Vision UI. Use Select some to choose a test image. The result shows you how many objects were detected and the image is shown with bounding boxes, labels and confidence scores.

    test_ui

  • From a command-line, you can test your deployed REST endpoint using an image file and the curl command. Notice the output JSON shows multiple bottles were detected and provides the confidence, label and location for each of them.

    Warning: this example used --insecure for convenience.

    $ curl --insecure -i -F files=@coke_bottle_23.png https://ny1.ptopenlab.com/AIVision/api/dlapis/9f9d6787-0183-4a1b-be49-751b6ca16724
    HTTP/1.1 100 Continue
    
    HTTP/1.1 200 OK
    Server: nginx/1.9.13
    Date: Thu, 14 Dec 2017 21:58:26 GMT
    Content-Type: application/json
    Content-Length: 508
    Connection: keep-alive
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Headers: origin, content-type, accept, authorization
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
    Access-Control-Allow-Origin: *
    
    { "classified" : [ { "confidence" : 0.9986369013786316 , "ymax" : 578 , "label" : "coca-cola" , "xmax" : 755 , "xmin" : 588 , "ymin" : 29} , { "confidence" : 0.9954010248184204 , "ymax" : 592 , "label" : "coca-cola" , "xmax" : 601 , "xmin" : 437 , "ymin" : 10} , { "confidence" : 0.8161203265190125 , "ymax" : 567 , "label" : "coca-cola" , "xmax" : 426 , "xmin" : 259 , "ymin" : 17}] , "imageUrl" : "http://ny1.ptopenlab.com:443/AIVision/temp/5a26dd3b-d8ba-4e01-8b93-5a43f28e97c7.png" , "result" : "success"}
    

Summary

Now you’ve seen how deep learning technology is able to learn from labeled example images and create an object detection API. Since you created a REST endpoint which returns the results in JSON, it is easy to use this in any app.

PowerAI Vision made it all very easy to do while harnessing GPU power to accelerate the training.

The accuracy of your object detection will depend on the examples provided. Most likely a dataset used to experiment will be too small to give production quality results. Training takes time and good training data. You can grow your dataset and improve your results.