Skip to content

Vision

Label images with a MobileNet model, returning the top ImageNet class or the top predictions with confidence scores

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/vision/index.md to help me query Vision with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Top-5 (label, confidence) predictions for an image BLOB, confidence-descending.

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT label, round(confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB)
ORDER BY confidence DESC;
Result
label confidence
envelope 0.1352
ping-pong ball 0.0981
Band Aid 0.0729
tennis ball 0.0529
binder 0.0524

Quick start

Choose where to run Vision, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'vision' AS vision (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-vision-worker'
);

3. Run a query

query.sql
SELECT label, round(confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB)
ORDER BY confidence DESC;
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'vision' AS vision (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-vision-worker'
);

Overview

Image classification (ImageNet) on image blobs and file paths for SQL.

Catalog

Everything vision exposes once attached — read straight from the worker's released build.

vision 1 schema
main 1 table · 2 functions

Image classification (ImageNet) on image blobs for SQL

Schema examples (7)
Examples (7)

Single most likely ImageNet label for an image BLOB literal.

SELECT vision.main.top_label('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB) AS label;

Top-5 (label, confidence) predictions for an image BLOB literal, confidence-descending.

SELECT label, round(confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB)
ORDER BY confidence DESC;
Result
label confidence
envelope 0.1352
ping-pong ball 0.0981
Band Aid 0.0729
tennis ball 0.0529
binder 0.0524

Count the ImageNet classes the model can predict (1000).

SELECT count(*) AS n_classes FROM vision.main.image_classes();

Peek at the first five (idx, label) class rows.

SELECT idx, label
FROM vision.main.image_classes()
WHERE idx < 5
ORDER BY idx;
3 more examples

Join the top-10 predictions for an image BLOB to the image_classes lookup table to recover each predicted label's ImageNet class index (idx), most-confident first.

SELECT c.idx, p.label, round(p.confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 10) AS p
JOIN vision.main.image_classes AS c USING (label)
ORDER BY p.confidence DESC;

Roll the full 1000-class distribution for an image BLOB up to one coarse category: total probability on the 118 dog-breed classes (ImageNet idx 151-268, found via image_classes) and the most likely breed among them.

SELECT count(*) AS n_breeds, round(sum(p.confidence), 4) AS dog_probability,
  arg_max(p.label, p.confidence) AS likeliest_breed
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 1000) AS p
JOIN vision.main.image_classes AS c USING (label)
WHERE c.idx BETWEEN 151 AND 268;

Tag images fetched with read_blob using top_label and look each label up in image_classes for its class index; a file that is not an image gets a NULL label, so the LEFT JOIN keeps it with NULL idx.

SELECT f.filename, c.idx, c.label
FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-vision/v0.4.0/test/sql/data/sample.png') AS f
LEFT JOIN vision.main.image_classes AS c ON c.label = vision.main.top_label(f.content)
ORDER BY f.filename;
Tables
image_classes 4 examples2 cols

The model's ImageNet label set: (idx, label), 1000 rows

Columns
idx INTEGER
0-based class index into the model's output vector.
labelnot null VARCHAR
Human-readable ImageNet class label.
ConstraintsPRIMARY KEY (idx)
Examples (4)

Count the ImageNet classes the model can predict (1000).

SELECT count(*) AS n FROM vision.main.image_classes;

Peek at the first five (idx, label) class rows.

SELECT idx, label FROM vision.main.image_classes WHERE idx < 5 ORDER BY idx;
SELECT count(*) AS n FROM vision.main.image_classes();
1 more example
SELECT idx, label
FROM vision.main.image_classes()
WHERE idx < 5
ORDER BY idx;
Link
Scalar functions
top_label (image BLOB) +1 overload 3 examples

The #1 predicted ImageNet label for an image BLOB (NULL if not an image)

Arguments
image BLOB
Image bytes (PNG/JPEG/...).
Overloads
top_label(image BLOB) → VARCHARtop_label(path VARCHAR) → VARCHAR
ReturnsVARCHAR
Examples (3)

Predict the single most likely ImageNet label for an image BLOB literal.

SELECT vision.main.top_label('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB) AS label;

Predict the top label for an image fetched over HTTPS with read_blob.

SELECT vision.main.top_label(content) AS label
FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-vision/v0.4.0/test/sql/data/sample.png');

Tag images fetched with read_blob using top_label and look each label up in image_classes for its class index; a file that is not an image gets a NULL label, so the LEFT JOIN keeps it with NULL idx.

SELECT f.filename, c.idx, c.label
FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-vision/v0.4.0/test/sql/data/sample.png') AS f
LEFT JOIN vision.main.image_classes AS c ON c.label = vision.main.top_label(f.content)
ORDER BY f.filename;
Link
Table functions
classify (image BLOB, top_k BIGINT) +3 overloads 4 examples

Top-5 ImageNet predictions (label, confidence) for an image BLOB

Arguments
image BLOB
Image bytes (PNG/JPEG/...).
top_k BIGINT
Number of predictions to return.
Overloads
classify(image BLOB)classify(image BLOB, top_k BIGINT)classify(path VARCHAR)classify(path VARCHAR, top_k BIGINT)
Returns columns
label VARCHAR
Predicted ImageNet class label.
confidence DOUBLE
Softmax probability in [0, 1]; rows are ordered confidence-descending.
Examples (4)

Top-5 predictions for an image BLOB literal, with rounded confidence, most-confident first.

SELECT label, round(confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB)
ORDER BY confidence DESC;
Result
label confidence
envelope 0.1352
ping-pong ball 0.0981
Band Aid 0.0729
tennis ball 0.0529
binder 0.0524

Join the top-10 predictions for an image BLOB to the image_classes lookup table to recover each predicted label's ImageNet class index (idx), most-confident first.

SELECT c.idx, p.label, round(p.confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 10) AS p
JOIN vision.main.image_classes AS c USING (label)
ORDER BY p.confidence DESC;

Roll the full 1000-class distribution for an image BLOB up to one coarse category: total probability on the 118 dog-breed classes (ImageNet idx 151-268, found via image_classes) and the most likely breed among them.

SELECT count(*) AS n_breeds, round(sum(p.confidence), 4) AS dog_probability,
  arg_max(p.label, p.confidence) AS likeliest_breed
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 1000) AS p
JOIN vision.main.image_classes AS c USING (label)
WHERE c.idx BETWEEN 151 AND 268;
1 more example

Top-10 predictions for an image BLOB literal (explicit top_k), confidence-descending.

SELECT label, round(confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 10)
ORDER BY confidence DESC;
Link

Try these queries

Predict the single most likely ImageNet label for an image BLOB.

SELECT vision.main.top_label('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB) AS label;

Uses top_label

Count the classes the model can predict (1000 ImageNet labels).

SELECT count(*) AS n FROM vision.main.image_classes();

Count the ImageNet classes the model can predict (1000).

SELECT count(*) AS n_classes FROM vision.main.image_classes()

Peek at the first five (idx, label) class rows.

SELECT idx, label
FROM vision.main.image_classes()
WHERE idx < 5
ORDER BY idx

Join the top-10 predictions for an image BLOB to the image_classes lookup table to recover each predicted label's ImageNet class index (idx), most-confident first.

SELECT c.idx, p.label, round(p.confidence, 4) AS confidence
FROM vision.main.classify('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x40\x00\x00\x00\x40\x08\x02\x00\x00\x00\x25\x0B\xE6\x89\x00\x00\x00\xE1\x49\x44\x41\x54\x78\xDA\xED\xDA\xB1\x0D\x83\x30\x10\x85\x61\xB0\x18\x21\x43\x30\x4C\x26\xA0\x66\x04\xC6\xC8\x08\x29\x52\x65\x82\x0C\xC3\x10\x19\x22\x05\x4D\xA4\x20\x41\x7C\xCF\x1C\x27\xFF\x57\x02\xB2\xDE\x87\x8D\x31\x16\x6D\x3F\x3C\x9A\xC8\x95\x9A\xE0\x05\x00\x00\x00\x00\x00\x00\x00\xF0\xAC\x6E\xCF\x45\xAF\xE1\xEE\x95\xEF\xFA\x1C\x19\x42\x00\x00\x00\x00\xE0\xFD\x1E\xC8\xA8\x79\x7A\xFF\x1E\xEC\x6F\x97\x00\x80\xD5\xE8\xDF\xA7\xB4\x8C\xEE\x98\xE8\xE5\x18\xE9\xE0\xF4\xD9\xD7\x97\x05\xE4\xA5\x91\x18\x92\x57\x7A\x95\xA1\xFA\xF7\x80\xFD\x16\x1A\x5B\xA8\xBB\x07\x54\x33\x89\xA5\x1D\xD6\x42\x00\x00\x00\x08\x0C\x50\xAD\x28\x2D\xED\x54\x3F\x84\xEC\x9D\x60\x6C\x81\x87\xD8\x76\x0B\xED\x1D\x98\x1C\x9F\x42\xC9\x1C\x20\x1B\x42\xFF\xA6\x51\xCD\x60\xCA\x8F\xFA\x25\xD3\xE6\xD2\xF2\xBC\xBB\x12\x9B\x8C\x18\xFB\x42\xE5\xB2\x32\x8D\x02\x00\x00\x00\x80\xBE\x5A\x7E\xFA\x03\x00\x00\x00\x00\x00\x00\x00\xE4\xD7\x07\x2B\x8B\x39\x99\xCE\x48\xA8\x86\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82'::BLOB, 10) AS p
JOIN vision.main.image_classes AS c USING (label)
ORDER BY p.confidence DESC

Uses classifyimage_classes

Tag images fetched with read_blob using top_label and look each label up in image_classes for its class index; a file that is not an image gets a NULL label, so the LEFT JOIN keeps it with NULL idx.

SELECT f.filename, c.idx, c.label
FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-vision/v0.4.0/test/sql/data/sample.png') AS f
LEFT JOIN vision.main.image_classes AS c ON c.label = vision.main.top_label(f.content)
ORDER BY f.filename

Uses image_classestop_label

5 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • How many rows does the model's ImageNet class listing return — i.e. the total number of (idx, label) entries in the full class list? Return that single number.
  • What is the ImageNet class label at class index 0? Return the single label.
  • List the three ImageNet classes with the smallest class index. Return columns `idx` and `label`, ordered by `idx` ascending.

Vision is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.