SlideShare a Scribd company logo
1 of 52
Download to read offline
Inteligencia Artificial para Android:
cómo empezar
Hello!
I am Isabel Palomar
2
Agenda
● Challenges and Initial ideas
● Main Deep Learning concepts
● Ok, but, what about Android?
… that’s all
3
��
1.
CHALLENGES AND INITIAL IDEAS
Getting started with Machine Learning and Android
Production-ready for common use cases
5
I want to create a
custom model
HOW?
6
“
77
@jeremyphoward
@math_rachel
I started a Deep Learning
Course 8 months ago at the
University of San Francisco.
💃 MY STORY: TAKING MY FIRST DEEP LEARNING CLASS
8
🤯 After the class…..
The key outcome of this lesson is that we'll have trained an
image classifier which can recognize pet breeds at state of
the art accuracy. The key to this success is the use of
transfer learning, which will be a key platform for much of
this course.
We also discuss how to set the most important
hyper-parameter when training neural networks:
the learning rate, using Leslie Smith's fantastic learning rate
finder method. Finally, we'll look at the important but rarely
discussed topic of labeling, and learn about some of the
features that fastai provides for allowing you to easily add
labels to your images. https://course.fast.ai/videos/?lesson=1
challenges….
‐ Many courses, even basic, assume that
you already know the subject.
‐ Reaching the final result without
learning the basics is not good.
‐
9
“When you are starting to learn about
Deep Learning it seems that there
are thousands of concepts,
mathematical functions and
scientific articles that you have to
read.
10
myths
2.
Main DEEP LEARNING CONCEPTS
Let’s understand the general concepts first
MACHINE LEARNING CONCEPTS
Data Task Model
12
Loss Function Learning Algorithm Evaluation
Place your screenshot here
13
Cat or dog?
1.- dATA
Data is distinct pieces of information which
acts as a fuel
14
Formats
Data can come in different formats depending on what you
want to solve
15
DATA FOR OUR example
16
How? Where do we get data from?
Data curation is the organization and integration
of data collected from various sources.
17
Techniques
You can use techniques like Questionnaires and surveys,
conducting interviews, using data scraping and data
crawling techniques.
Public datasets
● Google AI
● UCI ML Repository
● Data.gov.in
● Kaggle
Where do we get data from?
Crowdsourcing
Marketplaces
● Amazon Mechanical
Turk
● Dataturks
● Figure-eight
18
BACK TO OUR EXAMPLE...
Kaggle
● https://www.kaggle.com/c/dogs-vs-cats/
● https://forums.fast.ai/t/tips-for-building-large-image-datasets/26688
19
2.- task
The problem to resolve
20
Examples of tasks
21
TASK FOR OUR EXAMPLE
22
Identify if it is a
Cat or a Dog
Image classification
A common use of machine learning is to identify
what an image represents.
The task of predicting what
an image represents is called
image classification.
23
3.- model
The mathematical formulation of a task.
24
models
25
There are many models that are created over
the years.
Each model has its own advantages and
disadvantages based on the type of data on
which we are creating a model.
IMAGE CLASSIFICATION MODEL
An image classification model is trained to recognize various
classes of images.
26
When we subsequently
provide a new image as input
to the model, it will output the
probabilities of the image
representing each of the
types it was trained on.
An example output might be as follows:
Type Probability
Cat 0.01
Dog 0.99
27
Based on the output, we can see that
the classification model has predicted
that the image has a high probability
of representing a Dog
In this example, we will retrain a
MobileNet. MobileNet is a a small efficient
convolutional neural network.
https://ai.googleblog.com/2017/06/mobilenets-open-source-models-for.html
Model for our example
28
Retraining the mobileNet model
29
We use MobileNet model and retrain it.
python3 -m scripts.retrain
--bottleneck_dir=tf_files/bottlenecks
--model_dir=tf_files/models/"${ARCHITECTURE}"
--summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}"
--output_graph=tf_files/retrained_graph.pb
--output_labels=tf_files/retrained_labels.txt
--architecture="${ARCHITECTURE}"
--image_dir=tf_files/beer_photos
IMAGE_SIZE=224
ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}"
tHE RESULT...
USING THE RETRAINED MODEL
3030
Evaluation time (1-image): 0.250s
cat (score=0.99956)
dog (score=0.00043)
python3 -m scripts.label_image
--graph=tf_files/retrained_graph.pb
--image=tf_files/cat_dogs_photos/cat/"1.cat.jpg"
4.- loss function
How do we know which model is better?
Loss function (also known as the error)
answers this question.
31
5.- learning algorithm
The Learning Algorithms also known as
Optimization algorithms helps us to minimize
Error
32
Is something you do everyday...
You are optimizing
variables and basing your
personal decisions all day
long, most of the time
without even recognizing
the process consciously
https://mitsloan.mit.edu/ideas-made-to-matter/how-to-use
-algorithms-to-solve-everyday-problems
33
6.- evaluation
To compute a score for our ML model, we
need to evaluate it.
34
DEEP LEARNING CONCEPTS
Data Task Model
35
Loss Function Learning Algorithm Evaluation
3.
OKAY, BUT WHAT ABOUT ANDROID?
How to use our model in my app
MACHINE LEARNING IN YOUR APPS
● ML Kit For Firebase
● Core ML (Apple)
● TensorFlow Lite
● Cloud-based web services
● Your own service
Place your screenshot here
37
TENSORFLOW LITE
TensorFlow Lite is an open
source deep learning
framework for on-device
inference.
38
USING THE RETRAINED MODEL
3939
Evaluation time (1-image): 0.250s
cat (score=0.99956)
dog (score=0.00043)
python3 -m scripts.label_image
--graph=tf_files/retrained_graph.pb
--image=tf_files/cat_dogs_photos/cat/"1.cat.jpg"
TENSORFLOW LITE
40
TensorFlow Lite is a set of tools to
help developers run TensorFlow
models on mobile, embedded, and
IoT devices.
● TensorFlow Lite converter
● TensorFlow Lite interpreter
TensorFlow Lite converter
Converts TensorFlow models into
an efficient form for use by the
interpreter
Command line: tflite_convert
Starting from TensorFlow
1.9, the command-line tool
tflite_convert is installed as
part of the Python package.
41
pip install --upgrade "tensorflow==1.9.*"
Using TFLite Converter
42
Output:IMAGE_SIZE=224
tflite_convert 
--graph_def_file=tf_files/retrained_graph.pb 
--output_file=tf_files/optimized_graph.lite 
--input_format=TENSORFLOW_GRAPHDEF 
--output_format=TFLITE 
--input_shape=1,${IMAGE_SIZE},${IMAGE_SIZE},3 
--input_array=input 
--output_array=final_result 
--inference_type=FLOAT 
--input_data_type=FLOAT
recap
43
?
Required files
44
Optimized graph
cp tf_files/optimized_graph.lite android/tflite/app/src/main/assets/graph.lite
cp tf_files/retrained_labels.txt android/tflite/app/src/main/assets/labels.txt
Labels
repositories {
maven {
url 'https://google.bintray.com/tensorflow'
}
}
dependencies {
// ...
compile 'org.tensorflow:tensorflow-lite:+'
}
TensorFlow Lite interpreter
45
android {
aaptOptions {
noCompress "tflite"
noCompress "lite"
}
}
The TensorFlow Lite
interpreter is designed to be
lean and fast. The interpreter
uses a static graph ordering
and a custom (less-dynamic)
memory allocator to ensure
minimal load, initialization, and
execution latency.
dependencies
settings
Load model and create interpreter
protected Classifier… {
tfliteOptions.setNumThreads(numThreads);
tflite = new Interpreter(tfliteModel, tfliteOptions);
labels = loadLabelList(activity);
...
}
46
// Name of the model file stored in Assets.
private static final String MODEL_PATH = "graph.lite";
// Name of the label file stored in Assets.
private static final String LABEL_PATH = "labels.txt";
Dog: 1.00
cAMERA, Read the labels…..
47
https://developer.android.com/training/camerax
// Convert the image to bytes
convertBitmapToByteBuffer(bitmap);
// An array to hold inference results, to be feed
into Tensorflow Lite as outputs.
PriorityQueue<Map.Entry<String, Float>> sortedLabels =
new PriorityQueue<>(
RESULTS_TO_SHOW,
(element1, element2) ->
(element1.getValue()).compareTo(element2.getValue()));
Show the results
48
// Get the results
textToShow = String.format("n%s: %4.2f", label.getKey(),
label.getValue())
// Label (In this case PARAMO)
label.getKey()
// Value (In this case 1.0)
label.getValue()
cat (score=0.00000)
dog (score=1.00000)
Dog: 1.00
We did it!
49
Place your screenshot here
Common apps using artificial intelligence
50
Call to action!
Now you are ready to
start creating your first
applications using
Artificial Intelligence
51
52
THANKS!
You can find me at @isabelpalomar

More Related Content

Similar to Inteligencia artificial para android como empezar

"Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St..."Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St...Stefan Krawczyk
 
Google Big Data Expo
Google Big Data ExpoGoogle Big Data Expo
Google Big Data ExpoBigDataExpo
 
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLR
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLRMACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLR
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLRDrupalCamp Kyiv
 
Design Patterns - The Ultimate Blueprint for Software
Design Patterns - The Ultimate Blueprint for SoftwareDesign Patterns - The Ultimate Blueprint for Software
Design Patterns - The Ultimate Blueprint for SoftwareEdureka!
 
Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)wesley chun
 
Machine Learning for .NET Developers - ADC21
Machine Learning for .NET Developers - ADC21Machine Learning for .NET Developers - ADC21
Machine Learning for .NET Developers - ADC21Gülden Bilgütay
 
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)wesley chun
 
OpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyOpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyGanesan Narayanasamy
 
Deep Learning using Tensorflow and Data Science Experience
Deep Learning using Tensorflow and Data Science ExperienceDeep Learning using Tensorflow and Data Science Experience
Deep Learning using Tensorflow and Data Science ExperienceRoy Cecil
 
Andrew NG machine learning
Andrew NG machine learningAndrew NG machine learning
Andrew NG machine learningShareDocView.com
 
How to implement artificial intelligence solutions
How to implement artificial intelligence solutionsHow to implement artificial intelligence solutions
How to implement artificial intelligence solutionsCarlos Toxtli
 
Webinar: Design Patterns : Tailor-made solutions for Software Development
Webinar: Design Patterns : Tailor-made solutions for Software DevelopmentWebinar: Design Patterns : Tailor-made solutions for Software Development
Webinar: Design Patterns : Tailor-made solutions for Software DevelopmentEdureka!
 
Introduction Machine Learning by MyLittleAdventure
Introduction Machine Learning by MyLittleAdventureIntroduction Machine Learning by MyLittleAdventure
Introduction Machine Learning by MyLittleAdventuremylittleadventure
 
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...Dataconomy Media
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine LearningValéry BERNARD
 
Informatica Online Training
Informatica Online Training Informatica Online Training
Informatica Online Training saikirancrs
 

Similar to Inteligencia artificial para android como empezar (20)

"Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St..."Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St...
 
Google Big Data Expo
Google Big Data ExpoGoogle Big Data Expo
Google Big Data Expo
 
S2 NIGHT SKILL.pptx
S2 NIGHT SKILL.pptxS2 NIGHT SKILL.pptx
S2 NIGHT SKILL.pptx
 
S2 NIGHT SKILL.pptx
S2 NIGHT SKILL.pptxS2 NIGHT SKILL.pptx
S2 NIGHT SKILL.pptx
 
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLR
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLRMACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLR
MACHINE LEARNING FOR OPTIMIZING SEARCH RESULTS WITH DRUPAL & APACHE SOLR
 
Design Patterns - The Ultimate Blueprint for Software
Design Patterns - The Ultimate Blueprint for SoftwareDesign Patterns - The Ultimate Blueprint for Software
Design Patterns - The Ultimate Blueprint for Software
 
Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)
 
Machine Learning for .NET Developers - ADC21
Machine Learning for .NET Developers - ADC21Machine Learning for .NET Developers - ADC21
Machine Learning for .NET Developers - ADC21
 
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
 
OpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyOpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon Valley
 
Deep Learning using Tensorflow and Data Science Experience
Deep Learning using Tensorflow and Data Science ExperienceDeep Learning using Tensorflow and Data Science Experience
Deep Learning using Tensorflow and Data Science Experience
 
Andrew NG machine learning
Andrew NG machine learningAndrew NG machine learning
Andrew NG machine learning
 
How to implement artificial intelligence solutions
How to implement artificial intelligence solutionsHow to implement artificial intelligence solutions
How to implement artificial intelligence solutions
 
Webinar: Design Patterns : Tailor-made solutions for Software Development
Webinar: Design Patterns : Tailor-made solutions for Software DevelopmentWebinar: Design Patterns : Tailor-made solutions for Software Development
Webinar: Design Patterns : Tailor-made solutions for Software Development
 
Lecture-6-7.pptx
Lecture-6-7.pptxLecture-6-7.pptx
Lecture-6-7.pptx
 
Introduction Machine Learning by MyLittleAdventure
Introduction Machine Learning by MyLittleAdventureIntroduction Machine Learning by MyLittleAdventure
Introduction Machine Learning by MyLittleAdventure
 
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
 
On-device ML with TFLite
On-device ML with TFLiteOn-device ML with TFLite
On-device ML with TFLite
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine Learning
 
Informatica Online Training
Informatica Online Training Informatica Online Training
Informatica Online Training
 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Inteligencia artificial para android como empezar

  • 1. Inteligencia Artificial para Android: cómo empezar
  • 2. Hello! I am Isabel Palomar 2
  • 3. Agenda ● Challenges and Initial ideas ● Main Deep Learning concepts ● Ok, but, what about Android? … that’s all 3 ��
  • 4. 1. CHALLENGES AND INITIAL IDEAS Getting started with Machine Learning and Android
  • 6. I want to create a custom model HOW? 6
  • 7. “ 77 @jeremyphoward @math_rachel I started a Deep Learning Course 8 months ago at the University of San Francisco. 💃 MY STORY: TAKING MY FIRST DEEP LEARNING CLASS
  • 8. 8 🤯 After the class….. The key outcome of this lesson is that we'll have trained an image classifier which can recognize pet breeds at state of the art accuracy. The key to this success is the use of transfer learning, which will be a key platform for much of this course. We also discuss how to set the most important hyper-parameter when training neural networks: the learning rate, using Leslie Smith's fantastic learning rate finder method. Finally, we'll look at the important but rarely discussed topic of labeling, and learn about some of the features that fastai provides for allowing you to easily add labels to your images. https://course.fast.ai/videos/?lesson=1
  • 9. challenges…. ‐ Many courses, even basic, assume that you already know the subject. ‐ Reaching the final result without learning the basics is not good. ‐ 9
  • 10. “When you are starting to learn about Deep Learning it seems that there are thousands of concepts, mathematical functions and scientific articles that you have to read. 10 myths
  • 11. 2. Main DEEP LEARNING CONCEPTS Let’s understand the general concepts first
  • 12. MACHINE LEARNING CONCEPTS Data Task Model 12 Loss Function Learning Algorithm Evaluation
  • 13. Place your screenshot here 13 Cat or dog?
  • 14. 1.- dATA Data is distinct pieces of information which acts as a fuel 14
  • 15. Formats Data can come in different formats depending on what you want to solve 15
  • 16. DATA FOR OUR example 16
  • 17. How? Where do we get data from? Data curation is the organization and integration of data collected from various sources. 17 Techniques You can use techniques like Questionnaires and surveys, conducting interviews, using data scraping and data crawling techniques.
  • 18. Public datasets ● Google AI ● UCI ML Repository ● Data.gov.in ● Kaggle Where do we get data from? Crowdsourcing Marketplaces ● Amazon Mechanical Turk ● Dataturks ● Figure-eight 18
  • 19. BACK TO OUR EXAMPLE... Kaggle ● https://www.kaggle.com/c/dogs-vs-cats/ ● https://forums.fast.ai/t/tips-for-building-large-image-datasets/26688 19
  • 20. 2.- task The problem to resolve 20
  • 22. TASK FOR OUR EXAMPLE 22 Identify if it is a Cat or a Dog
  • 23. Image classification A common use of machine learning is to identify what an image represents. The task of predicting what an image represents is called image classification. 23
  • 24. 3.- model The mathematical formulation of a task. 24
  • 25. models 25 There are many models that are created over the years. Each model has its own advantages and disadvantages based on the type of data on which we are creating a model.
  • 26. IMAGE CLASSIFICATION MODEL An image classification model is trained to recognize various classes of images. 26 When we subsequently provide a new image as input to the model, it will output the probabilities of the image representing each of the types it was trained on.
  • 27. An example output might be as follows: Type Probability Cat 0.01 Dog 0.99 27 Based on the output, we can see that the classification model has predicted that the image has a high probability of representing a Dog
  • 28. In this example, we will retrain a MobileNet. MobileNet is a a small efficient convolutional neural network. https://ai.googleblog.com/2017/06/mobilenets-open-source-models-for.html Model for our example 28
  • 29. Retraining the mobileNet model 29 We use MobileNet model and retrain it. python3 -m scripts.retrain --bottleneck_dir=tf_files/bottlenecks --model_dir=tf_files/models/"${ARCHITECTURE}" --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}" --output_graph=tf_files/retrained_graph.pb --output_labels=tf_files/retrained_labels.txt --architecture="${ARCHITECTURE}" --image_dir=tf_files/beer_photos IMAGE_SIZE=224 ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}" tHE RESULT...
  • 30. USING THE RETRAINED MODEL 3030 Evaluation time (1-image): 0.250s cat (score=0.99956) dog (score=0.00043) python3 -m scripts.label_image --graph=tf_files/retrained_graph.pb --image=tf_files/cat_dogs_photos/cat/"1.cat.jpg"
  • 31. 4.- loss function How do we know which model is better? Loss function (also known as the error) answers this question. 31
  • 32. 5.- learning algorithm The Learning Algorithms also known as Optimization algorithms helps us to minimize Error 32
  • 33. Is something you do everyday... You are optimizing variables and basing your personal decisions all day long, most of the time without even recognizing the process consciously https://mitsloan.mit.edu/ideas-made-to-matter/how-to-use -algorithms-to-solve-everyday-problems 33
  • 34. 6.- evaluation To compute a score for our ML model, we need to evaluate it. 34
  • 35. DEEP LEARNING CONCEPTS Data Task Model 35 Loss Function Learning Algorithm Evaluation
  • 36. 3. OKAY, BUT WHAT ABOUT ANDROID? How to use our model in my app
  • 37. MACHINE LEARNING IN YOUR APPS ● ML Kit For Firebase ● Core ML (Apple) ● TensorFlow Lite ● Cloud-based web services ● Your own service Place your screenshot here 37
  • 38. TENSORFLOW LITE TensorFlow Lite is an open source deep learning framework for on-device inference. 38
  • 39. USING THE RETRAINED MODEL 3939 Evaluation time (1-image): 0.250s cat (score=0.99956) dog (score=0.00043) python3 -m scripts.label_image --graph=tf_files/retrained_graph.pb --image=tf_files/cat_dogs_photos/cat/"1.cat.jpg"
  • 40. TENSORFLOW LITE 40 TensorFlow Lite is a set of tools to help developers run TensorFlow models on mobile, embedded, and IoT devices. ● TensorFlow Lite converter ● TensorFlow Lite interpreter TensorFlow Lite converter Converts TensorFlow models into an efficient form for use by the interpreter
  • 41. Command line: tflite_convert Starting from TensorFlow 1.9, the command-line tool tflite_convert is installed as part of the Python package. 41 pip install --upgrade "tensorflow==1.9.*"
  • 42. Using TFLite Converter 42 Output:IMAGE_SIZE=224 tflite_convert --graph_def_file=tf_files/retrained_graph.pb --output_file=tf_files/optimized_graph.lite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --input_shape=1,${IMAGE_SIZE},${IMAGE_SIZE},3 --input_array=input --output_array=final_result --inference_type=FLOAT --input_data_type=FLOAT
  • 44. Required files 44 Optimized graph cp tf_files/optimized_graph.lite android/tflite/app/src/main/assets/graph.lite cp tf_files/retrained_labels.txt android/tflite/app/src/main/assets/labels.txt Labels
  • 45. repositories { maven { url 'https://google.bintray.com/tensorflow' } } dependencies { // ... compile 'org.tensorflow:tensorflow-lite:+' } TensorFlow Lite interpreter 45 android { aaptOptions { noCompress "tflite" noCompress "lite" } } The TensorFlow Lite interpreter is designed to be lean and fast. The interpreter uses a static graph ordering and a custom (less-dynamic) memory allocator to ensure minimal load, initialization, and execution latency. dependencies settings
  • 46. Load model and create interpreter protected Classifier… { tfliteOptions.setNumThreads(numThreads); tflite = new Interpreter(tfliteModel, tfliteOptions); labels = loadLabelList(activity); ... } 46 // Name of the model file stored in Assets. private static final String MODEL_PATH = "graph.lite"; // Name of the label file stored in Assets. private static final String LABEL_PATH = "labels.txt"; Dog: 1.00
  • 47. cAMERA, Read the labels….. 47 https://developer.android.com/training/camerax // Convert the image to bytes convertBitmapToByteBuffer(bitmap); // An array to hold inference results, to be feed into Tensorflow Lite as outputs. PriorityQueue<Map.Entry<String, Float>> sortedLabels = new PriorityQueue<>( RESULTS_TO_SHOW, (element1, element2) -> (element1.getValue()).compareTo(element2.getValue()));
  • 48. Show the results 48 // Get the results textToShow = String.format("n%s: %4.2f", label.getKey(), label.getValue()) // Label (In this case PARAMO) label.getKey() // Value (In this case 1.0) label.getValue() cat (score=0.00000) dog (score=1.00000) Dog: 1.00
  • 49. We did it! 49 Place your screenshot here
  • 50. Common apps using artificial intelligence 50
  • 51. Call to action! Now you are ready to start creating your first applications using Artificial Intelligence 51
  • 52. 52 THANKS! You can find me at @isabelpalomar