The document discusses building an image recognition application for identifying Iraqi currency denominations. It covers preparing a dataset with labeled images of each denomination under different conditions, training an object detection model using the Turi Create library, and exporting the model for use in an iOS/Android application. The key steps are preparing a dataset with 300+ labeled photos of each denomination, training an object detection model on the dataset, evaluating the model, and exporting it for use in a mobile application.
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
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
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')