00 — Background
The Cigar Tin
Henri Wintermans Long Panatella
My wife's uncle passed away several years ago. After the house clearance, very little remained. One of the things that did was an old cigar tin, rattling with coins collected over what must have been decades. Nobody knew where they had come from, which countries, which eras, or whether any of them amounted to anything beyond loose change from a life well lived.
The tin sat around for a while, as these things do. But the question it posed kept coming back: what exactly do we have here? A numismatist would charge for an appraisal. A collector would know at a glance. I am neither. So I decided to build something.
This project documents how I used local AI vision models, running entirely on a MacBook in a home office in Belfast, to classify all 101 coins, identify their origin, condition and collector value, and compare the performance of three local vision models in the process. No cloud. No API costs. No specialist knowledge required.
01 — Methodology
Pipeline Design and Model Selection
The pipeline was built in five logical stages. First, 202 JPEG images were captured via MacBook webcam using Photo Booth, both sides of each coin photographed in sequence. Photo Booth saves files with system-generated GUID filenames, so a Python script sorted them by modification time and renamed them sequentially to coin_001_A.jpeg through coin_101_B.jpeg.
A structured prompt instructed each model to act as an expert numismatist and return a JSON object covering 19 fields including country, denomination, year, Sheldon condition grade, metal composition, collector interest, and estimated value range. All three models were run via Ollama on the MacBook Pro, with each model completing all 101 coins in a single pass before switching. This kept each model fully resident in the 24GB unified memory and avoided costly model-swap overhead. Results were saved after every coin, allowing the pipeline to resume from any interruption.
The JSON parser was written to handle markdown fences, prose wrapping, and partial JSON, extracting a valid object from each response regardless of formatting. This proved essential: Gemma initially wrapped all output in markdown code fences, and Llama produced two distinct corruption patterns that required a multi-stage parser to resolve. Additionally, Llama uses a different API endpoint to the other two models and can only accept one image per message, requiring each coin to be submitted as a two-turn conversation rather than a single prompt.
Qwen3.5:9b
Qwen3.5 is Alibaba's third-generation multimodal family, released in early 2026. The 9B variant offers a strong balance of vision capability and inference speed on consumer hardware, with a class-leading 256K context window. Selected as a well-regarded open-weight alternative to proprietary vision APIs, with particular strength in structured output generation. Delivered 100% field completion with zero parse errors.
Gemma4:e4b
Gemma 4 is Google DeepMind's open-weight model family for efficient on-device deployment. The e4b variant is a 4-bit quantised build optimised for Apple Silicon. Included as a direct Google-provenance comparator, allowing results to be set against what a paid Gemini API call would return from the same model lineage, without transmitting data off-device. Fastest of the three at 54.7 seconds per coin.
Llama3.2-vision:11b
Llama 3.2 Vision is Meta's open-weight multimodal model, released September 2024. Included as a widely-deployed open-source comparator to test whether a third model lineage would produce meaningfully different results. It encountered several significant reliability challenges not seen in the other two models, detailed in the findings, and required four passes and a multi-stage custom parser to complete the full dataset.
Results at a glance
Results at a glance
Results at a glance
02 — Results
Agreement Rates by Field
Agreement rates below reflect two-model comparison between Qwen and Gemma, the two models that completed the dataset without reliability anomalies. Llama's results are analysed separately in the findings section. Adding Llama as a third comparator did not improve any field's agreement rate.
agreement
agreement
agreement
agreement
03 — Key Findings
What the Data Tells Us
Country identification is the most reliable field at 81%. Most disagreements between Qwen and Gemma involved colonial or dependency attributions, for example British India versus United Kingdom, attributable to labelling ambiguity rather than genuine misidentification. Llama's country accuracy was considerably lower, with 37 mismatches including egregious errors such as Czech Republic for Bulgaria, Monaco for Brazil, and Canada for France.
Year agreement at 59% is substantially weaker than initial sampling suggested. An early ten-coin sample indicated 90%, but the full dataset reveals this was unrepresentative. Year identification deteriorates significantly for older, worn, or partially legible coins where date digits are obscured. Llama introduced an additional failure mode not seen in the other models: returning approximate decades such as "1980s" rather than a specific year on eight coins.
Denomination agreement at 31% is the most significant failure mode between Qwen and Gemma. Disagreements arise from labelling convention differences ("20p" versus "20 Pence"), currency system misattributions, and genuine identification errors on ambiguous pre-decimal coins. A normalisation post-processing layer would resolve the majority of convention-based discrepancies without requiring model retraining.
Condition grading is almost entirely divergent: only 2 of 101 coins received the same grade from Qwen and Gemma. Qwen applied G-4 to 87% of coins, treating it as a near-universal default for circulated coinage. Gemma applied VF-20 to 46% of coins with considerably more variance. The two models are not using different rubrics so much as Qwen has collapsed the grading scale to a single value.
Confidence scores are uninformative as a tiebreaker. Qwen and Gemma both reported 95% on almost every coin regardless of disagreement. Llama reported 100% on the coins it did score, but left 33 of 101 confidence fields empty entirely. None of the three models' confidence outputs can be used to flag uncertain cases without explicit calibration against a ground-truth validation set.
Gemma is the fastest and most discriminating model for this task. At 54.7 seconds average it is meaningfully quicker than both Qwen (60.3s) and Llama (56.0s on completed coins). It applies a broader range of condition grades than either of the other models, making it the strongest baseline for production use once a common grading rubric is established via prompt engineering.
Llama applied MS-65 to 71% of all coins, the most extreme grading bias of any model. MS-65 is a near-perfect Mint State grade reserved for uncirculated coins with virtually no wear. Applying it to 72 of 101 coins photographed on a desk with a webcam is clearly incorrect. Where Qwen's G-4 default understates condition, Llama's MS-65 default overstates it by the maximum possible margin. Neither model is usable for grading without explicit rubric anchoring in the system prompt.
Llama produced significant structured output reliability issues absent from the other two models. It produced malformed JSON in two distinct patterns: stray numeral tokens inserted after commas throughout the output, and denomination values used as key names rather than values. Standard JSON parsing failed on 65 of 101 coins, requiring a multi-stage custom parser. Twelve coins returned with zero elapsed time. Thirty-three confidence fields were empty. Llama also required four separate passes to complete the dataset due to repeated timeouts, compared to a single pass for both Qwen and Gemma.
Six coins stumped all three models simultaneously, each producing a different country identification. Coin 026 was identified as United Kingdom, Australia and United States. Coin 030 divided between Slovakia, Slovenia and Czech Republic. Coin 060 produced United Kingdom, United States and New Zealand. Coin 073 was called Ireland, Eire and South Africa. Coin 085 split as New Zealand, United States and United Kingdom. Coin 088 attracted Ireland, an unknown regional Italian identification and United Kingdom. These are the collection's most genuinely ambiguous pieces, likely worn, partially obscured, or from issues with similar designs across multiple national coinages.
04 — Build Log
Trial, Error and Iteration
Building the pipeline was not without friction. The following log documents each problem encountered and how it was resolved. The pattern is itself illustrative of how practical AI projects actually develop: the model is rarely the source of difficulty.
TextEdit saved the Python script as Rich Text Format
TextEdit defaults to RTF, causing Python to throw a SyntaxError on the RTF header. Fixed by switching to Format > Make Plain Text before pasting code, and setting Plain Text as the default in TextEdit preferences.
Photo Booth saved all 202 images with GUID filenames
A Python script sorted files by modification time and renamed them sequentially to coin_001_A.jpeg through coin_101_B.jpeg, with a dry-run mode to verify pairings before committing.
Gemma wrapping all JSON output in markdown code fences
Gemma 4 wrapped every response in ```json ... ``` fences. The parser was rewritten to strip markdown fences and extract the outermost { } block from any response, making it immune to fenced and prose-wrapped outputs.
Gemma output truncated mid-field by token limit
Gemma's verbose output exceeded the 1,024-token num_predict limit, truncating responses mid-field. Increased to 2,048 tokens, providing sufficient headroom for complete responses across all coin types.
Incorrect Ollama model tags in the script
Initial tags (qwen2.5vl:latest and gemma3:27b) did not match the locally installed models. Corrected to qwen3.5:9b and gemma4:latest, confirmed via ollama list.
Model-swap overhead from alternating models per coin
The original pipeline alternated between models for each coin, forcing Ollama to swap models in and out of the 24GB unified memory on every iteration. Refactored with a --model flag to run all 101 coins through one model before switching, keeping the full model resident throughout.
Timeout on coin 83 during the Qwen pass
Coin 83 exceeded the 120-second timeout, likely due to a complex or ambiguous image requiring longer inference. Because progress is saved after every successful coin, the script was simply re-run. Coin 83 completed on the second attempt.
Llama 3.2 Vision: 400 Bad Request on all coins
Llama uses a different API endpoint to Qwen and Gemma. Sending images via /api/generate with a top-level images field returned a 400 error on every coin. The query function was updated to route Llama through /api/chat with a messages structure, while Qwen and Gemma continue to use /api/generate.
Llama 3.2 Vision only accepts one image per message
After fixing the endpoint, a 500 error appeared: "this model only supports one image while more than one image requested." Llama cannot accept both coin sides in a single message. The payload was restructured as a two-turn conversation: the A side sent first, a brief assistant acknowledgement, then the B side with the full classification prompt.
Llama producing malformed JSON on 65 of 101 coins
Two distinct corruption patterns: stray numeral 1 tokens inserted after every comma, and denomination values used as key names (e.g. 20: Czech Koron). Standard parsing failed on 65 coins. A multi-stage parser was added: stripping stray tokens, fixing unquoted numeric keys, and falling back to key-value pair extraction for partially valid responses. Full parse errors were reduced to zero, with 65 coins marked as partial parses.
Llama requiring four passes to complete 101 coins
Llama repeatedly timed out on individual coins during each pass, requiring three additional restarts. The progress file tracks each completed coin individually, so each restart resumed from where the previous pass left off. All 101 coins were eventually processed: 36 clean parses and 65 partial parses.
05 — Data Explorer
Coin-by-Coin Results
Select any coin to view source images alongside a field-by-field comparison of all three models' outputs.
| Coin | Country | Denom. | Year | Qwen | Gemma | Llama | Ctry | Year | Denom. | Cond. | Δ | View |
|---|
06 — Conclusions & Recommendations
Implications for Deployment
The experiment demonstrates both the maturity and the current limits of open-weight vision models on a specialist classification task. Provenance identification is sufficiently reliable to automate at scale. Condition grading and denomination labelling are not, without further prompt engineering. Llama's reliability profile makes it unsuitable for production structured data pipelines on this hardware without significant additional work.
07 — Cost Analysis
Local Inference vs Cloud API
All three models were run locally with no cloud dependency. The comparison below uses each model's nearest commercial API equivalent: Qwen VL Plus on Alibaba Cloud, Gemini Flash 2.5 for Gemma, and Llama 3.2 Vision 11B via OpenRouter for Llama. Token estimates are based on actual image dimensions (720x480px): 425 visual tokens for Qwen VL, 258 for both Gemini and Llama (single tile at this resolution), plus approximately 700 tokens of system prompt and output schema.
Hardware: £1,799 · 20W inference draw
Qwen VL Plus + Gemini Flash 2.5 + Llama 3.2 Vision
If the MacBook is already owned, local inference costs less than the cloud equivalent. The marginal electricity cost across all three models is 2.9p. The equivalent cloud API bill is 7.4p. Both figures are negligible in absolute terms, but the privacy advantage of on-device processing is not.
Cloud wins on total cost of ownership at this scale. Including hardware amortisation, local inference costs 77p for 101 coins versus 7.4p in the cloud. The M5 would need to process approximately 2.45 million coin images before the hardware cost pays back against equivalent cloud API spend.
Privacy is the decisive local advantage at any scale. For a numismatic catalogue of personal or commercial sensitivity, coin images and the story behind them stay on the device. Cloud APIs transmit images to third-party servers. For a family collection this distinction was the starting point, not an afterthought.
Llama is the cheapest cloud option by a significant margin despite being the weakest performer. At $0.049 per million tokens via OpenRouter, its cloud equivalent costs £0.006 for this experiment versus £0.036 for Qwen. Price and quality do not correlate in this comparison.
Cost at scale
| Volume | Compute time | Local — electricity | Local — incl. amortisation | Cloud API (3 models) | Cheaper option |
|---|---|---|---|---|---|
| 101 coins this experiment | 4.80 hrs | £0.029 | £0.77 | £0.074 | Local (elec) |
| 1,000 coins | 47.5 hrs | £0.29 | £7.61 | £0.73 | Local (elec) |
| 10,000 coins | 475 hrs | £2.89 | £76 | £7.33 | Local (elec) |
| 100,000 coins | 4,750 hrs | £28.90 | £761 | £73.30 | Local (elec) |
| 2.45M coins break-even point | ~115,000 hrs | £700 | £1,799 | £1,799 | Break-even |
Assumptions: M5 base chip at 20W during LLM inference; PowerNI unit rate at 30.62p/kWh (April 2026 bill; Northern Ireland electricity sits outside the Ofgem price cap); MacBook Pro M5 14" 24GB at £1,799 amortised over 4 years at 8 hours/day; three-model total compute 4.80 hours. Qwen VL Plus at $0.137/$0.409 per 1M tokens; Gemini Flash 2.5 at $0.10/$0.40 per 1M tokens; Llama 3.2 Vision 11B at $0.049/$0.049 per 1M tokens via OpenRouter; USD/GBP at 0.80. Llama is the cheapest cloud option by a significant margin despite being the weakest performer on this task.