Created
August 9, 2018 05:58
-
-
Save peckjon/deeff0164a83ebbd1842d8bfdbaa65cd to your computer and use it in GitHub Desktop.
Quickly Building a Face Recognizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Algorithmia | |
api_key = "YOUR_API_KEY" | |
client = Algorithmia.client(api_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1: Adding images and training | |
input1 = { | |
"action":"add_images", | |
"data_collection":"MyFaceClassifiers", | |
"name_space":"celebrities", | |
"images":[ | |
{"url":"data://cv/face_recognition_example_data/jim_caviezel_01.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_02.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_03.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_04.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_05.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_06.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_07.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_08.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_09.jpg","person":"jim_caviezel"}, {"url":"data://cv/face_recognition_example_data/jim_caviezel_10.jpg","person":"jim_caviezel"}, | |
{"url":"data://cv/face_recognition_example_data/michael_emerson_01.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_02.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_03.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_04.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_05.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_06.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_07.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_08.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_09.jpg","person":"michael_emerson"}, {"url":"data://cv/face_recognition_example_data/michael_emerson_10.jpg","person":"michael_emerson"}, | |
{"url":"data://cv/face_recognition_example_data/amy_acker_01.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_02.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_03.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_04.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_05.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_06.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_07.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_08.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_09.jpg","person":"amy_acker"}, {"url":"data://cv/face_recognition_example_data/amy_acker_10.jpg","person":"amy_acker"}, | |
{"url":"data://cv/face_recognition_example_data/sarah_shahi_01.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_02.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_03.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_04.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_05.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_06.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_07.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_08.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_09.jpg","person":"sarah_shahi"}, {"url":"data://cv/face_recognition_example_data/sarah_shahi_10.jpg","person":"sarah_shahi"}, | |
{"url":"data://cv/face_recognition_example_data/kevin_chapman_01.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_02.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_03.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_04.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_05.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_06.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_07.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_08.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_09.jpg","person":"kevin_chapman"}, {"url":"data://cv/face_recognition_example_data/kevin_chapman_10.jpg","person":"kevin_chapman"} | |
] | |
} | |
print client.algo("cv/FaceRecognition/0.2.0").pipe(input1).result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 2: Prediction of images | |
input2 = { | |
"name_space": "celebrities", | |
"data_collection": "MyFaceClassifiers", | |
"action": "predict", | |
"images": [ | |
{"url": "data://cv/face_recognition_example_data/jim_caviezel_11.jpg"}, | |
{"url": "data://cv/face_recognition_example_data/michael_emerson_11.jpg"}, | |
{"url": "data://cv/face_recognition_example_data/amy_acker_11.jpg"}, | |
{"url": "data://cv/face_recognition_example_data/sarah_shahi_11.jpg"}, | |
{"url": "data://cv/face_recognition_example_data/kevin_chapman_11.jpg"} | |
] | |
} | |
print client.algo("cv/FaceRecognition/0.2.0").pipe(input2).result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment