Skip to content

CDiscover · transform.extract

Features from a pretrained model (images, audio, text)

What do these images, sounds or texts look like to a pretrained model, as numbers I can use in other methods?

Runs a frozen encoder over a column of image files, audio files or texts and returns one vector per row: `<column>_emb_1 … _emb_d` columns you can save to the dataset and use for clustering, maps, search or as model features. Files are decoded once on this computer (orientation, resizing and resampling are fixed, so the same file always gives the same numbers) and cached by their content. Encoders without a download (an 8 × 8 thumbnail, a loudness envelope) work right away; pretrained ones (MiniLM for text, MobileNetV3 for images, and the encoders other methods add) run after a one-time download you approve. Files that can't be read get missing values.

Experimental Python and R agree to 6 decimals Also called feature extraction, frozen encoder, image embeddings…

A real result

Example “Images thumbnail”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Features from a pretrained model (images, audio, text)Recorded · Python and R agreeRecorded 2026-11-25 · 16 values compared · largest relative difference 1.3e-15
R

12 of 12 rows were encoded with Thumbnail pixels (8 × 8 gray) into 64 features each; the mean vector length is 3.797.

Rows encoded
12
Features per row
64
Mean vector length
3.797

First 10 rows (first 4 of 64 features)

RowpathFeature 1Feature 2Feature 3Feature 4
1media/images/gradient_0.png0.64630.64020.60800.5460
2media/images/gradient_1.png0.55910.60640.64460.6627
3media/images/gradient_2.png0.64640.64650.64650.6465
4media/images/gradient_3.jpg0.49680.53560.57340.6045
5media/images/rings_0.png0.32280.45750.32930.3029
6media/images/rings_1.png0.39370.46360.41330.3725
7media/images/rings_2.png0.56170.47780.32870.2573
8media/images/rings_3.jpg0.38250.45450.42370.3860
9media/images/checker_0.png0.35130.60410.39590.6041
10media/images/checker_1.png0.33670.55160.55160.3780
Python

12 of 12 rows were encoded with Thumbnail pixels (8 × 8 gray) into 64 features each; the mean vector length is 3.797.

Rows encoded
12
Features per row
64
Mean vector length
3.797

First 10 rows (first 4 of 64 features)

RowpathFeature 1Feature 2Feature 3Feature 4
1media/images/gradient_0.png0.64630.64020.60800.5460
2media/images/gradient_1.png0.55910.60640.64460.6627
3media/images/gradient_2.png0.64640.64650.64650.6465
4media/images/gradient_3.jpg0.49680.53560.57340.6045
5media/images/rings_0.png0.32280.45750.32930.3029
6media/images/rings_1.png0.39370.46360.41330.3725
7media/images/rings_2.png0.56170.47780.32870.2573
8media/images/rings_3.jpg0.38250.45450.42370.3860
9media/images/checker_0.png0.35130.60410.39590.6041
10media/images/checker_1.png0.33670.55160.55160.3780

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Worked examples in the app

  • Images thumbnailmedia_images · column: path
  • Audio loudness envelopemedia_audio · column: path
  • Audio ast audiosetaud3_sounds · column: path
  • Text minilmml_corpus · column: text
  • Text e5 smallml_corpus · column: text
  • Text electra smallml_corpus · column: text
  • Images clipclip_images · column: path
  • Images siglipclip_images · column: path

In the guides

Where it sits in the decision guides

  • Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize
  • Feature engineering: dates, interactions, splines, binning, text features · DS & ML Decision Guide · Prepare data for modelling

What you need

Columncategorical · 1 column
Image or audio files (such as the path column of a media folder added in Data), or a text column for a text encoder.

Choices you make

statistics

Encoderdefault thumbnail

The frozen model that turns each row into a vector. Pick one made for the column's data: images, audio or text.

  • Images: 8 × 8 thumbnail (no download)(default) — The 64 gray pixels of a small copy, from 0 to 1. A quick baseline that groups images by layout and brightness.
  • Images: MobileNetV3-Small (~10 MB, Python only) — 1,024 features from a small ImageNet network; groups images by content. Runs in Python through onnxruntime after a one-time download.
  • Images: ResNet-50 (~100 MB) — 2,048 features from a ResNet-50 trained on ImageNet-1k photos; groups images by object type. Python and R give the same numbers.
  • Images: DINOv2-small (~90 MB) — 384 features from a vision transformer trained without labels on 142 million images; puts look-alike images together. Python and R agree.
  • Images: CLIP ViT-B/32 (~607 MB) — 512 values per image in the space CLIP shares with text, so the CLIP text encoder's vectors compare with them. Python and R agree.
  • Images: SigLIP base/16 (~815 MB) — 768 values per image in the space SigLIP shares with text (WebLI-trained). Python and R give the same numbers.
  • Audio: loudness envelope (no download) — The RMS level of 32 equal parts of each clip (16 kHz mono). A quick baseline for how loudness rises and falls.
  • Audio: AST AudioSet (~346 MB) — 768 values per clip from the Audio Spectrogram Transformer trained on AudioSet: groups recordings by the sounds in them. Python and R agree.
  • Text: all-MiniLM-L6-v2 (~91 MB) — 384-value sentence embeddings that place texts with similar meaning close together. Python and R give the same numbers.
  • Text: E5-small-v2 (~133 MB) — 384-value English text embeddings trained on text pairs; each text is read as "query: <text>". Python and R give the same numbers.
  • Text: multilingual-E5-small (~471 MB) — 384-value embeddings for about 100 languages (XLM-R vocabulary); each text is read as "query: <text>".
  • Text: RoBERTa base (~499 MB) — The mean of RoBERTa's 768-value token states: a general English encoder, not trained for sentence similarity.
  • Text: DistilBERT base (~268 MB) — The mean of DistilBERT's 768-value token states (uncased English).
  • Text: ELECTRA-small (~54 MB) — The mean of ELECTRA-small's 256-value token states (uncased English); small and quick.
  • Text: CLIP ViT-B/32 text encoder (~607 MB) — 512 values per text in CLIP's image–text space: compare texts with images embedded by CLIP ViT-B/32.
  • Text: SigLIP base/16 text encoder (~815 MB) — 768 values per text in SigLIP's image–text space: compare texts with images embedded by SigLIP base/16.

Advanced

Batch sizedefault 32

Rows sent to the encoder at once. Changes speed and memory only, never the numbers.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Frozen model

    The encoder isn't trained on your data, so nothing leaks between rows; the features are only as good as what the model learned.

  • Fixed decoding

    Images are oriented, resized and normalized, and audio mixed to mono and resampled, the same way every time; JPEG and MP3 files decoded outside the app can differ slightly.

  • What the model learned from

    Pretrained encoders reflect their training data (ImageNet photos, web sentences); check that your data looks like it before relying on the features.

What it reports

n_rows
Rows the run read, rows that got a vector, and rows whose file couldn't be decoded (they get missing values).
n_encoded
Rows the run read, rows that got a vector, and rows whose file couldn't be decoded (they get missing values).
n_skipped
Rows the run read, rows that got a vector, and rows whose file couldn't be decoded (they get missing values).
dim
A pretrained model used as-is to turn each image, sound or text into a vector; it learns nothing from your data.
encoder
A pretrained model used as-is to turn each image, sound or text into a vector; it learns nothing from your data.
modality
A pretrained model used as-is to turn each image, sound or text into a vector; it learns nothing from your data.
mean_norm
The average Euclidean length of the rows' vectors; MiniLM vectors have length 1, other encoders vary.
checksum
A weighted sum of every feature value and the means of the first features, so two runs or engines compare in a few numbers.

Per group, level or term: mean[<dim>]

Python and R

Python and R agree to 6 decimals (relative tolerance 1e-9). Python uses numpy, pandas, pyarrow, codesplash; R uses nanoparquet, jsonlite, codesplashr.

Default traps between the two languages

  • Both engines read the same float32 arrays the host decoded (images and audio) and run the same encoder twins; the thumbnail and loudness-envelope features agree to rounding of sums, MiniLM to about 1e-15.
  • MobileNetV3-Small runs in Python only (onnxruntime); R stops with a message for that choice. It has no parity case.
  • Without the downloaded MiniLM weights the text case stops with CS_WEIGHTS_MISSING in both engines (a counted skip); nothing is downloaded automatically.
Python

The exact script CodeSplash ran for example “Images thumbnail” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Features from a pretrained model (images, audio, text)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method transform.extract 1.0.0 · spec 0ffabb291139a11c
# Dataset: media_images (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import encoders
from codesplash import ml as csml

COLUMN = "path"
ENCODER = "thumbnail"
BATCH = int(32)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/media_images.parquet", columns=["path"])
n_input = len(df)
df["path"] = pd.Categorical(df["path"], categories=sorted(df["path"].dropna().unique()))
df = df.dropna(subset=["path"])  # listwise deletion over the analysis columns
df["path"] = df["path"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["path"])  # infinite values stop the run (registry/errors.yaml)
out = csml.out_dir("target/academy-parity/run-8142/transform.extract/images_thumbnail/out-python")
enc = encoders.get(ENCODER)
n, d = len(df), enc.dim
rows = df.index.to_numpy(dtype=np.int64)  # each row's position in the input
X = np.full((n, d), np.nan)
ok = np.zeros(n, dtype=bool)

# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
import json as _media_json
from codesplash import media as cs_media
media = cs_media.setup(_media_json.loads("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"column\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"stretch\",\"mode\":\"gray\",\"normalize\":\"none\",\"size\":[8,8]}}"), "target/academy-parity/run-8142/transform.extract/images_thumbnail/out-python", df, "tests/parity/fixtures/media_images.parquet")
media_ids = cs_media.ids_of(media, df)
# %% Encode the decoded files (each distinct file once; unreadable files get missing values)
status = cs_media.status(media, media_ids)
ok = np.array([s is None for s in status], dtype=bool)
if not ok.any():
    first = int(np.flatnonzero(~ok)[0])
    cs_media.fail(media, media_ids[first], status[first])
good = [m for m, o in zip(media_ids, ok) if o]
uniq = list(dict.fromkeys(good))
E = encoders.embed(ENCODER, media, BATCH, ids=uniq)
pos = {m: k for k, m in enumerate(uniq)}
X[ok] = E[[pos[m] for m in good]]
skipped = np.flatnonzero(~ok)
if len(skipped):
    warnings.append(cs.cs_warning("CS_W_MEDIA_SKIPPED", count=int(len(skipped)), total=int(n),
                                  file=str(df[COLUMN].iloc[int(skipped[0])])))

# %% Summary
Xo = X[ok]
norms = np.sqrt((Xo ** 2).sum(axis=1))
i_idx, j_idx = np.meshgrid(np.arange(Xo.shape[0]), np.arange(d), indexing="ij")
weights_grid = ((i_idx * 31 + j_idx * 7) % 13 + 1).astype(np.float64)
values = {
    "n_rows": int(n_input),
    "n_encoded": int(ok.sum()),
    "n_skipped": int((~ok).sum()),
    "dim": int(d),
    "encoder": enc.label,
    "modality": enc.modality,
    "mean_norm": float(norms.mean()),
    "checksum": float((Xo * weights_grid).sum()),
}
for j in range(min(8, d)):
    values[f"mean[{j + 1}]"] = float(Xo[:, j].mean())

emb = pd.DataFrame({"row": rows})
for j in range(d):
    emb[f"emb_{j + 1}"] = pd.array(X[:, j], dtype="Float64")
emb.to_parquet(f"{out}/embedding.parquet", index=False)

show = min(10, n)
k_show = min(4, d)
preview = []
for k in range(show):
    rec = {"row": int(rows[k]) + 1, "value": str(df[COLUMN].iloc[k])[:80]}
    for j in range(k_show):
        rec[f"emb_{j + 1}"] = None if not ok[k] else float(X[k, j])
    preview.append(rec)
tables = [{
    "key": "preview",
    "title": f"First {show} rows (first {k_show} of {d} features)",
    "columns": [{"key": "row", "label": "Row", "type": "integer"}, {"key": "value", "label": COLUMN, "type": "string"}]
    + [{"key": f"emb_{j + 1}", "label": f"Feature {j + 1}", "type": "number"} for j in range(k_show)],
    "rows": preview,
}]
summary = (f"{values['n_encoded']} of {values['n_rows']} rows were encoded with {enc.label} into {d} features each"
           + (f" ({values['n_skipped']} files couldn't be decoded and got missing values)" if values["n_skipped"] else "")
           + f"; the mean vector length is {values['mean_norm']:.3f}.")
statistics = [
    {"key": "n_encoded", "label": "Rows encoded", "value": values["n_encoded"]},
    {"key": "dim", "label": "Features per row", "value": d},
    {"key": "mean_norm", "label": "Mean vector length", "value": values["mean_norm"]},
]
cs.publish({
    "title": "Features from a pretrained model (images, audio, text)",
    "engine": cs.engine_info("numpy", "pandas"),
    "n": int(ok.sum()),
    "summary": summary,
    "statistics": statistics,
    "tables": tables,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "embedding", "path": f"{out}/embedding.parquet", "format": "parquet", "title": "Features (one row per input row)"}],
})
R

The exact script CodeSplash ran for example “Images thumbnail” · R version 4.5.1 (2025-06-13)

# Features from a pretrained model (images, audio, text)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method transform.extract 1.0.0 · spec 0ffabb291139a11c
# Dataset: media_images (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)
COLUMN <- "path"
ENCODER <- "thumbnail"
BATCH <- as.integer(32)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/media_images.parquet", col_select = c("path")))
n_input <- nrow(df)
df[["path"]] <- factor(df[["path"]], levels = sort(unique(df[["path"]]), method = "radix"))
df <- df[stats::complete.cases(df[c("path")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("path"))  # infinite values stop the run (registry/errors.yaml)
out <- cs_ml_out_dir("target/academy-parity/run-8142/transform.extract/images_thumbnail/out-r")
enc <- cs_encoder_get(ENCODER)
if (!("r" %in% enc$engines)) stop(sprintf("%s runs in Python only; choose another encoder in R.", enc$label), call. = FALSE)
n <- nrow(df); d <- enc$dim
rows <- as.integer(rownames(df)) - 1L  # each row's position in the input
X <- matrix(NA_real_, n, d)
ok <- rep(FALSE, n)

# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
media <- cs_media_setup(jsonlite::fromJSON("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"column\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"stretch\",\"mode\":\"gray\",\"normalize\":\"none\",\"size\":[8,8]}}", simplifyVector = FALSE), "target/academy-parity/run-8142/transform.extract/images_thumbnail/out-r", df,
                        "tests/parity/fixtures/media_images.parquet")
media_ids <- cs_media_ids(media, df)
# %% Encode the decoded files (each distinct file once; unreadable files get missing values)
status <- cs_media_status(media, media_ids)
ok <- is.na(status)
if (!any(ok)) {
  first <- which(!ok)[1]
  cs_media_fail(media, media_ids[first], status[first])
}
good <- media_ids[ok]
uniq <- unique(good)
E <- cs_encoder_embed(ENCODER, media, BATCH, ids = uniq)
X[ok, ] <- E[match(good, uniq), , drop = FALSE]
skipped <- which(!ok)
if (length(skipped)) {
  warnings <- c(warnings, cs_warning("CS_W_MEDIA_SKIPPED", count = length(skipped), total = n,
                                     file = as.character(df[[COLUMN]][skipped[1]])))
}

# %% Summary
Xo <- X[ok, , drop = FALSE]
norms <- sqrt(rowSums(Xo^2))
weights_grid <- outer(seq_len(nrow(Xo)) - 1, seq_len(d) - 1, function(i, j) ((i * 31 + j * 7) %% 13) + 1)
values <- list(
  n_rows = n_input,
  n_encoded = sum(ok),
  n_skipped = sum(!ok),
  dim = d,
  encoder = enc$label,
  modality = enc$modality,
  mean_norm = mean(norms),
  checksum = sum(Xo * weights_grid)
)
for (j in seq_len(min(8, d))) values[[sprintf("mean[%d]", j)]] <- mean(Xo[, j])

emb <- data.frame(row = rows)
for (j in seq_len(d)) emb[[sprintf("emb_%d", j)]] <- X[, j]
nanoparquet::write_parquet(emb, file.path(out, "embedding.parquet"))

show <- min(10, n)
k_show <- min(4, d)
preview <- lapply(seq_len(show), function(k) {
  rec <- list(row = rows[k] + 1L, value = substr(as.character(df[[COLUMN]][k]), 1, 80))
  for (j in seq_len(k_show)) rec[[sprintf("emb_%d", j)]] <- if (ok[k]) X[k, j] else NA
  rec
})
tables <- list(list(
  key = "preview",
  title = sprintf("First %d rows (first %d of %d features)", show, k_show, d),
  columns = c(list(list(key = "row", label = "Row", type = "integer"), list(key = "value", label = COLUMN, type = "string")),
              lapply(seq_len(k_show), function(j) list(key = sprintf("emb_%d", j), label = sprintf("Feature %d", j), type = "number"))),
  rows = preview
))
summary <- paste0(values$n_encoded, " of ", values$n_rows, " rows were encoded with ", enc$label, " into ", d, " features each",
                  if (values$n_skipped > 0) paste0(" (", values$n_skipped, " files couldn't be decoded and got missing values)") else "",
                  "; the mean vector length is ", sprintf("%.3f", values$mean_norm), ".")
statistics <- list(
  list(key = "n_encoded", label = "Rows encoded", value = values$n_encoded),
  list(key = "dim", label = "Features per row", value = d),
  list(key = "mean_norm", label = "Mean vector length", value = values$mean_norm)
)
cs_publish(list(
  title = "Features from a pretrained model (images, audio, text)",
  engine = cs_engine_info("nanoparquet", "jsonlite"),
  n = sum(ok),
  summary = summary,
  statistics = statistics,
  tables = tables,
  values = values,
  warnings = warnings,
  artifacts = list(list(key = "embedding", path = file.path(out, "embedding.parquet"), format = "parquet",
                        title = "Features (one row per input row)"))
))

Sources

  • Yosinski J, Clune J, Bengio Y, Lipson H (2014). How transferable are features in deep neural networks? NeurIPS 2014, 3320–3328.
  • Howard A, Sandler M, Chu G, et al. (2019). Searching for MobileNetV3. ICCV 2019, 1314–1324.
  • Reimers N, Gurevych I (2019). Sentence-BERT: Sentence embeddings using Siamese BERT-networks. EMNLP-IJCNLP 2019, 3982–3992.
  • Wang W, Wei F, Dong L, Bao H, Yang N, Zhou M (2020). MiniLM: Deep self-attention distillation for task-agnostic compression of pre-trained transformers. NeurIPS 2020.

From the CodeSplash method registry · transform.extract v1.0.0.