Building a Smart Receipt Scanner with Core ML: Training a Text Classifier from Scratch


I'm currently diving deeper into Core ML, and I thought—why not build something practical and exciting along the way? That’s when the idea hit me: a smart receipt scanner app powered by Core ML. Sounds a bit intimidating at first, right? Don’t worry—I’ll guide you through the entire process, step by step, making it simple and approachable.
Key Features
Scan or Upload Receipt Image (Camera or Gallery)
Extract Text from Image (OCR with Vision)
Parse and Structure Extracted Data
Categorize Items (Using self trained ML model)
Display Results by Category
In this article, I’ll focus on the most fundamental part of the project: training the machine learning model that powers the receipt scanner.
Preparing the dataset
To train our model, the first thing we need is a dataset. Since we’re working on a custom use case, we’ll be creating our own dataset in .csv
format. Remember: the larger and more diverse your dataset, the better the model's performance!
Tips:
Normalize inputs (e.g. lowercase, remove symbols)
Use at least 50–100 examples per category
Label examples in spei languages if needed
Training with Create ML
- Open Create ML app from Xcode.
- Open Create ML > New Project > Text Classifier
- Import CSV
- Select Transfer Learning – BERT Embeddings as the model type, and set the number of training iterations (e.g., 20 or more, depending on your dataset size).
In my case, I selected Latin as the language family and French as the target language.
Once everything is set, click the Train button at the top to start the training process.
- After the training is complete, go to the Preview tab to test the model with your own data.
- Once you're satisfied with the results, head over to the Output section and download your trained ML model. Voila! You now have your very own custom-trained model—congratulations!
In the next article, I’ll show you how to integrate this model into an iOS app. Stay tuned!
Subscribe to my newsletter
Read articles from nyein ei directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
