MTG Card Embeddings Gallery

A pre-built embedding gallery for Magic: The Gathering card recognition: one 256-dimensional unit-norm embedding vector per card printing (105,647 printings), computed by running each Scryfall card image through the mtg_card_identification_embeddings model (MIT).

Use it to identify a photographed card: embed the photo with the same model, then find the nearest gallery entry by cosine similarity.

Usage

The gallery ships as three files (built by tools/build_gallery.py):

File Size Contents
gallery/gallery_f16.bin ~52 MB fp16 embeddings, row-major [N x 256]
gallery/gallery_ids.json ~4 MB JSON array of Scryfall card IDs (row order matches the bin)
gallery/meta.json ~7 MB JSON map scryfall_id โ†’ "Name | set #collector"

Minimal consumer (browser):

const ids = await (await fetch('gallery/gallery_ids.json')).json();
const meta = await (await fetch('gallery/meta.json')).json();
const buf = await (await fetch('gallery/gallery_f16.bin')).arrayBuffer();
const embeddings = new Float16Array(buf); // [N x 256] row-major
// query: dot product against every row; the gallery vectors are unit-norm,
// so the raw dot product IS the cosine similarity.

Rebuilding the gallery

cd tools
nix develop   # python3 + onnxruntime + numpy + pillow
python3 build_gallery.py

Downloads Scryfall card images (cached in images/), embeds them with mtg_embed_fp32.onnx (fetched from the model repo above), and writes the three gallery files. Full build: ~40 minutes for all printings.

Attribution

  • Card data and images: Scryfall โ€” unofficial Fan Content permitted under the Wizards of the Coast Fan Content Policy. Card images, card names, and mana symbols are copyright Wizards of the Coast, LLC. This dataset is not produced by or endorsed by Wizards of the Coast.
  • Embedding model: dhvazquez/mtg_card_identification_embeddings (MIT license).
  • The embedding vectors themselves are this project's own computation. The gallery data (gallery/, gallery_cards.json) is released under CC-BY 4.0 (see gallery/LICENSE.txt) โ€” a permissive data license. The build scripts in tools/ are code and are released under GPL-3.0-or-later (see LICENSE.md).
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support