SlideShare una empresa de Scribd logo
1 de 30
Stephen Wylie
GDG Dallas
@SWebCEO
Fusing AI with AR
NH GDG
DevFest
9/28/2019
NH GDG
DevFest
●GDE in Machine Learning
●Software Engineer @ rewardStyle
●Fix old arcade machines & computers, and pinballs
of all eras
●Love fancy men’s clothing & vintage TV game
shows
●Lots of patents in this area
About Me
AI + AR:
Does anyone do this
themselves?
NH GDG
DevFest
Sports
● Homecourt- Practice
basketball, get coaching
● MLB - ID players, show stats
AI + AR: Does anyone do this themselves?
Yes, of course! But with help...
APIs & Frameworks Are Your Friends!
Retail
● Burberry - Customize items,
detect counterfeits
● Cup Noodles - Turn cups into
musical instruments
● Wayfair, IKEA - Preview items
in your own house
Vehicle Recognition & Auto
Loans
● Blippar - AR/VR company
● Capital One - AR feature of
Auto Navigator
● USAA - Loans & insurance
Key Terms
Key Terms
In AI
● MobileNet, SqueezeNet,
Inception, ResNet
Neural networks optimized for
computer vision tasks
● Tensorflow Lite
Inference engine optimized to run
.tflite models on mobile devices
● MLKit
APIs that enable specific Machine
Learning use cases on devices or
cloud
In AR
● ARCore
Cross-platform augmented reality
SDK using OpenGL for motion
tracking, scene building
● Sceneform
AR SDK for Android saving you
from learning OpenGL
Establish your
Android app
Establish your Android app
Preparation
Install prereqs
Install latest
versions of
APIs, SDKs,
IDEs, and build
tools
Preparation
Clone repo
Get
Tensorflow
source from
Docker, Github,
etc.
Understand &
Build
Open app code
Edit app code
to use
Sceneform
fragment
rather than
Camera-
ConnectionFra
gment
Bust your
head
Build with Bazel
This smooths
object
detection,
improves
tracking on
recognized
entities
Build
More
Add AR code
Hit test the
bounding box
and draw the
3D model
relative to that
point
Finish
Profit!
Or, fix
problems and
build your own
TFLite model
NH GDG
DevFest
●Latest:
●Java JDK 10 (not 11, not 8)
●Building in Windows? You’ll need ~5GB worth of:
○Visual C++ Build Tools - visualcppbuildtools_full.exe
■Windows 10 SDK 10.0.10240
■.NET Framework SDK
○A real shell like MSYS2
●Pick your poison! Download Tensorflow source from GitHub or
Docker
Install Prerequisites
●Android Studio
●Android API level
●Android NDK
●Gradle
●Bazel
Establish your Android app
Preparation
Install prereqs
Install latest
versions of
APIs, SDKs,
IDEs, and build
tools
Preparation
Clone repo
Get
Tensorflow
source from
Docker, Github,
etc.
Understand &
Build
Open app code
Edit app code
to use
Sceneform
fragment
rather than
Camera-
ConnectionFra
gment
Bust your
head
Build with Bazel
This smooths
object
detection,
improves
tracking on
recognized
entities
Build
More
Add AR code
Hit test the
bounding box
and draw the
3D model
relative to that
point
Finish
Profit!
Or, fix
problems and
build your own
TFLite model
NH GDG
DevFest
Code root: tensorflow/tensorflow/lite/examples/android/app
●Consider copying to a different folder
●Add Sceneform dependencies to Gradle build
●Update Gradle build to latest Tools, API >= 26
●Add AR permissions to Android Manifest
●Make new Layout incorporating ArFragment
●Use this Layout in your CameraActivity
○Or make it a separate class
○Update Manifest with new Activity
○Ensure DetectorActivity extends it
Gradle downloads ML model assets
Start Modifying Code
Code
Thus
Far
Establish your Android app
Preparation
Install prereqs
Install latest
versions of
APIs, SDKs,
IDEs, and build
tools
Preparation
Clone repo
Get
Tensorflow
source from
Docker, Github,
etc.
Understand &
Build
Open app code
Edit app code
to use
Sceneform
fragment
rather than
Camera-
ConnectionFra
gment
Bust your
head
Build with Bazel
This smooths
object
detection,
improves
tracking on
recognized
entities
Build
More
Add AR code
Hit test the
bounding box
and draw the
3D model
relative to that
point
Finish
Profit!
Or, fix
problems and
build your own
TFLite model
NH GDG
DevFest
●Define androidsdk and androidndk path in
WORKSPACE
●Omit API level & build tools version
●cd to tensorflow/
●Run bazel build
//tensorflow/lite/examples/android:tflite_demo
●Funky Windows business
●Pray hard!
Build with Bazel
What
Success
Looks
Like
Code
Thus
Far
Establish your Android app
Preparation
Install prereqs
Install latest
versions of
APIs, SDKs,
IDEs, and build
tools
Preparation
Clone repo
Get
Tensorflow
source from
Docker, Github,
etc.
Understand &
Build
Open app code
Edit app code
to use
Sceneform
fragment
rather than
Camera-
ConnectionFra
gment
Bust your
head
Build with Bazel
This smooths
object
detection,
improves
tracking on
recognized
entities
Build
More
Add AR code
Hit test the
bounding box
and draw the
3D model
relative to that
point
Finish
Profit!
Or, fix
problems and
build your own
TFLite model
NH GDG
DevFest
●Can’t use Bazel anymore
○Incorporate object detection model into src/main/jniLibs
○Set parameter for CPU architecture in Gradle
●Sceneform Plugin or Gradle Instruction
○Sceneform codelab calls for 1.4; Android Studio plugin is 1.6
○Best to just use Gradle instructions to create SFB assets
●Add augmented reality code to MultiBoxTracker
Add Augmented Reality Code
Final
Product
Establish your Android app
Preparation
Install prereqs
Install latest
versions of
APIs, SDKs,
IDEs, and build
tools
Preparation
Clone repo
Get
Tensorflow
source from
Docker, Github,
etc.
Understand &
Build
Open app code
Edit app code
to use
Sceneform
fragment
rather than
Camera-
ConnectionFra
gment
Bust your
head
Build with Bazel
This smooths
object
detection,
improves
tracking on
recognized
entities
Build
More
Add AR code
Hit test the
bounding box
and draw the
3D model
relative to that
point
Finish
Profit!
Or, fix
problems and
build your own
TFLite model
Pitfalls of AI + AR
Battery Life
A Pitfall of AI + AR
“Turn your phone
into an incendiary
device!
Run AI & AR at the
same time.”
Throttling AI is key.
NH GDG
DevFest
Depth & size of object
Another Pitfall of AI + AR
Projecting 3D object in AR requires good understanding of 3D space:
●Size of object, in pixels,
proportional to the camera
●Size of object, in real life,
to position 3D object correctly
●Positioning 3D object visible
to user without maneuvering
●Improvement: Correlate bounding box with hit detection
NH GDG
DevFest
Sensor drift
Yet Another Pitfall of AI + AR
Object out of the viewport?
●AR relies on point clouds, hardware sensors
●Hardware sensors likely to drift with lots of motion
●Objects anchored to world space likely to wander off
Solution?
●Ensure scene has good contrast, enough corners to see every
frame
●Attach objects to anchors
●Scan enough of the scene ahead of time before drawing AR
NH GDG
DevFest
Tracking Multiple Objects
And Yet Another Pitfall of AI + AR
●Object detections could be missed, false, or switch IDs
●Discover correlations between objects moving on camera
○Pairwise dependencies
○Uniform or non-uniform hypergraph
●Multiple object tracking is easier with the tensorflowlite_demo library
●No library? Gotta code it yourself!
Mitigating This
●Consumption issues? Minimize anchors as you instantiate objects
●Take the time to set up NDK and/or libraries
Building Your Model
NH GDG
DevFest
●Garbage in, garbage out
● Need at least 100 samples per category
○ Kaggle
○ Record your own videos
● Keras imagedatagenerator
● Label your own bounding boxes
Collecting Data
NH GDG
DevFest
Building Your Model
Tensorflow Cloud AutoML +
Firebase
NH GDG
DevFest
●tflite_convert binary available in Github code
○ Convert a GraphDef
○ Convert a SavedModel
○ Convert a Keras model
● Or, use AutoML Vision Object Detection Beta
○ AutoML Vision Edge in ML Kit - Export to Android using Firebase
○ Models in this form are quantized - i.e. ints, not floats
○ Small, edge device compatible; may lose accuracy
Converting Your Model
Thank You!
ML Summit ‘19
#MLSummit
@SWebCEO
goshtastic.blogspot.com
github.com/mrcity/mlworkshop
Slideshare: StephenWylie3

Más contenido relacionado

Similar a Fusing AI With AR for Android - 9/28/2019

TensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleTensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleIsrael Blancas
 
3D Programming Basics: WebGL
3D Programming Basics: WebGL3D Programming Basics: WebGL
3D Programming Basics: WebGLGlobant
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
The 10 Commandments For The Eager Developer
The 10 Commandments For The Eager DeveloperThe 10 Commandments For The Eager Developer
The 10 Commandments For The Eager DeveloperTsvika Kleinman
 
Nodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNicola Del Gobbo
 
Hack'n Break Android Workshop
Hack'n Break Android WorkshopHack'n Break Android Workshop
Hack'n Break Android WorkshopElif Boncuk
 
Tooling Matters - Development tools
Tooling Matters - Development toolsTooling Matters - Development tools
Tooling Matters - Development toolsSimon Dittlmann
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneursRodrigo Gil
 
sdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_publicsdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_publicRick Lau
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.jsDmytro Ovcharenko
 
Building Kick Ass Video Games for the Cloud
Building Kick Ass Video Games for the CloudBuilding Kick Ass Video Games for the Cloud
Building Kick Ass Video Games for the CloudChris Schalk
 
Android Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveAndroid Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveSebastian Vieira
 
Bdd agile requirements
Bdd agile requirementsBdd agile requirements
Bdd agile requirementsAgile Vietnam
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTWaqqas Jabbar
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Androidnatdefreitas
 
From Cardboard to Daydream - The Evolution of VR on Android
From Cardboard to Daydream - The Evolution of VR on AndroidFrom Cardboard to Daydream - The Evolution of VR on Android
From Cardboard to Daydream - The Evolution of VR on AndroidOscar Salguero
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloudwesley chun
 
Interfaces of the future now available augmented reality - google glass - 3...
Interfaces of the future now available   augmented reality - google glass - 3...Interfaces of the future now available   augmented reality - google glass - 3...
Interfaces of the future now available augmented reality - google glass - 3...CuriousInventor
 

Similar a Fusing AI With AR for Android - 9/28/2019 (20)

TensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleTensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de Google
 
3D Programming Basics: WebGL
3D Programming Basics: WebGL3D Programming Basics: WebGL
3D Programming Basics: WebGL
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Gradle by Example
Gradle by ExampleGradle by Example
Gradle by Example
 
The 10 Commandments For The Eager Developer
The 10 Commandments For The Eager DeveloperThe 10 Commandments For The Eager Developer
The 10 Commandments For The Eager Developer
 
Nodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to hero
 
Hack'n Break Android Workshop
Hack'n Break Android WorkshopHack'n Break Android Workshop
Hack'n Break Android Workshop
 
Tooling Matters - Development tools
Tooling Matters - Development toolsTooling Matters - Development tools
Tooling Matters - Development tools
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneurs
 
Spark core intro
Spark core introSpark core intro
Spark core intro
 
sdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_publicsdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_public
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Building Kick Ass Video Games for the Cloud
Building Kick Ass Video Games for the CloudBuilding Kick Ass Video Games for the Cloud
Building Kick Ass Video Games for the Cloud
 
Android Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveAndroid Lollipop: The developer's perspective
Android Lollipop: The developer's perspective
 
Bdd agile requirements
Bdd agile requirementsBdd agile requirements
Bdd agile requirements
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUST
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
From Cardboard to Daydream - The Evolution of VR on Android
From Cardboard to Daydream - The Evolution of VR on AndroidFrom Cardboard to Daydream - The Evolution of VR on Android
From Cardboard to Daydream - The Evolution of VR on Android
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloud
 
Interfaces of the future now available augmented reality - google glass - 3...
Interfaces of the future now available   augmented reality - google glass - 3...Interfaces of the future now available   augmented reality - google glass - 3...
Interfaces of the future now available augmented reality - google glass - 3...
 

Último

A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 

Último (20)

A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 

Fusing AI With AR for Android - 9/28/2019

  • 1. Stephen Wylie GDG Dallas @SWebCEO Fusing AI with AR NH GDG DevFest 9/28/2019
  • 2. NH GDG DevFest ●GDE in Machine Learning ●Software Engineer @ rewardStyle ●Fix old arcade machines & computers, and pinballs of all eras ●Love fancy men’s clothing & vintage TV game shows ●Lots of patents in this area About Me
  • 3. AI + AR: Does anyone do this themselves?
  • 4. NH GDG DevFest Sports ● Homecourt- Practice basketball, get coaching ● MLB - ID players, show stats AI + AR: Does anyone do this themselves? Yes, of course! But with help... APIs & Frameworks Are Your Friends! Retail ● Burberry - Customize items, detect counterfeits ● Cup Noodles - Turn cups into musical instruments ● Wayfair, IKEA - Preview items in your own house Vehicle Recognition & Auto Loans ● Blippar - AR/VR company ● Capital One - AR feature of Auto Navigator ● USAA - Loans & insurance
  • 6. Key Terms In AI ● MobileNet, SqueezeNet, Inception, ResNet Neural networks optimized for computer vision tasks ● Tensorflow Lite Inference engine optimized to run .tflite models on mobile devices ● MLKit APIs that enable specific Machine Learning use cases on devices or cloud In AR ● ARCore Cross-platform augmented reality SDK using OpenGL for motion tracking, scene building ● Sceneform AR SDK for Android saving you from learning OpenGL
  • 8. Establish your Android app Preparation Install prereqs Install latest versions of APIs, SDKs, IDEs, and build tools Preparation Clone repo Get Tensorflow source from Docker, Github, etc. Understand & Build Open app code Edit app code to use Sceneform fragment rather than Camera- ConnectionFra gment Bust your head Build with Bazel This smooths object detection, improves tracking on recognized entities Build More Add AR code Hit test the bounding box and draw the 3D model relative to that point Finish Profit! Or, fix problems and build your own TFLite model
  • 9. NH GDG DevFest ●Latest: ●Java JDK 10 (not 11, not 8) ●Building in Windows? You’ll need ~5GB worth of: ○Visual C++ Build Tools - visualcppbuildtools_full.exe ■Windows 10 SDK 10.0.10240 ■.NET Framework SDK ○A real shell like MSYS2 ●Pick your poison! Download Tensorflow source from GitHub or Docker Install Prerequisites ●Android Studio ●Android API level ●Android NDK ●Gradle ●Bazel
  • 10. Establish your Android app Preparation Install prereqs Install latest versions of APIs, SDKs, IDEs, and build tools Preparation Clone repo Get Tensorflow source from Docker, Github, etc. Understand & Build Open app code Edit app code to use Sceneform fragment rather than Camera- ConnectionFra gment Bust your head Build with Bazel This smooths object detection, improves tracking on recognized entities Build More Add AR code Hit test the bounding box and draw the 3D model relative to that point Finish Profit! Or, fix problems and build your own TFLite model
  • 11. NH GDG DevFest Code root: tensorflow/tensorflow/lite/examples/android/app ●Consider copying to a different folder ●Add Sceneform dependencies to Gradle build ●Update Gradle build to latest Tools, API >= 26 ●Add AR permissions to Android Manifest ●Make new Layout incorporating ArFragment ●Use this Layout in your CameraActivity ○Or make it a separate class ○Update Manifest with new Activity ○Ensure DetectorActivity extends it Gradle downloads ML model assets Start Modifying Code
  • 13. Establish your Android app Preparation Install prereqs Install latest versions of APIs, SDKs, IDEs, and build tools Preparation Clone repo Get Tensorflow source from Docker, Github, etc. Understand & Build Open app code Edit app code to use Sceneform fragment rather than Camera- ConnectionFra gment Bust your head Build with Bazel This smooths object detection, improves tracking on recognized entities Build More Add AR code Hit test the bounding box and draw the 3D model relative to that point Finish Profit! Or, fix problems and build your own TFLite model
  • 14. NH GDG DevFest ●Define androidsdk and androidndk path in WORKSPACE ●Omit API level & build tools version ●cd to tensorflow/ ●Run bazel build //tensorflow/lite/examples/android:tflite_demo ●Funky Windows business ●Pray hard! Build with Bazel
  • 17. Establish your Android app Preparation Install prereqs Install latest versions of APIs, SDKs, IDEs, and build tools Preparation Clone repo Get Tensorflow source from Docker, Github, etc. Understand & Build Open app code Edit app code to use Sceneform fragment rather than Camera- ConnectionFra gment Bust your head Build with Bazel This smooths object detection, improves tracking on recognized entities Build More Add AR code Hit test the bounding box and draw the 3D model relative to that point Finish Profit! Or, fix problems and build your own TFLite model
  • 18. NH GDG DevFest ●Can’t use Bazel anymore ○Incorporate object detection model into src/main/jniLibs ○Set parameter for CPU architecture in Gradle ●Sceneform Plugin or Gradle Instruction ○Sceneform codelab calls for 1.4; Android Studio plugin is 1.6 ○Best to just use Gradle instructions to create SFB assets ●Add augmented reality code to MultiBoxTracker Add Augmented Reality Code
  • 20. Establish your Android app Preparation Install prereqs Install latest versions of APIs, SDKs, IDEs, and build tools Preparation Clone repo Get Tensorflow source from Docker, Github, etc. Understand & Build Open app code Edit app code to use Sceneform fragment rather than Camera- ConnectionFra gment Bust your head Build with Bazel This smooths object detection, improves tracking on recognized entities Build More Add AR code Hit test the bounding box and draw the 3D model relative to that point Finish Profit! Or, fix problems and build your own TFLite model
  • 22. Battery Life A Pitfall of AI + AR “Turn your phone into an incendiary device! Run AI & AR at the same time.” Throttling AI is key.
  • 23. NH GDG DevFest Depth & size of object Another Pitfall of AI + AR Projecting 3D object in AR requires good understanding of 3D space: ●Size of object, in pixels, proportional to the camera ●Size of object, in real life, to position 3D object correctly ●Positioning 3D object visible to user without maneuvering ●Improvement: Correlate bounding box with hit detection
  • 24. NH GDG DevFest Sensor drift Yet Another Pitfall of AI + AR Object out of the viewport? ●AR relies on point clouds, hardware sensors ●Hardware sensors likely to drift with lots of motion ●Objects anchored to world space likely to wander off Solution? ●Ensure scene has good contrast, enough corners to see every frame ●Attach objects to anchors ●Scan enough of the scene ahead of time before drawing AR
  • 25. NH GDG DevFest Tracking Multiple Objects And Yet Another Pitfall of AI + AR ●Object detections could be missed, false, or switch IDs ●Discover correlations between objects moving on camera ○Pairwise dependencies ○Uniform or non-uniform hypergraph ●Multiple object tracking is easier with the tensorflowlite_demo library ●No library? Gotta code it yourself! Mitigating This ●Consumption issues? Minimize anchors as you instantiate objects ●Take the time to set up NDK and/or libraries
  • 27. NH GDG DevFest ●Garbage in, garbage out ● Need at least 100 samples per category ○ Kaggle ○ Record your own videos ● Keras imagedatagenerator ● Label your own bounding boxes Collecting Data
  • 28. NH GDG DevFest Building Your Model Tensorflow Cloud AutoML + Firebase
  • 29. NH GDG DevFest ●tflite_convert binary available in Github code ○ Convert a GraphDef ○ Convert a SavedModel ○ Convert a Keras model ● Or, use AutoML Vision Object Detection Beta ○ AutoML Vision Edge in ML Kit - Export to Android using Firebase ○ Models in this form are quantized - i.e. ints, not floats ○ Small, edge device compatible; may lose accuracy Converting Your Model
  • 30. Thank You! ML Summit ‘19 #MLSummit @SWebCEO goshtastic.blogspot.com github.com/mrcity/mlworkshop Slideshare: StephenWylie3