SlideShare a Scribd company logo
Husam Aamer
from
Image Recognition
Applications & Dataset Preparation
Did you see this before ?
•Cover violence or
nudity images
facebook app
AppChief
Did you see this before ?
•Suggests sharing
photos with
recognized facebook
friends
Moments app
AppChief
Did you see this before ?
•Search for photo
content in iOS and
Android
Photos
AppChief
Did you see this before ?
•Cutting out a person
from an image
Sticky app
Did you see this before ?
What is image recognition ?
How to build my own app ?
Why I need it ?
Is the ability of software to identify objects, places, people, writing and
actions in images.
labeling the content of images with meta-tags, performing image content
search and guiding autonomous robots, self-driving cars and accident
avoidance systems…etc
Next slides
How to build my own app ?
TRAIN THE MODEL
PREPARE DATASET
BUILD AND RUN
…
…
What do you need ?
PREPARE DATASET
Classify image ? Detect multiple objects
inside image ?
or
Image recognition types
&
IMAGE
CLASSIFICATION
OBJECT
DETECTION
PREPARE DATASET
vs
OBJECT
DETECTION
input
output
Image Image
Class labelsClass label
OBJECT
DETECTION
INSTANCE
SEGMENTATION
types
+
bounding box
+
bounding boxes
+
segmentation
PREPARE DATASET
Image recognition types
-
IMAGE
CLASSIFICATION
CLASSIFICATION
CLASSIFICATION
+ LOCALIZATION
vs
IMAGE
CLASSIFICATION
OBJECT
DETECTION
CLASSIFICATION
CLASSIFICATION
+ LOCALIZATION
OBJECT
DETECTION
INSTANCE
SEGMENTATION
types
PREPARE DATASET
Image recognition types
Example
vs
IMAGE
CLASSIFICATION
OBJECT
DETECTION
CLASSIFICATION
CLASSIFICATION
+ LOCALIZATION
OBJECT
DETECTION
INSTANCE
SEGMENTATION
types
PREPARE DATASET
Image recognition types
WE
WILL
CONTINUE
WITH
OBJECT
DETECTION
Let’s create a money reader model
STEP 1. Naming objects (Object labels)
PREPARE DATASET / OBJECT DETECTION
1 IQD_50000_ar
3 IQD_25000_ar
5 IQD_10000_ar
7 IQD_5000_ar
9 IQD_1000_ar
11 IQD_500_ar
13 IQD_250_ar
2 IQD_50000_en
4 IQD_25000_en
6 IQD_10000_en
8 IQD_5000_en
10 IQD_1000_en
12 IQD_500_en
14 IQD_250_en
Let’s create a money reader model
STEP 2. Take photos for each money face AS MUCH AS YO CAN
PREPARE DATASET / OBJECT DETECTION
For better accuracy take hundreds of photos with
• Different backgrounds

• Different positions

• Different light conditions

• Different orientations
Let’s create a money reader model
PREPARE DATASET / OBJECT DETECTION
• Different backgrounds

• Different positions

• Different light conditions

• Different orientations
STEP 2. Take photos for each money face AS MUCH AS YO CAN
STEP 2. Take photos for each money face AS MUCH AS YO CAN
Let’s create a money reader model
PREPARE DATASET / OBJECT DETECTION
Let’s create a money reader model
2. Take about 300 photos for each money face
PREPARE DATASET / OBJECT DETECTION
Let’s create a money reader model
2. Take about 300 photos for each money face
PREPARE DATASET / OBJECT DETECTION
Let’s create a money reader model
2. Take about 300 photos for each money face
PREPARE DATASET / OBJECT DETECTION
Let’s create a money reader model
STEP 3. Labeling objects inside images
PREPARE DATASET / OBJECT DETECTION
Label : IQD_50000_en
x : 6
y : 120
width : 150
heigh : 370
Objects :
Object #1
Let’s create a money reader model
STEP 3. Labeling objects inside images
PREPARE DATASET / OBJECT DETECTION
Label : IQD_50000_en
x : 90
y : 125
width : 313
heigh : 313
Objects :
Object #1
CAUTION : Some training libraries prefers different coordinates system in labeling
PREPARE DATASET / OBJECT DETECTION
X, Y, Width , Height midX, midY, Width , Height
minX, minY, maxX , maxY
It’s recommended to check the library needs you want to use for training before start labeling
How many photos do you think we need
for each label ?
PREPARE DATASET / OBJECT DETECTION
10 ?
20 ?
50 ?
100 ?
200 ?
300 ?
Assuming 300 photos
is good for our model
let’s calculate time required
PREPARE DATASET / OBJECT DETECTION
300 image x 14 Label x (5 sec) taking photo x (30 sec) labeling
175 hours !!! 7 Days !
We made a timesaving app
PREPARE DATASET / OBJECT DETECTION
Only 1 hour
300 image x 14 Label x (5 sec) taking photo x (60 sec) labeling
50 image x 14 Label x (5 sec) taking photo x (0 sec) labeling
PREPARE DATASET / OBJECT DETECTION
1 2 3Create labels Capture Generate
PREPARE DATASET / OBJECT DETECTION
3 Transfer
Easy Dataset
PREPARE DATASET / OBJECT DETECTION
Demo time
Easy Dataset
PREPARE DATASET / OBJECT DETECTION
Money Reader - ‫العملة‬ ‫قارئ‬
Final live app
Final dataset
kaggle.com/husamaamer/iraqi-currency-
~1 GB
Iraqi Money ‫العراقية‬ ‫العملة‬
Object detection dataset for Iraqi currency
MODEL TRAINING
import turicreate as tc
import os
# Define all images annotations with bounding box details (I am showing only 1)
annotations = tc.SArray([
[{
“label”:”5000ar",
“type":"rectangle",
“coordinates”:{“y":188.5,"x":207,"width":304,"height":152}
}],
… , … …
])
MODEL TRAINING
import turicreate as tc
import os
# Define all images annotations with bounding box details (I am showing only 1)
annotations = tc.SArray([
[{
“label”:”5000ar",
“type":"rectangle",
“coordinates”:{“y":188.5,"x":207,"width":304,"height":152}
}],
… , … …
])
# 1. Load images (Note: you can ignore 'Not a JPEG file' errors)
data = tc.image_analysis.load_images('mr_turi_ic', with_path=True)
data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path)))
data['annotations'] = tc.SArray(data=annotations, dtype=list)
MODEL TRAINING
import turicreate as tc
import os
# Define all images annotations with bounding box details (I am showing only 1)
annotations = tc.SArray([
[{
“label”:”5000ar",
“type":"rectangle",
“coordinates”:{“y":188.5,"x":207,"width":304,"height":152}
}],
… , … …
])
# 1. Load images (Note: you can ignore 'Not a JPEG file' errors)
data = tc.image_analysis.load_images('mr_turi_ic', with_path=True)
data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path)))
data['annotations'] = tc.SArray(data=annotations, dtype=list)
# Make a train-test split
train_data, test_data = data.random_split(0.8)
MODEL TRAINING
import turicreate as tc
import os
# Define all images annotations with bounding box details (I am showing only 1)
annotations = tc.SArray([
[{
“label”:”5000ar",
“type":"rectangle",
“coordinates”:{“y":188.5,"x":207,"width":304,"height":152}
}],
… , … …
])
# 1. Load images (Note: you can ignore 'Not a JPEG file' errors)
data = tc.image_analysis.load_images('mr_turi_ic', with_path=True)
data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path)))
data['annotations'] = tc.SArray(data=annotations, dtype=list)
# Make a train-test split
train_data, test_data = data.random_split(0.8)
# Create a model using Turi Create's object detector API
model = tc.object_detector.create(train_data, max_iterations=1000)
# Save the predictions to an SArray
predictions = model.predict(test_data)
# Evaluate the model and save the results into a dictionary
metrics = model.evaluate(test_data)
print('Precision' , metrics['mean_average_precision'])
MODEL TRAINING
import turicreate as tc
import os
# Define all images annotations with bounding box details (I am showing only 1)
annotations = tc.SArray([
[{
“label”:”5000ar",
“type":"rectangle",
“coordinates”:{“y":188.5,"x":207,"width":304,"height":152}
}],
… , … …
])
# 1. Load images (Note: you can ignore 'Not a JPEG file' errors)
data = tc.image_analysis.load_images('mr_turi_ic', with_path=True)
data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path)))
data['annotations'] = tc.SArray(data=annotations, dtype=list)
# Make a train-test split
train_data, test_data = data.random_split(0.8)
# Create a model using Turi Create's object detector API
model = tc.object_detector.create(train_data, max_iterations=1000)
# Save the predictions to an SArray
predictions = model.predict(test_data)
# Evaluate the model and save the results into a dictionary
metrics = model.evaluate(test_data)
print('Precision' , metrics['mean_average_precision'])
# Save the model for later use in Turi Create
model.save(‘turi_ic.model')
# Export for use in Core ML file to the current directory
model.export_coreml('turi_ic.mlmodel')
Thanks for listening,

More Related Content

PDF
Learning jQuery in 30 minutes
PDF
CDAT - graphics - vcs - xmgrace - Introduction
PDF
Unit testing UIView
PDF
D3.js and SVG
PDF
Introduction to jQuery
PPTX
jQuery Fundamentals
PDF
Learning jQuery made exciting in an interactive session by one of our team me...
PDF
Chaco Step-by-Step
Learning jQuery in 30 minutes
CDAT - graphics - vcs - xmgrace - Introduction
Unit testing UIView
D3.js and SVG
Introduction to jQuery
jQuery Fundamentals
Learning jQuery made exciting in an interactive session by one of our team me...
Chaco Step-by-Step

What's hot (11)

PDF
jQuery Essentials
PDF
Html5 canvas
PPT
J query
PPTX
J query1
PDF
HTML5 Canvas - The Future of Graphics on the Web
PDF
기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017
PPTX
jQuery
ODP
Introduction to jQuery
PPTX
Jquery
PPTX
jQuery
jQuery Essentials
Html5 canvas
J query
J query1
HTML5 Canvas - The Future of Graphics on the Web
기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017
jQuery
Introduction to jQuery
Jquery
jQuery
Ad

Similar to Image recognition applications and dataset preparation - DevFest Baghdad 2018 (20)

PPTX
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
PDF
Machine learning Exam.pdf
PDF
Data quality is more important than you think
PDF
Object and Currency Detection for the Visually Impaired
PPTX
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
PDF
Image Classification and Annotation Using Deep Learning
PDF
Extracting information from images using deep learning and transfer learning ...
PPTX
Fynd ml-2019-challenge-ppt
PPTX
CNN_INTRO.pptx
PDF
Currency Recognition using Machine Learning
PDF
An In-Depth Look at Image Annotation Methods for Computer Vision
PDF
Computer vision
PDF
Pragmatic deep learning for image labelling
PDF
maXbox starter75 object detection
PDF
Image Classification using Deep Learning
PPTX
3rd Seminar
PPTX
3rd Seminar
PPTX
Ai powered images-opieaivienna
PDF
Lausanne 2019 #2
PPTX
Validating credit cards on mobile using deep learning
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
Machine learning Exam.pdf
Data quality is more important than you think
Object and Currency Detection for the Visually Impaired
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
Image Classification and Annotation Using Deep Learning
Extracting information from images using deep learning and transfer learning ...
Fynd ml-2019-challenge-ppt
CNN_INTRO.pptx
Currency Recognition using Machine Learning
An In-Depth Look at Image Annotation Methods for Computer Vision
Computer vision
Pragmatic deep learning for image labelling
maXbox starter75 object detection
Image Classification using Deep Learning
3rd Seminar
3rd Seminar
Ai powered images-opieaivienna
Lausanne 2019 #2
Validating credit cards on mobile using deep learning
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Electronic commerce courselecture one. Pdf
PDF
Getting Started with Data Integration: FME Form 101
cuic standard and advanced reporting.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Programs and apps: productivity, graphics, security and other tools
Assigned Numbers - 2025 - Bluetooth® Document
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Mobile App Security Testing_ A Comprehensive Guide.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Electronic commerce courselecture one. Pdf
Getting Started with Data Integration: FME Form 101

Image recognition applications and dataset preparation - DevFest Baghdad 2018

  • 2. Image Recognition Applications & Dataset Preparation
  • 3. Did you see this before ? •Cover violence or nudity images facebook app AppChief
  • 4. Did you see this before ? •Suggests sharing photos with recognized facebook friends Moments app AppChief
  • 5. Did you see this before ? •Search for photo content in iOS and Android Photos AppChief
  • 6. Did you see this before ? •Cutting out a person from an image Sticky app
  • 7. Did you see this before ?
  • 8. What is image recognition ? How to build my own app ? Why I need it ? Is the ability of software to identify objects, places, people, writing and actions in images. labeling the content of images with meta-tags, performing image content search and guiding autonomous robots, self-driving cars and accident avoidance systems…etc Next slides
  • 9. How to build my own app ? TRAIN THE MODEL PREPARE DATASET BUILD AND RUN … …
  • 10. What do you need ? PREPARE DATASET Classify image ? Detect multiple objects inside image ? or
  • 12. vs OBJECT DETECTION input output Image Image Class labelsClass label OBJECT DETECTION INSTANCE SEGMENTATION types + bounding box + bounding boxes + segmentation PREPARE DATASET Image recognition types - IMAGE CLASSIFICATION CLASSIFICATION CLASSIFICATION + LOCALIZATION
  • 15. Let’s create a money reader model STEP 1. Naming objects (Object labels) PREPARE DATASET / OBJECT DETECTION 1 IQD_50000_ar 3 IQD_25000_ar 5 IQD_10000_ar 7 IQD_5000_ar 9 IQD_1000_ar 11 IQD_500_ar 13 IQD_250_ar 2 IQD_50000_en 4 IQD_25000_en 6 IQD_10000_en 8 IQD_5000_en 10 IQD_1000_en 12 IQD_500_en 14 IQD_250_en
  • 16. Let’s create a money reader model STEP 2. Take photos for each money face AS MUCH AS YO CAN PREPARE DATASET / OBJECT DETECTION For better accuracy take hundreds of photos with • Different backgrounds • Different positions • Different light conditions • Different orientations
  • 17. Let’s create a money reader model PREPARE DATASET / OBJECT DETECTION • Different backgrounds • Different positions • Different light conditions • Different orientations STEP 2. Take photos for each money face AS MUCH AS YO CAN
  • 18. STEP 2. Take photos for each money face AS MUCH AS YO CAN Let’s create a money reader model PREPARE DATASET / OBJECT DETECTION
  • 19. Let’s create a money reader model 2. Take about 300 photos for each money face PREPARE DATASET / OBJECT DETECTION
  • 20. Let’s create a money reader model 2. Take about 300 photos for each money face PREPARE DATASET / OBJECT DETECTION
  • 21. Let’s create a money reader model 2. Take about 300 photos for each money face PREPARE DATASET / OBJECT DETECTION
  • 22. Let’s create a money reader model STEP 3. Labeling objects inside images PREPARE DATASET / OBJECT DETECTION Label : IQD_50000_en x : 6 y : 120 width : 150 heigh : 370 Objects : Object #1
  • 23. Let’s create a money reader model STEP 3. Labeling objects inside images PREPARE DATASET / OBJECT DETECTION Label : IQD_50000_en x : 90 y : 125 width : 313 heigh : 313 Objects : Object #1
  • 24. CAUTION : Some training libraries prefers different coordinates system in labeling PREPARE DATASET / OBJECT DETECTION X, Y, Width , Height midX, midY, Width , Height minX, minY, maxX , maxY It’s recommended to check the library needs you want to use for training before start labeling
  • 25. How many photos do you think we need for each label ? PREPARE DATASET / OBJECT DETECTION 10 ? 20 ? 50 ? 100 ? 200 ? 300 ?
  • 26. Assuming 300 photos is good for our model let’s calculate time required PREPARE DATASET / OBJECT DETECTION 300 image x 14 Label x (5 sec) taking photo x (30 sec) labeling 175 hours !!! 7 Days !
  • 27. We made a timesaving app PREPARE DATASET / OBJECT DETECTION Only 1 hour 300 image x 14 Label x (5 sec) taking photo x (60 sec) labeling 50 image x 14 Label x (5 sec) taking photo x (0 sec) labeling
  • 28. PREPARE DATASET / OBJECT DETECTION 1 2 3Create labels Capture Generate
  • 29. PREPARE DATASET / OBJECT DETECTION 3 Transfer Easy Dataset
  • 30. PREPARE DATASET / OBJECT DETECTION Demo time Easy Dataset
  • 31. PREPARE DATASET / OBJECT DETECTION Money Reader - ‫العملة‬ ‫قارئ‬ Final live app Final dataset kaggle.com/husamaamer/iraqi-currency- ~1 GB Iraqi Money ‫العراقية‬ ‫العملة‬ Object detection dataset for Iraqi currency
  • 32. MODEL TRAINING import turicreate as tc import os # Define all images annotations with bounding box details (I am showing only 1) annotations = tc.SArray([ [{ “label”:”5000ar", “type":"rectangle", “coordinates”:{“y":188.5,"x":207,"width":304,"height":152} }], … , … … ])
  • 33. MODEL TRAINING import turicreate as tc import os # Define all images annotations with bounding box details (I am showing only 1) annotations = tc.SArray([ [{ “label”:”5000ar", “type":"rectangle", “coordinates”:{“y":188.5,"x":207,"width":304,"height":152} }], … , … … ]) # 1. Load images (Note: you can ignore 'Not a JPEG file' errors) data = tc.image_analysis.load_images('mr_turi_ic', with_path=True) data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path))) data['annotations'] = tc.SArray(data=annotations, dtype=list)
  • 34. MODEL TRAINING import turicreate as tc import os # Define all images annotations with bounding box details (I am showing only 1) annotations = tc.SArray([ [{ “label”:”5000ar", “type":"rectangle", “coordinates”:{“y":188.5,"x":207,"width":304,"height":152} }], … , … … ]) # 1. Load images (Note: you can ignore 'Not a JPEG file' errors) data = tc.image_analysis.load_images('mr_turi_ic', with_path=True) data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path))) data['annotations'] = tc.SArray(data=annotations, dtype=list) # Make a train-test split train_data, test_data = data.random_split(0.8)
  • 35. MODEL TRAINING import turicreate as tc import os # Define all images annotations with bounding box details (I am showing only 1) annotations = tc.SArray([ [{ “label”:”5000ar", “type":"rectangle", “coordinates”:{“y":188.5,"x":207,"width":304,"height":152} }], … , … … ]) # 1. Load images (Note: you can ignore 'Not a JPEG file' errors) data = tc.image_analysis.load_images('mr_turi_ic', with_path=True) data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path))) data['annotations'] = tc.SArray(data=annotations, dtype=list) # Make a train-test split train_data, test_data = data.random_split(0.8) # Create a model using Turi Create's object detector API model = tc.object_detector.create(train_data, max_iterations=1000) # Save the predictions to an SArray predictions = model.predict(test_data) # Evaluate the model and save the results into a dictionary metrics = model.evaluate(test_data) print('Precision' , metrics['mean_average_precision'])
  • 36. MODEL TRAINING import turicreate as tc import os # Define all images annotations with bounding box details (I am showing only 1) annotations = tc.SArray([ [{ “label”:”5000ar", “type":"rectangle", “coordinates”:{“y":188.5,"x":207,"width":304,"height":152} }], … , … … ]) # 1. Load images (Note: you can ignore 'Not a JPEG file' errors) data = tc.image_analysis.load_images('mr_turi_ic', with_path=True) data['label'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path))) data['annotations'] = tc.SArray(data=annotations, dtype=list) # Make a train-test split train_data, test_data = data.random_split(0.8) # Create a model using Turi Create's object detector API model = tc.object_detector.create(train_data, max_iterations=1000) # Save the predictions to an SArray predictions = model.predict(test_data) # Evaluate the model and save the results into a dictionary metrics = model.evaluate(test_data) print('Precision' , metrics['mean_average_precision']) # Save the model for later use in Turi Create model.save(‘turi_ic.model') # Export for use in Core ML file to the current directory model.export_coreml('turi_ic.mlmodel')