Skip to content

Auto Label with a saved Workflow from the SDK and the CLI - #594

Open
iurisilvio wants to merge 10 commits into
mainfrom
iuri/autolabel-workflow-jobs
Open

iurisilvio wants to merge 10 commits into
mainfrom
iuri/autolabel-workflow-jobs

Conversation

@iurisilvio

@iurisilvio iurisilvio commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

You can now start an Auto Label job that runs a saved Workflow, from the SDK (model_type="workflow") and the CLI (--model-type workflow), to label a batch with SAHI, model ensembles or any logic you built in Workflows. Both also take Label by Example's labeled images (#595, merged into this branch).

The public start route (POST /:workspace/:project/autolabel) already takes these jobs the way the web app sends them: modelType: "workflow" with workflowId, workspaceName, selectedOutputName, classMapping, inputValues and imageInputName. The SDK could not send any of them.

Changes

  • Project.autolabel(..., model_type="workflow") takes the Workflow's URL slug as model (the url column of roboflow workflow list), workflow_output (the output that holds the predictions) and class_mapping ({workflow class: project class}), plus the optional workflow_inputs and workflow_image_input.
  • rfapi.start_autolabel_job sends them as workflowId, selectedOutputName, classMapping, inputValues and imageInputName, with workspaceName set to the workspace in the URL (the API resolves the Workflow there).
  • The route refuses a Workflow job without a threshold for every project class the mapping targets, and does not fill them in from defaultConfidence. So confidence (0.5 when omitted, the web app's default) is applied to each mapped class unless confidence_thresholds is given.
  • roboflow autolabel start takes --workflow-output, --class-mapping and --workflow-inputs (inline JSON or @file), and --workflow-image-input.
  • A Workflow job without workflow_output or class_mapping, or Workflow options with another model type, raises ValueError before any request (exit 1 in the CLI).
  • CLI-COMMANDS.md gets an example. The changelog entries of this PR and of Label by Example in Project.autolabel and the CLI #595 are under a new ## Unreleased, because 1.7.5 was released without them.
project.autolabel(
    batch_id="batch-1",
    model="vehicle-detector",
    model_type="workflow",
    workflow_output="predictions",
    class_mapping={"car": "vehicle", "truck": "vehicle"},
    confidence=0.4,
)
roboflow autolabel start -p cars --batch-id batch-1 -m vehicle-detector --model-type workflow \
  --workflow-output predictions --class-mapping '{"car": "vehicle", "truck": "vehicle"}' --confidence 0.4

The job runs the Workflow's published version, not its draft. The API checks that the Workflow and its output exist before it creates the job (WORKFLOW_UNAVAILABLE, no credits used). An OAuth app limited to project folders cannot start a Workflow job (FOLDER_SCOPED_TOKEN_REFERENCE); the SDK signs in with API keys, so this does not affect it.

The MCP server gets the same changes in roboflow/roboflow-mcp#398. The docs are roboflow/docs#716 (saved Workflows) and roboflow/docs#717 (Label by Example), both merged.

Label by Example (#595)

roboflow/roboflow#20350 (merged 12-01) opened Label by Example on the public Auto Label API: referenceExamples: [{"imageId": "..."}] on the start and preview routes, and takesReferenceExamples in the models list. The server reads each image's boxes of the job's classes from the project.

  • Project.autolabel(..., reference_examples=[...]) and Project.autolabel_preview(..., reference_examples=[...]) take the image ids; rfapi sends them as referenceExamples. A single id string is one example, not one per character.
  • roboflow autolabel start and preview take --reference-example <image-id>, repeated for up to 10.
  • roboflow autolabel models adds an EXAMPLES column, and Workspace.autolabel_models() documents takesReferenceExamples.

An example must be in the project's dataset (not only in a batch or in review) with a box of the job's classes. Otherwise the API answers REFERENCE_EXAMPLE_NOT_FOUND (404) or INVALID_REFERENCE_EXAMPLES (400), and the SDK passes those errors on as they are.

Not in this PR

  • A preview for a Workflow job: autolabel_preview takes catalog models only.

Testing

  • python -m unittest on bc65444, with main (1.7.5) merged in: 1331 tests pass (1 skipped), including new ones for resolve_workflow, the request body start_autolabel_job sends, Project.autolabel with Workflow options, and the CLI (mapping from @file, threshold fan-out, missing output, Workflow flags on a foundation model), and for the examples payload, the Project methods, the --reference-example flag and the models table.
  • make check_code_quality (ruff and mypy) is clean.
  • Not run against a live API: the tests check the request body against what the route validates (workflowJobFields.js and findWorkflowClassMappingError in the monorepo).

🤖 Generated with Claude Code

iurisilvio and others added 4 commits November 30, 2026 15:00
Project.autolabel(size_filter=...) and `roboflow autolabel start
--min-width/--max-width/--min-height/--max-height` send the API's
sizeFilter, which drops labels whose box is outside those sizes.

The Auto Label docs now cover the catalog's keypoint models
(gemini-4-argon-keypoints, ...), which ignore
keypoint_confidence_threshold, and use listed model ids in examples
(gpt-6-astra-boxes is unlisted since GPT-6.2 Astra replaced it).
`autolabel models` shows the project types each model labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Project.autolabel(model="<workflow-url>", model_type="workflow",
workflow_output=..., class_mapping=...) and `roboflow autolabel start
--model-type workflow --workflow-output ... --class-mapping ...` start
the public route's saved-Workflow job (modelType "workflow"), which
neither client could send before.

The route requires workspaceName, selectedOutputName, classMapping and
a numeric threshold for every class the mapping writes, and it does not
fan defaultConfidence out for a Workflow job. So the adapter sends the
route's workspace as workspaceName, and `confidence` (0.5 when omitted,
the web app's start value) is fanned out over the mapped project classes
unless confidence_thresholds is given. A Workflow job without an output
or a class mapping, or a Workflow option on another model type, is a
ValueError before any request: a catalog model's job would otherwise
take a classMapping it was not meant to get.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iurisilvio and others added 2 commits December 2, 2026 11:16
#593 merged into main as the squash 444db7a, whose tree equals its last
head c5b1580, which this branch already has. Merging it with -s ours
changes no file and moves the merge base past the squash, so the merge
of main below conflicts only where main changed since.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iurisilvio
iurisilvio changed the base branch from iuri/autolabel-sync-size-filter-keypoints to main December 2, 2026 10:18
The PR now targets main; the retarget alone does not start the test
workflow, which runs only for pull requests into main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iurisilvio added a commit that referenced this pull request Dec 2, 2026
…ples

Brings in main (with the squash of #593 recorded) through #594's branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iurisilvio iurisilvio self-assigned this Dec 2, 2026
@iurisilvio
iurisilvio requested a review from a team December 2, 2026 11:00
iurisilvio and others added 3 commits December 3, 2026 13:08
* Take Label by Example's reference examples in the SDK and the CLI

Project.autolabel and autolabel_preview take reference_examples, the ids of
labeled images of the project the model sees as examples, and the CLI takes
--reference-example on start and preview. autolabel models marks the models
that take them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Link the Label by Example changelog entry to #595

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.7.5 was released without #594 and #595, and the merge of main put their
entries under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant