AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019...

69
AI and AR Godfrey Nolan

Transcript of AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019...

Page 1: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

AI and ARGodfrey Nolan

Page 2: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans
Page 3: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans
Page 4: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

01.Experience

Page 5: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Experience

• FieldMap

• Create waypoints

• Rolling shutter vs global shutter

• Automated flight around field

• Tile images on iPad

• Stitch images using OpenCV.

9/5/2019 Counting Sheep 5

Page 6: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

9/5/2019 Counting Sheep 6

Page 7: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Experience

• Secure Drones Labs

• No data leakage

• Tamper resistant

• Self destruct button

9/5/2019 Counting Sheep 7

Page 8: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

02.Counting Sheep??

Page 9: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Counting Sheep

• Requirements

• Semi-practical example

• Using existing experience

• Move to Drone 2.0

• Answer the age old question‘Do Androids dream ofElectric Sheep’

9/5/2019 Counting Sheep 9

Page 10: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

03.Plug and Play

Page 11: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

• Google Cloud Platform

• Docker

9/5/2019 Counting Sheep 11

Page 12: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 12

Page 13: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 13

Page 14: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 14

Page 15: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 15

Page 16: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 16

Page 17: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Components

• DJI Mobile SDK

• Google Tensorflow

9/5/2019 Counting Sheep 17

Page 18: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

04.Machine Learning Workflow

Page 19: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 19

Page 20: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 20

Page 21: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 21

Page 22: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 22

Page 23: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 23

Page 24: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 24

Page 25: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Workflow

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 25

Page 26: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

05.Implementation

Page 27: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 27

Page 28: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 28

Page 29: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 29

Page 30: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 30

Page 31: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 31

Page 32: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

Page 33: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 33

Page 34: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 34

Page 35: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 35

Page 36: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 36

Page 37: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 37

Page 38: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 38

Page 39: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 39

Page 40: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train and Test

• Prepare the Dataset

• Set Up Google Cloud Account

• Set Up Docker

• Configure Google Cloud

• Set Up Object Detection API

• Train Your Model

• Evaluate Your Model

9/5/2019 Counting Sheep 40

Page 41: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 41

Page 42: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 42

Page 43: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 43

Page 44: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 44

Page 45: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 45

Page 46: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 46

Page 47: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 47

Page 48: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Implementation

• Get Data

• Train & Test

• Adjust

• Deploy

• Test & Validate

9/5/2019 Counting Sheep 48

Page 49: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans
Page 50: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

06.Resources Q&A

Page 51: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Lessons Learned

• Crowdsource earlier

• Choose more practical example

• Create your own images

• Image quality

9/5/2019 Counting Sheep 51

Page 52: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Lessons Learned

• Dyed sheep

• Streamline config. with Docker

• Tensorflow works on iOS

9/5/2019 Counting Sheep 52

Page 53: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Future Plans

• Cattle

• Horses

• Deer

• Polar Bear (thermal)

• Parking Lots

• Plants

• Pallets

9/5/2019 Counting Sheep 53

Page 54: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Future Plans

• Animal Tracking

• AR and AI

• Amazon’s Mechanical Turk

• Automate

9/5/2019 Counting Sheep 54

Page 55: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Resources

• http://developer.dji.com

• https://www.tensorflow.org/install/

• https://github.com/tzutalin/labelImg

• https://github.com/tensorflow/models/tree/master/research/object_detection

• https://becominghuman.ai/

• https://towardsdatascience.com/how-to-train-your-own-object-detector-with-tensorflows-object-detector-api-bec72ecfe1d9

• https://docs.bazel.build

• https://t.co/uUTWuPw1ve (whitepaper) and https://github.com/nickdonnellyriis/sheep_demo (code)

9/5/2019 Counting Sheep 55

Page 56: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Q&A

[email protected]

• @godfreynolan

• riis.com/blog

• slides.com/godfreynolan

9/5/2019 Counting Sheep 56

Page 57: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

07.Extras

Page 58: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Prepare the Dataset

• Gather images

• Label the images with LabelImg found at https://github.com/tzutalin/labelImg

• Generate CSV files from your labeled dataset using script found at https://github.com/datitran/raccoon_dataset/blob/master/xml_to_csv.py

• Convert the CSV files into your TFRecord Dataset using script found at https://github.com/datitran/raccoon_dataset/blob/master/generate_tfrecord.py

• Create your label map file.

9/5/2019 Counting Sheep 58

Page 59: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Prepare the Dataset

9/5/2019 Counting Sheep 59

Page 60: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set Up Google Cloud Account

• Sign up for a Google Cloud Account

• Set up a project named CountingSheep

• Enable ML Engine for your project https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com

• Click “Storage” on the side bar, and then create a new bucket called CountingSheepData

• Create a sub-directory called “data” in your storage bucket

9/5/2019 Counting Sheep 60

Page 61: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set Up Your Docker Environment

• Download Docker from docker.io

• Download the Dockerfilehttps://github.com/tensorflow/models/blob/master/research/object_detection/dockerfiles/android/Dockerfile

• docker build .

• docker images

• docker run -it IMAGE_ID

9/5/2019 Counting Sheep 61

Page 62: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Configure your local Google Cloud environment

• Login - gcloud auth login

• Set your google cloud project - gcloud config set project YOUR_PROJECT_NAME

• Set your storage bucket - gsutil mb gs://YOUR_UNIQUE_BUCKET_NAME

• Export Google Cloud project/bucket names - export PROJECT="YOUR_PROJECT_ID"

export YOUR_GCS_BUCKET="YOUR_UNIQUE_BUCKET_NAME"

9/5/2019 Counting Sheep 62

Page 63: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Configure your local Google Cloud environment

• Get the name of your service account:-curl -H "Authorization: Bearer $(gcloud auth print-access-token)" https://ml.googleapis.com/v1/projects/${PROJECT}:getConfig

• Using the tpuServiceAccount value from the response. Export the TPU service account with the following command:-

- export TPU_ACCOUNT=your-service-account

• Grant ML service agent to TPU service account:-gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$TPU_ACCOUNT --role roles/ml.serviceAgent

9/5/2019 Counting Sheep 63

Page 64: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set up Object Detection API

• Ensure your local copy of object detection API works with following commands:cd /tensorflow/models/researchpython object_detection/builders/model_builder_test.py

9/5/2019 Counting Sheep 64

Page 65: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set up Object Detection API

• Move your TFRecord files and label map from your host machine into your docker imagedocker cp train.record CONTAINERNAME:/train.recorddocker cp test.record CONTAINERNAME:/test.recorddocker cp sheep_label_map.pbtxt CONTAINERNAME:/ sheep_label_map.pbtxt

• Copy the data over to your bucket (from your docker container)gsutil -m cp -r /train.record gs://${YOUR_GCS_BUCKET}/data/gsutil -m cp -r /test.record gs://${YOUR_GCS_BUCKET}/data/gsutil cp /sheep_label_map.pbtxt gs://${YOUR_GCS_BUCKET}/data/

9/5/2019 Counting Sheep 65

Page 66: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set up Object Detection API

• Download the object detection model:curl –O http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_0.75_depth_300x300_coco

14_sync_2018_07_03.tar.gztar xzf ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03.tar.gz

• Upload it to Google cloudgsutil cp /tmp/ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03/model.ckpt.*

gs://${YOUR_GCS_BUCKET}/data/

9/5/2019 Counting Sheep 66

Page 67: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Set up Object Detection API

• Update the following values in the config file:/tensorflow/models/research/object_detection/samples/configs/ssd_mobilenet_v1_0.75_depth_quantized_300x300_pets_sync.config

Upload file to Google Cloud bucket with the following command:gsutil cp

/tensorflow/models/research/object_detection/samples/configs/ssd_mobilenet_v1_0.75_depth_quantized_300x300_pets_sync.config gs://${YOUR_GCS_BUCKET}/data/pipeline.config

• Package the object detection API with the following commands:bash object_detection/dataset_tools/create_pycocotools_package.sh /tmp/pycocotoolspython setup.py sdist

9/5/2019 Counting Sheep 67

Page 68: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train your model

• Start your training job on Google Cloud TPU with the following command:cd /tensorflow/models/researchgcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` --job-dir=gs://${YOUR_GCS_BUCKET}/train --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-

0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz --module-name object_detection.model_tpu_main--runtime-version 1.9 --scale-tier BASIC_TPU --region us-central1--model_dir=gs://${YOUR_GCS_BUCKET}/train --tpu_zone us-central1 --pipeline_config_path=gs://${YOUR_GCS_BUCKET}/data/pipeline.config

•9/5/2019 Counting Sheep 68

Page 69: AI and AR - Amazon S3 · • Streamline config. with Docker • Tensorflow works on iOS 9/5/2019 Counting Sheep 52. Future Plans

Train your model

• Start your training job on Google Cloud TPU with the following command:cd /tensorflow/models/researchgcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` --job-dir=gs://${YOUR_GCS_BUCKET}/train --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-

0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz --module-name object_detection.model_tpu_main--runtime-version 1.9 --scale-tier BASIC_TPU --region us-central1--model_dir=gs://${YOUR_GCS_BUCKET}/train --tpu_zone us-central1 --pipeline_config_path=gs://${YOUR_GCS_BUCKET}/data/pipeline.config

•9/5/2019 Counting Sheep 69