Trending

World technology news

→
Classifying photos on the iPhone with Core ML in 2017
Artificial Intelligence · 2017
Artificial Intelligence2017

Classifying photos on the iPhone with Core ML in 2017

Apple’s working WWDC 2017 flower classifier and its documented Photos deployment show what on-device machine learning looked like in practice.

Archive retrospective · Topic year 2017

Developer's JournalPublished: Nov 27, 20266 min read
Reading progress0%
In this article
  1. What the 2017 sources actually show
  2. Give the packaged model an input contract
  3. Separate model scores from the interface decision
  4. Measure first use and repeated use separately
  5. Try the complete workflow without a network
  6. Turn the demonstration into acceptance criteria

What the 2017 sources actually show

Apple introduced Core ML alongside iOS 11 on June 5, 2017. At WWDC session 703 the engineering team connected a trained flower classifier to an app. A selected photograph produced a proposed flower label on the device. This was a working integration demonstration. Apple’s September announcement separately dates the operating system rollout to users. The available material establishes the workflow, while adoption figures for the demonstration app fall outside its scope. There is separate evidence of machine learning in a shipped Apple product. A November 2017 engineering article explains that Apple began using deep learning for face detection in iOS 10 and made computer vision capabilities available to developers with Vision. The paper describes the demands of processing a Photos library on the phone. Together the sources tell two complementary stories. The demonstration shows how a developer connected an existing model to a user action. The article reports how a product team handled an actual device workload with limited memory, storage, and energy.

Give the packaged model an input contract

The conference example began with an already trained model. The developers added the model to Xcode, inspected its declared inputs and outputs, and used a generated Swift or Objective-C interface. Xcode compiled the model for deployment and bundled it with the application. The app could then request a prediction locally. Dataset collection and training remained separate from invoking that model on a photograph. A real application should define the image its model expects. Orientation, crop, scaling, and color conversion can change results. Work out which component prepares the image and where any higher-resolution original is needed. Loading an image more than once can obscure the performance cost of inference. Record the input requirements next to the model version so teams can replace a model without accidentally changing what the UI sends. On a version change, run the same reference photographs through both versions and compare the results saved by the application.

Software delivery pipelineConceptual sketch · summary of the article's technical flow

Separate model scores from the interface decision

Imagine a municipal garden worker who wants to label a flower photograph. A local model supplies a ranked list of candidates. The app offers a suggestion only when its leading score meets a threshold and the runner-up is sufficiently far behind. The worker can always choose the label. The JavaScript fixture below runs the interface rule independently of any specific model. Its labels and scores are synthetic. The example chooses 0.60 as the minimum first score and 0.25 as the minimum lead. A strong first candidate returns a suggestion. Two close candidates or a weak leader leave the selection to the worker. A prediction score does not establish a measured probability of correctness for the application’s users. Pick operating thresholds by testing the actual photo conditions and deciding how costly a wrong suggestion would be. Daylight, background, and the available camera all deserve representation in the test set.

function suggestedLabel([first, second]) {
  if (!first || first.score < 0.60) return null;
  if (second && first.score - second.score < 0.25) return null;
  return first.label;
}

suggestedLabel([
  { label: "rose", score: 0.88 }, { label: "daisy", score: 0.09 }
]); // "rose"

suggestedLabel([
  { label: "rose", score: 0.61 }, { label: "daisy", score: 0.38 }
]); // null

suggestedLabel([
  { label: "daisy", score: 0.51 }, { label: "rose", score: 0.48 }
]); // null

Measure first use and repeated use separately

The first prediction can include model loading and memory allocation. Later calls can reuse a loaded model and still pay for image preparation. Measure time to the first result and time for a sequence of predictions separately. On each run, record the platform, model and photo set. Compare representative older and newer devices under similar conditions. Larger photos and warm hardware can change the observed behavior. Apple’s 2017 report describes the difficulty of sharing computation, memory, and energy with other tasks on a phone. A prototype should also cover the consequences visible to its users. If a person switches images while a prediction is running, attach the result to the request that produced it. A file decode failure, a model loading error, and an uncertain answer should have different handling. With separate measurements and states, the team can address slow image loading without incorrectly changing the model or adjusting the UI thresholds.

Try the complete workflow without a network

Enable offline mode, reopen the app, and select the same stored photo. When the model and input are available locally, this exercise tests the app’s full prediction path without an active connection. A separate possibility is that the original photo is stored remotely and cannot yet be loaded. The UI should identify that input problem separately from an inference error. Local inference is one part of the application's data flow. The rest of the application can have network features of its own. Record the result of the test without unnecessarily keeping the photograph in a diagnostic log. Check the application's permission and analytics behavior separately. Include a small screen, rotated images, and a rejected suggestion in the acceptance run. The garden worker’s ability to finish the task manually makes the model easier to introduce incrementally and provides a clear outcome if the system is uncertain.

Turn the demonstration into acceptance criteria

The useful feature of the 2017 example is the connection between a trained model, the action of picking a photo, and an answer produced locally. For a production app, write down the image contract, the device budget, and the decision the model is intended to assist. Agree on a small, reproducible set of acceptance examples. Measure the repeatable path before introducing model changes or adding more automated decisions. The three synthetic classifications above validate the example interface rule. Product acceptance would also measure false suggestions and the time needed to complete the workflow on supported hardware. Observing when people choose a different label can guide a later test, with the collection process designed deliberately. This gives the team a way to improve its predictions while keeping the original task usable when a suggestion is unavailable.

Be the first reader ✎ Write a comment

Reader discussion

Discussion prompt

Which data would you verify before applying this development in your field?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.