Choix 2.0: now a proper desktop app

TL;DR Choix 2.0 is a photo culling app for Macs with Apple Silicon. It’s free in the Mac App Store, and it’s still available with brew install --cask volodymyrsmirnov/tap/choix or as a DMG download from GitHub releases.

In April I wrote about choix, my tool that groups photos of the same scene, so I can pick one winner in each group and send only the winners to the editor. The idea worked, but using it was awkward. To cull a shoot you opened a terminal, went to the folder, ran a command and then switched to a browser tab that talked to a server on localhost. On top of that it needed exiftool, ffmpeg and ONNX Runtime from Homebrew, and two models downloaded on the first run: 352 MB of CLIP for grouping and 177 MB of TOPIQ for the quality rating.

Overall, the CLI was a crutch, and the web UI was a crutch for the crutch. Also, I wanted Choix in the Mac App Store, and a sandboxed app can’t depend on Homebrew tools. So version 2.0 is a desktop app, and most of the changes follow from that.

The Library

The new home screen is the Library: every folder you added, grouped by the month it was shot in, newest first. Each row shows the date range, the number of photos and clusters, how many are picked and rejected, and a strip of six thumbnails taken evenly across the shoot. You add folders with Add Folder (⌘O) or by dropping them on the window.

The Choix Library: folders from Dubai, Vienna, Sicily, Sao Lorenco and Iceland grouped by month, each with its photo, cluster, pick and reject counts and a strip of six thumbnails

The Dubai folder has 29 picks and 191 rejects out of 246 photos. The infinite monkey theorem from the first post still holds.

Folders are scanned in the background, two at a time, and the one you open jumps the queue. If you rename or move a folder in Finder, Choix follows it, and a folder you delete leaves the Library by itself. A folder on a drive that isn’t connected stays in the list, dimmed, until the drive is back. Removing a folder from the Library only makes Choix forget it, and the photos stay where they are.

Inside a folder you get the clusters, with the camera, the time, the pick and reject counters and a progress line for each one. You can filter by camera, sort by capture time and re-cluster with different settings, and Open Picks (⌘P) shows the copies in Finder.

A folder in Choix: clusters of photos from the Fujifilm X100VI with their capture time, pick and reject counters and quality scores on each thumbnail

Focus, Compare and pixel-peep work as before, with the same keys: Space picks, X rejects, C compares, Z zooms in. Picks and rejects can now be undone with ⌘Z, rejected photos can be hidden, and there is an option to jump to the next photo after each pick or reject. All the shortcuts are also in the macOS menu bar.

Compare mode in Choix: two almost identical photos of a sunset over a promenade side by side, one picked and one rejected, each with its quality score

Apple frameworks instead of exiftool and ffmpeg

The first version called external tools for almost everything: exiftool for EXIF, exiftool again to pull the JPEG preview out of a RAW file, ffmpeg or sips to resize it, ffmpeg for video frames, and ONNX Runtime for both models. A thumbnail of a RAW file meant starting exiftool and then ffmpeg, and each tool could break on its own, like ffmpeg on iPhone HEIC files or the ONNX Runtime dylib after a brew upgrade.

Now Choix runs no external tools. EXIF and video metadata come from ImageIO and AVFoundation, the JPEG preview is read straight from the RAF or DNG file and resized by ImageIO, video keyframes come from AVFoundation, and visual grouping uses the Vision framework. Reading the embedded preview from a RAF takes about 3 ms, and making a 1600 px preview out of it about 60 ms of CPU time.

I ran both versions twice on a folder of 248 RAF files on an Apple M5, with visual grouping and the quality rating on. The new version is about 4 times faster (times are the average of the two runs):

Stage Choix 0.1 Choix 2.0
Metadata ~3 s 0.2 s
Thumbnails 22 s 6.5 s
Visual analysis 9.5 s 0.9 s
Quality rating ~100 s under 25 s
Whole job 133 s 32 s

For the new version, the quality rating row also includes a few finishing steps, like the preview strip for the Library.

How grouping works now

The three levels are the same as before: by device, then by time with a gap of 10 minutes, then by visual similarity inside each time bucket. The last level changed completely.

Before, each photo got a CLIP embedding from its 256 px thumbnail, squashed into a square, and photos were grouped with single-linkage clustering at a similarity of 0.92. Single-link chains photos: if A looks like B and B looks like C, all three end up together even when A and C have little in common. To compare the options, I measured the grouping on two data sets: INRIA Holidays, 1,491 holiday photos in 500 known groups, and a folder of 110 of my photos from one camera, which I labelled by hand into 68 scenes. The score is F1 over pairs of photos, where 1.0 means the groups match the labels exactly.

Method Public set My folder Time per photo Download
DINOv2 base 0.81 0.95 218 ms 347 MB
Apple Vision feature print 0.75 0.89 7-10 ms none
CLIP ViT-B/32 0.72 0.89 39 ms 352 MB
Choix 0.1 (CLIP, single-link, 0.92) 0.58 0.68 39 ms 352 MB
Time buckets only 0.17 0.12

DINOv2 was the most accurate, but it needs a 347 MB download and takes more than 20 times longer per photo than Vision. The image feature print from Apple’s Vision is as good as CLIP, comes with macOS and takes about 10 ms. So Choix now computes a feature print for every photo from its 1600 px preview, on the device, and groups them with complete-linkage clustering: two groups merge only if every photo in one is close to every photo in the other. On my folder, the best threshold was 0.91, where every pair it formed was a real pair. The default is 0.90, one step looser, as I prefer slightly bigger groups, and it can be changed in the settings.

Videos are grouped too, by the feature print of their first keyframe, and cross-device merging, which puts the camera and the phone shots of the same scene into one cluster, still works.

How the quality rating works

Every photo gets a small badge with a technical quality score from 0 to 10. It’s meant for one thing: showing which frame in a cluster of almost identical ones is the sharpest and cleanest. In the first version the score came from TOPIQ, a 177 MB neural network that took 375-600 ms per photo and had a non-commercial license. Now it’s a short formula written in Go, which runs on the 1600 px preview in a few tens of milliseconds.

The formula looks at three things:

  1. Sharpness. The preview is blurred with a Gaussian at two sizes, and the variance of the Laplacian of each shows how much fine detail there is. A focused photo has a lot of it, and a defocused or shaken one doesn’t.
  2. Noise. Noise also looks like fine detail, so it’s measured separately on the flattest parts of the image, and its share is subtracted from the sharpness.
  3. Exposure. How far the average brightness is from middle grey, and the share of pixels with blown-out highlights.

These are added up with fixed weights and mapped to 0-10. To check it, I took 150 sharp public photos and damaged them in known ways: defocus, motion blur, missed focus on the subject, noise, under- and overexposure, 3,150 images in total. The formula ranked the original above its damaged copy in 97% of pairs, against 94% for TOPIQ. Its weak spot is light overexposure, about +1 EV.

The score doesn’t know anything about composition, expressions or whether the sharp part is your subject. A frame focused on the background rates like a sharp one, because technically it is. It also doesn’t rank good photos of different scenes against each other, so compare the numbers only inside a cluster. And it never acts: nothing is picked, rejected or hidden because of it.

Under the hood

Choix is still written in Go, and the engine of the first version (scan, metadata, thumbnails, analysis, clusters, picks) moved into the app almost as it was. The UI is built with Wails v3, which gives a native macOS window with the system WebKit view inside, so the app doesn’t ship its own copy of Chrome. The frontend is React with TypeScript and Tailwind.

Instead of the HTTP API and server-sent events of the first version, the frontend talks to Go through Wails bindings and typed events. Every part of the app, like the library, the open folder or the settings, is a Go service, and its exported methods become generated TypeScript functions. Only the thumbnails and previews go over HTTP, through a handler on Wails’ asset server. Apple frameworks are called through cgo and small Objective-C files, and folder access goes through security-scoped bookmarks, as the sandbox requires. Wails is imported only at the edges of the app, so the engine and the services are tested without a window.

The code is on GitHub, and the settings are in the README.