Paying for the same
photo twice
I built a tool that turns phone photos of donated books into a library spreadsheet. It was expensive until I saw the same photos going back to the model at every step.
5 min read
Part of my job at the Özyeğin University library is cataloging donated books. For each book I take a couple of photos with my phone, usually the cover and the page with the publication details, and I pause for a moment before the next one, so the gap in the timestamps separates one book from another. What the library needs at the end is one spreadsheet per donor, with a column that says whether the collection already has the title.
A listing like that used to take me about four hours. Now it takes about 30 to 40 minutes to photograph and process, and the tool I built for it is part of how I work.
The first version started from the photos and leaned on a model for the rest, including searching the web. It worked, and it was expensive. One day of donations, 41 books in 89 photos, used about 13 percent of my weekly model allowance.
The photos stayed in the conversation
Taking fewer pictures did not help. The cover and the publication page were usually all a book needed, and a third or fourth photo rarely added anything, so there was little to cut.
I found the real cost while reading through the token counts. Every photo was read as a separate image inside one long conversation, and the conversation carried everything that came before it. Each time the model moved on to the next step, every cover and publication page it had already read went back in with the new request.
I was paying for each photo again at every step that followed.
So the bill did not grow with the number of photos. It grew with the number of photos multiplied by the number of steps they rode along for.
First versionEvery request carried every photo before it. One day, 41 books in 89 photos: about 13% of my weekly model allowance.
AugustSheets of four, a session per donor, no web search for what the page already says. Cost down 73%.
SeptemberText only. The Mac reads 572 photos in about 2 minutes; no image reaches a model.
Each version is measured in its own terms; the three are not on one scale.
In August I changed three things. Photos went onto composite sheets of four, labeled so that a book’s cover and its publication page always landed on the same sheet. Each donor was handled in a separate session, so the images never entered the main conversation. And the model was no longer allowed to search the web for details it could already read on the page in front of it. With all three in place, the processing cost on real donation photos fell by 73 percent. Grouping got more accurate too, because a book’s cover and its publication page now sat side by side.
What the Mac could read
In September I stopped sending images to any model. Apple’s Vision framework, which ships with macOS, scans each photo for text and barcodes on the laptop itself. Six earlier days of donations, 572 photos, took about two minutes, at no cost. Only text goes on to a model, with the barcode readings and whatever an ISBN lookup returns, and a cheaper text model sorts it into the eight fields of the spreadsheet: type, language, title, author, place of publication, ISBN, year or edition, and number of copies.
Before building on it, I checked whether the recognition alone was good enough. Those 572 photos covered 250 books, and I counted how many values in the finished reference lists turned up in the text the Mac had read. It matched 97 percent of the ISBNs and authors, and nearly every place of publication and year. Titles came out at 90 percent, and most of that gap was one fifteen-volume catalog printed in Arabic script, which the reference list had transliterated into Latin letters. Without it, titles reached 96 percent.
Reference fields matched in the recognized text
| Field | Matched |
|---|---|
| ISBN | 97% |
| Author | 97% |
| Title | 90%96% without one Arabic-script catalog |
| Place | over 99% |
| Year | over 99% |
572 photos from six days of donations, read on the Mac. A value counts when it appears anywhere in the recognized text; grouping and extraction were measured separately.
The rows that need a person
The hard part after that was grouping: deciding which photos belong to the same book. Covers and publication pages kept landing in different groups, and one book became two rows.
273rows for 250 books
33%of rows flagged for review
249rows for 250 books
19%of rows flagged for review
Three changes together: a grouping step, a valid ISBN clearing a split row, and a second pass for Arabic script.
I made three changes. A short step before extraction now asks whether neighboring groups are the same publication. A row split off from another no longer needs review when its own photos carry a valid ISBN. And a photo that reads poorly in the default pass gets a second pass for Arabic script. On the same 250 books, the output went from 273 rows to 249, and the share of rows flagged for review dropped from 33 percent to 19. The grouping step alone cut the tokens by more than a third: over five of the six days, from 1.1 million to 684,000.
Deciding which rows I should look at is done outside the model, by plain rules. An ISBN has to pass its check digit and appear in that book’s own photos. The year has to appear in the book’s own text. On one magazine, the model had guessed a publication year from a headline about the previous year’s decisions. The rule caught it.
The first real donation went through the finished pipeline on September 17: 69 books, 139 photos, one command. It ran for 12.4 minutes and used 148,000 tokens. The book-data service it relied on had hit its daily limit and returned nothing all day, so the model worked from the recognized text alone. The report flagged seven rows, and I handed in the spreadsheet as it came out.
The pipeline also repairs ISBNs. A reading of the ISBN for Ağrıdağı Efsanesi, a Yaşar Kemal novel, failed its check digit. When that happens, the pipeline tries every single-digit variation, looks up the valid ones, and keeps the one whose title matches the row. For that book, the right number ended in 1.
Alperen Karaman,