Automate a data pipeline to ingest, archive, process, classify and visualize data on animals visiting trail cameras - using Apple Create ML models, training, custom fitting and Swift
Authenticate with Trailcam manufacturer, get S3 bucket authentication token (python)
List and download new photographs to a local folder (python, json)
Sort images into YYYY-MM-DD folders (python, bash)
Archive images in personal AWS S3 bucket
Manually classify images into 0.NoDeer and 1.Deer
Train Apple's generic Image Classification model using Create ML (Apple Create ML)
Import ML model into a simple Swift XCode CLI project (XCode, Swift)
Export a binary that takes a directory as argument, runs classification on each object, and output the results (json, Swift)
Generate statistics (python, json)
Generate basic visualization (graphs) of data (JavaScript, HTML, json)
(1-5, 9-10 were reused from PyTorch project)
You can visit the live page at: https://thorburn.se/trailcam/ ("Total deer observations per day...")
You can check out the code at: https://github.com/boaworm/OklahomaAI-CLI
End result: While this project share similarities with the PyTorch-based project, this proved an interesting learning opportunity, showcasing Apple's approach to common ML tasks.
While PyTorch (and surrounding toolkits) are hugely flexible, Apple provides a very refined and efficient way to train and deploy ML models. They offer their Create ML tool for "free". It is easy to use, generated better results than i could get with PyTorch, and EXTREMELY fast.
Using PyTorch and training resnet50 on 20.000 low-res images took 12+ hours and generated quite poor results in a basic 2-class setup. Running the same data set using Create ML and a pre-defined Image Classification model took only a few minutes and generated >85% correct classification. Apple's approach to hardware-supported models for a set of pre-defined tasks seems to pay off - if your problem can be solved with a predefined model.
Once a good model had been trained, invoking the ML model was trivial using XCode and a Swift CLI project - generating a binary that is invoked on daily folders.
(All training took place on a Mac Studio M1 Max 8+2 cores with SSD and 64 GB ram)
Â