Recognize Handwriting with Core ML – 2/24 Days of Swift Tutorials 🎄

Learn how to Recognize Handwriting on iOS with Core ML and Swift. You are going to use Core ML, the Vision Framework and the MNIST machine learning model to recognize handwriting directly from the touch drawing of your users.

📲 Slack Community:


👏 Support me on Patreon:


➡️ Additional Tutorial Files:
Core ML Models:
CanvasView class:

➡️ Finished Project on Github:

➡️ Web:

If you have questions about the video or Cocoa programming, please comment below.


Gabriel Mesquita says:

I’m getting really poor results, any one having the same problem? i.e. I write a “1” but then the system recognizes it as a “4” 🙁

syntax says:

Not very accurate results and I am getting
this error:
⚠️flatMap’ is deprecated: Please use compactMap(_:) for the case where closure returns an optional value

Use ‘compactMap(_:)’ instead

Kaartik Malhotra says:

is CoreML supported by iphone6?

Stephen Anderson says:

I drew a bird and got a 4. Reminds be the good old back-propagation jokes.

Llama Lords says:

When I opened the finished project it was just an Xcode project with no code. Where is the completed project?

J. H. says:

How can you determine the name of a variable by something different? Is that even possible? I mean creating subclasses like example1, example2, example3 etc.

RobbieTheH4x says:

Who else is watching this and has no clue what is going on?

Muhammad Arij says:

I have a project to Recognise the number from number plate (Number Plate Recognition)
Can you help me for this ?
you have any tutorial of recognising number from number plate ?

Muhammad Ali says:

awasome video . it is done by a coreml model not by a developer , developer like me only write a small code . what developer do special ???

Mr. Jones says:

For those getting poor results:

1) Use this MNIST model instead (make sure to replace MNIST() with mnistCNN() in your setupVision function)

2) Remove the .filter from the handleClassification function

3) Remember to write your digit large enough, as the 375×375 (or whatever) canvas area is being downsized to 28×28. If your digit is small, it’s just going to look like a 1 when downsized.

Not entirely sure why, but the model linked in the video is not outputting proper confidence levels – it would only output a 1.0 confidence for one number and then the others would be 0.0000000000000001 (actually much much lower lol)

The new model I linked does give proper confidence levels; however, because there’s a lot of crossover between the numbers, a confidence requirement of 0.8 (or whatever) is too high. By removing the confidence filter, the first result of array is still the highest confidence number. Unfortunately this model is not great at recognizing the number 0 from my testing, but it’s pretty good with all the others.

Julian Urrego says:

Great tutorials man, thank you for keeping doing this!

Pedro Ortiz says:


Ary de Oliveira says:

to GitHub an empty project

tim mez says:

Thank you so much! Your channel is awesome

Janet GL says:

can it recognizes colors?? that would be really cool

Thehelltoday says:

to GitHub an empty project

Pedro Ortiz says:

It recognizes letters too?

Cyril Garcia says:

Downloaded the project as is and did not get any accurate results. 🙁

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!