The Cigar Tin Project — April 2026

Classifying 101 Inherited Coins Using Local AI Vision Models

A three-model comparison of Qwen3.5, Gemma 4 and Llama 3.2 Vision, run entirely on a MacBook Pro with no cloud dependency

David Crozier CBE 101 coins  •  202 images 3 models evaluated Belfast, April 2026
This case study documents the design and results of a local AI vision pipeline built to catalogue an inherited collection of 101 coins. Three open-weight vision models were run independently via Ollama on a MacBook Pro M5 with 24GB unified memory, with no cloud dependency and no data leaving the device. The results reveal meaningful convergence on country identification between the two stronger models, significant divergence on year and denomination labelling, near-total disagreement on condition grading, and a range of structured output reliability challenges unique to the third model, with important implications for the deployment of local AI models in specialist classification tasks.

The Cigar Tin

Henri Wintermans Long Panatella cigar tin containing the coin collection

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.


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.

202 JPEG images coin_001_A/B through coin_101_A/B Prompt builder 19-field JSON schema · numismatist role Ollama — local inference three sequential passes · MacBook Pro M5 · 24 GB · no internet qwen3.5:9b /api/generate 1 pass · 100% clean 60.3 s avg · 6.6 GB gemma4:e4b /api/generate 1 pass · 100% clean 54.7 s avg · 9.6 GB llama3.2-vision /api/chat · two-turn 4 passes required 65 partial · 7.9 GB JSON parser strip fences · fix stray tokens · validate Per-coin JSON results/coin_*.json · progress file updated Progress file resume on restart Master CSV 101 coins × 3 models × 19 fields Comparison report accuracy · speed · reliability
Model A — Qwen

Qwen3.5:9b

DeveloperAlibaba Cloud
Size on disk6.6 GB
Context window256K tokens
ModalitiesText & image

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.

Model B — Gemma

Gemma4:e4b

DeveloperGoogle DeepMind
Size on disk9.6 GB
Context window128K tokens
ModalitiesText & image

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.

Model C — Llama

Llama3.2-vision:11b

DeveloperMeta AI
Size on disk7.9 GB
Context window128K tokens
ModalitiesText & image (single image)

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.

Model A — Qwen

Results at a glance

Average response time60.3 s
Most common gradeG-4 (87% of coins)
Confidence (modal)95%
Parse errors0
Passes required1
Model B — Gemma

Results at a glance

Average response time54.7 s
Most common gradeVF-20 (46% of coins)
Confidence (modal)95%
Parse errors0
Passes required1
Model C — Llama

Results at a glance

Avg response (non-zero)56.0 s
Most common gradeMS-65 (71% of coins)
Confidence where reported100% (modal)
Full parse errors0 (65 partial)
Passes required4

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.

81%
Country
agreement
59%
Year
agreement
31%
Denomination
agreement
2%
Condition
agreement

What the Data Tells Us

F 1

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.

F 2

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.

F 3

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.

F 4

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.

F 5

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.

F 6

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.

F 7

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.

F 8

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.

F 9

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.


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.

Issue 1

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.

Issue 2

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.

Issue 3

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.

Issue 4

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.

Issue 5

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.

Issue 6

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.

Issue 7

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.

Issue 8

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.

Issue 9

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.

Issue 10

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.

Issue 11

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.


Coin-by-Coin Results

Select any coin to view source images alongside a field-by-field comparison of all three models' outputs.

CoinCountryDenom.Year QwenGemmaLlama CtryYear Denom.Cond. ΔView

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.

1Do not rely on any model for denomination identification without post-processing. At 31% agreement, a normalisation layer mapping free-text output to a controlled vocabulary is essential before any downstream use.
2Treat year identification as unreliable for pre-1950 coins. Most year disagreements cluster around older, worn coins. A rule-based flag based on estimated coin age and condition could route these for human review automatically.
3Anchor all models to an explicit Sheldon scale rubric with examples. Qwen's G-4 default and Llama's MS-65 default both render condition grades meaningless for differentiation without explicit rubric instruction in the system prompt.
4Prefer Gemma for production pipelines. It is the fastest at 54.7 seconds per coin, completed in a single pass with zero parse errors, and applies more discriminating condition grades than either Qwen or Llama.
5Qwen is the most consistent choice for structured output pipelines. One hundred per cent field completion, zero parse errors, and single-pass completion make it the lowest-risk option where output reliability is the primary concern.
6Do not deploy Llama 3.2 Vision for structured classification without significant engineering investment. Its MS-65 grading default, 65 partial parses, four-pass requirement, and country misidentification rate make it the weakest performer. Its single-image-per-message constraint also requires a workaround that adds pipeline complexity.
7The six contested coins warrant specialist human review. The six coins where all three models gave different country identifications represent the collection's genuinely ambiguous pieces. They are the ones that would give a human numismatist pause too, and should be set aside for expert appraisal.

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.

Local — MacBook Pro M5

Hardware: £1,799  ·  20W inference draw

Electricity (4.80 hrs @ 30.62p/kWh)£0.029
Hardware amortisation (4yr, 8hr/day)£0.74
Total (marginal, electricity only)2.9p
Total (including amortisation)77p
Data privacyComplete — on device
Cloud — Paid API Tokens

Qwen VL Plus  +  Gemini Flash 2.5  +  Llama 3.2 Vision

Qwen VL Plus (Alibaba Cloud)£0.036
Gemini Flash 2.5 (Google AI)£0.032
Llama 3.2 Vision 11B (OpenRouter)£0.006
Combined total, all three models7.4p
Data privacyImages leave device
C 1

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.

C 2

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.

C 3

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.

C 4

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.

VolumeCompute time Local — electricityLocal — incl. amortisation Cloud API (3 models)Cheaper option
101 coins
this experiment
4.80 hrs£0.029£0.77£0.074Local (elec)
1,000 coins47.5 hrs£0.29£7.61£0.73Local (elec)
10,000 coins475 hrs£2.89£76£7.33Local (elec)
100,000 coins4,750 hrs£28.90£761£73.30Local (elec)
2.45M coins
break-even point
~115,000 hrs£700£1,799£1,799Break-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.