It is now time to jump into the coding part of the application. We are using a model developed using the Caffe deep learning framework by Berkeley AI Research (BAIR) team as well as the community of contributors. As a first step, we need to convert the existing Caffe models into Core ML models to be utilized in our application:
//Downloading Age and Gender models wget http://www.openu.ac.il/home/hassner/projects/cnn_agegender/cnn_age_gen der_models_and_data.0.0.2.zip unzip -a cnn_age_gender_models_and_data.0.0.2.zip
Now, go to the extracted folder and convert the model into a Core ML model:
import coremltools folder = 'cnn_age_gender_models_and_data.0.0.2' coreml_model = coremltools.converters.caffe.convert( (folder + '/age_net.caffemodel', folder + '/deploy_age.prototxt'), image_input_names = 'data', class_labels = 'ages.txt' ) coreml_model.save('Age.mlmodel')
The same needs to be done for the gender model as well. To kick start our...