[This post is republished from the . Click . —Frank] a16z AI Playbook here for part 1 of this coding tutorial Now let’s add AI superpowers to our iPhone app by retaining the model with our own and connecting the trained model to our iPhone app. data Setup and Test the iOS App 0. Open Terminal Like in the initial TensorFlow setup, we start by by our side — please follow that link if you need a reminder of the steps. We will continue our convention of using full paths instead of bash shortcuts to keep problems to a minimum, so whenever you see you will have to replace it with your own home path ([here's why we do this]](/docs/guides/dl-start#openTerminal)). having a trusty Terminal always open /Users/joe/ Retraining the Model Retraining the model follows the same steps and some additional optimizations that we can make on the dataset for running on . described earlier mobile Below, you will find each step with a brief description of what it accomplishes. To make it easier, however, we have created a shell script that will run the entire process you can which you can then uncompress in your home directory. download the script here as a zipfile At the top of the script you’ll find the following line TARGET_ROOT_FOLDER=/Users/joe Change that value to the folder you have been using to store both and directories, and then you can run the script: tf_files tensorflow $ ./runtraining.sh While the script is running, you can keep reading to see what the different commands are. In case of errors, the script should direct you to the right section of . this FAQ If you followed the previous examples you should already have the Inception model downloaded. However, if you want to make sure you have an unmodified copy, you can download it again by running curl -o /Users/joe/tf_files/inception.zip \ https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip \ && unzip /Users/joe/tf_files/inception.zip -d /Users/joe/tf_files/inception Then, download the training data for the app we are going to build: curl -o /Users/joe/tf_files/a16zset.zip \ https://cryptic-alpha.herokuapp.com/a16zset.zip \ && unzip /Users/joe/tf_files/a16zset.zip -d /Users/joe/tf_files/a16zset In the end, you should have both the folder and a new folder which contains two main datasets: and . /tf_files/inception /tf_files/a16zset business_card not_business_card as mentioned previously, our dataset is based on the , built as follows: Note: Stanford Mobile Dataset We selected the dataset that includes images of business cards, book covers and CD covers but did not use all 500 images for each category. We then expanded the sets with additional images obtained via web searches, verifying that they had been marked for reuse (according to Google Search) and added a new category for credit cards, which can be very similar to business cards. Finally we normalized the images to dimensions of 640x480 with medium JPEG compression. This isn’t required by the process but we wanted to keep the dataset a relatively small download and have a reference image size that we could use later with the mobile app. This showcases the flexibility afforded by DL for real-world applications while keeping complexity of the training process to a minimum. In our app the image recognition process is intended to speed up, rather than completely replace, human interaction, so even lower-probability matches can be useful. To retrain the model, we use the same command as before, pointing it to the new dataset: $ bazel-bin/tensorflow/examples/image_retraining/retrain \--bottleneck_dir=/Users/joe/tf_files/a16z_bottlenecks \--model_dir=/Users/joe/tf_files/inception \--output_graph=/Users/joe/tf_files/a16z_retrained_graph.pb \--output_labels=/Users/joe/tf_files/a16z_retrained_labels.txt \--image_dir /Users/joe/tf_files/a16zset Using the Model in the iOS App Our iOS App uses the iOS static along with our own Swift Code for it. TensorFlow library Originally published in ’s . Andreessen Horowitz AI Playbook is how hackers start their afternoons. We’re a part of the family. We are now and happy to opportunities. Hacker Noon @AMI accepting submissions discuss advertising & sponsorship To learn more, , , or simply, read our about page like/message us on Facebook tweet/DM @HackerNoon. If you enjoyed this story, we recommend reading our and . Until next time, don’t take the realities of the world for granted! latest tech stories trending tech stories