Skip to navigation

Predict TIMM

Runs on: gpu Dockerfile
First run can take longer while the worker pulls the configured Docker image.

Overview

Classifies every image in a dataset and saves the predicted class as an annotation in the output dataset: an image tag named after the class, with the score on a confidence tag beside it.

Pick a Destination dataset to add the predictions to a dataset you already have, such as a labeling pool or an active-learning set. Existing assets are kept, and new predictions replace any previous annotations for the same image. Leave it empty and the node writes into a dataset of its own, one version per run.

Predict with a classifier you trained here, or with a public ImageNet checkpoint when you just want to see what a generic model makes of your images.

The badge counts the annotated images and opens the output dataset.

Train TIMM Predict TIMM Evaluate classifier
  • resnet50
  • resnet101
  • efficientnet_b0
  • efficientnet_b1
  • efficientnet_b2
  • efficientnet_b3
  • efficientnet_b4
  • efficientnetv2_s
  • efficientnetv2_m
  • efficientnetv2_l
  • mobilenetv3_large_100
  • mobilenetv3_small_100
  • convnext_tiny
  • convnext_small
  • convnext_base
  • convnext_large
  • vit_small_patch16_224
  • vit_base_patch16_224
  • vit_large_patch16_224
  • swin_tiny_patch4_window7_224
  • swin_small_patch4_window7_224
  • swin_base_patch4_window7_224
  • deit_small_patch16_224
  • deit_base_patch16_224

Prerequisites

RequirementWhat you need
GPU workerA worker with a GPU.
Image datasetAn existing Dataset with images.
A model to runA model of this workspace or the zoo, picked in Model. Train TIMM produces one, and the picker copies a zoo entry in.

How it works

1

Fetches the selected model’s weights, checks them with the safe-weights check, and loads them onto the GPU.

2

Creates the output dataset and adds the source images to it.

3

Classifies the images in batches and keeps the predicted class for each one.

4

Writes the predictions as annotations and shows how many images were annotated on the badge.

FAQ

No. Predictions land in the output dataset and the source keeps whatever it already had.

Replace leaves only the new predictions in the output dataset, which is what you want before an evaluation node. Keep both carries the input annotations over next to the predictions, which is what you want when comparing them side by side.

The 1000 ImageNet classes. That is useful for a quick sanity check or for coarse sorting, but it will not name your own categories, which is why most runs pick a model trained here.

Every image the model scores above the confidence threshold does. Raise the threshold to leave uncertain images unannotated instead of forcing a guess.

Run the matching evaluation node against a ground-truth dataset. Prediction alone reports how many images were annotated, not how correct the annotations are.

Yes, through Apply model. It reads the framework off the model asset and dispatches to this node, which is what you want when the model is only picked at runtime.

Inputs

Dataset
datasetRequired

Dataset whose images are classified. Predictions are added to the output dataset, not to this one. Key: DATASET.

Destination dataset
dataset

Dataset the predictions are added to, keeping what it already holds. An image it already annotates gets the new prediction instead. Leave empty to use the node’s own output dataset, which a rerun writes a new version of. Key: DST_DATASET.

Model
modelRequired

Model to run inference with, from this workspace or the zoo. The node is handed the resolved version and runs on its weights: the model stored for it (safetensors with its config.json, or an ONNX graph), or the published weights its zoo tag names, downloaded and checked against their SHA-256. Weights go through the safe-weights check before anything loads them, so with the policy on a pickle is refused until it is converted. Only versions with a class vocabulary are offered, a backbone has to be fine-tuned before it can predict. Key: MODEL.

Predict classes
ontology

Classes to keep in predictions. Images classified as other classes are skipped. Leave empty to keep all classes. Values come from MODEL. Key: CLASSES.

Config
yamlRequired

Number of images the model runs on at once, written as batch_size. Larger batches are faster on a GPU with spare memory. Key: CONFIG.

Download batch size
integerDefaults to 64Required

Number of images downloaded at once while the model works through the previous batch. Raise it when downloads, not inference, are the bottleneck. Minimum: 1. Key: DOWNLOAD_BATCH_SIZE.

Prefetch batches
integerDefaults to 4Required

Number of downloaded batches allowed to wait on disk ahead of the model. Higher values keep the GPU fed but use more disk space. Minimum: 1. Key: PREFETCH_BATCHES.

Outputs

Output Dataset
dataset

Dataset with the input images plus the classifier prediction annotations: the destination dataset when one is picked, otherwise the node’s own. Shown as an artifact. Key: OUTPUT_DATASET.

Predicted
string

Number of images annotated. Shown on the node as a badge. Selecting the badge opens OUTPUT_DATASET. Key: PRED_COUNT.

Models and configuration

Model is the one place the weights come from: a model of this workspace, or one of the zoo entries listed above. The node is handed the resolved version and runs on its weights — the model stored for it, or the published weights of its zoo tag, downloaded and checked against their SHA-256 for an entry that hosts none.

A zoo entry predicts the 1000 ImageNet classes rather than yours, so most runs pick a model trained here.

Classes narrows the output to the listed class names. Config holds the inference settings, including the confidence threshold and the batch size.

Runtime

The node runs in its own GPU container. The first run takes longer while the worker pulls the image and downloads the selected weights.

Images are fetched ahead of the model to keep the GPU busy. Download Batch Size sets how many arrive at once and Prefetch Batches how many wait on local disk, so raise them for fast storage and lower them when disk is tight.

JSON config

Machine-readable node interface for automation and advanced usage.

{
"name": "Predict TIMM",
"description": "Run inference with a trained classification model on a dataset and write the images and the classifier prediction annotations into the output dataset.",
"category": "Predict",
"namespace": null,
"templateKey": "models/timm/predict_timm",
"version": "v1",
"inputs": [
{
"key": "DATASET",
"label": "Dataset",
"type": "dataset",
"description": "Dataset whose images are classified. Predictions are added to the output dataset, not to this one.",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"creatable": false
}
},
{
"key": "DST_DATASET",
"label": "Destination dataset",
"type": "dataset",
"description": "Dataset the predictions are added to, keeping what it already holds. An image it already annotates gets the new prediction instead. Leave empty to use the node's own output dataset, which a rerun writes a new version of.",
"required": false,
"default": null,
"visibleWhen": null
},
{
"key": "MODEL",
"label": "Model",
"type": "model",
"description": "Model to run inference with, from this workspace or the zoo. The node is handed the resolved version and runs on its weights: the model stored for it (safetensors with its config.json, or an ONNX graph), or the published weights its zoo tag names, downloaded and checked against their SHA-256. Weights go through the safe-weights check before anything loads them, so with the policy on a pickle is refused until it is converted. Only versions with a class vocabulary are offered; a backbone has to be fine-tuned before it can predict.\n",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"framework": "timm",
"task_type": "classification",
"has_classes": "true"
}
},
{
"key": "CLASSES",
"label": "Predict classes",
"type": "ontology",
"description": "Classes to keep in predictions. Images classified as other classes are skipped. Leave empty to keep all classes.",
"required": false,
"default": null,
"visibleWhen": null,
"options": {
"ref": "MODEL",
"selectable": true
}
},
{
"key": "CONFIG",
"label": "Config",
"type": "yaml",
"description": "Number of images the model runs on at once, written as `batch_size`. Larger batches are faster on a GPU with spare memory.",
"required": true,
"default": "batch_size: 64\n",
"visibleWhen": null
},
{
"key": "DOWNLOAD_BATCH_SIZE",
"label": "Download batch size",
"type": "number",
"description": "Number of images downloaded at once while the model works through the previous batch. Raise it when downloads, not inference, are the bottleneck.",
"required": true,
"default": 64,
"visibleWhen": null,
"options": {
"type": "integer",
"min": 1
}
},
{
"key": "PREFETCH_BATCHES",
"label": "Prefetch batches",
"type": "number",
"description": "Number of downloaded batches allowed to wait on disk ahead of the model. Higher values keep the GPU fed but use more disk space.",
"required": true,
"default": 4,
"visibleWhen": null,
"options": {
"type": "integer",
"min": 1
}
}
],
"outputs": [
{
"key": "OUTPUT_DATASET",
"label": "Output Dataset",
"type": "dataset",
"description": "Dataset with the input images plus the classifier prediction annotations: the destination dataset when one is picked, otherwise the node's own.",
"artifact": true,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "PRED_COUNT",
"label": "Predicted",
"type": "string",
"description": "Number of images annotated.",
"artifact": false,
"badge": true,
"badgeOpens": "OUTPUT_DATASET",
"hidden": false
}
],
"runtime": {
"type": "docker",
"devices": [
"gpu"
],
"dockerImage": "ovalbee/node-classifier-inference:0.0.27"
},
"widgets": {
"widget": {
"id": "asset-preview",
"settings": {
"datasetId": {
"type": "variable",
"value": "self.outputs.OUTPUT_DATASET"
}
}
}
}
}

References