Repository navigation
Add existing_annotations (replace, preserve, merge) to Project.autolabel and the CLI - #570
Merged
Merged
Conversation
The Auto Label API takes mergeExistingAnnotations: keep the annotations already on the batch images and add only the predictions that don't overlap an existing annotation of the same class (IoU >= 0.5). Project.autolabel(merge_existing_annotations=True) and `roboflow autolabel start --merge-existing` send it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Project.autolabel takes existing_annotations="replace" | "preserve" | "merge" and the CLI takes --existing-annotations, the same three modes the server has. preserve_existing_annotations still works with a DeprecationWarning, and --preserve-existing is a hidden alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to the value An empty --existing-annotations (ex: an unset $MODE) now fails like any other unknown mode instead of falling back to replace. preserve_existing_annotations=False now points to existing_annotations="replace", not "preserve". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…existing # Conflicts: # CHANGELOG.md # CLI-COMMANDS.md # roboflow/adapters/rfapi.py # roboflow/cli/handlers/autolabel.py # roboflow/core/project.py # tests/adapters/test_autolabel.py # tests/cli/test_autolabel_handler.py # tests/test_project_autolabel.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Auto Label has three ways to handle images that already have annotations: replace them, preserve them and add every prediction, or merge (roboflow/roboflow#18427, in production since 2026-10-27). Merge keeps the existing annotations and adds only the predictions that don't overlap an existing annotation of the same class (IoU of at least 0.5), so objects that are already labeled aren't duplicated.
The SDK and the CLI take the mode as one parameter with the server's three values, instead of one boolean per mode:
Project.autolabel(..., existing_annotations="replace" | "preserve" | "merge").Nonesends nothing, so the server default (replace) applies, as before.roboflow autolabel start --existing-annotations replace|preserve|merge. An unknown value is a structured error (exit code 1) before any request.rfapi.start_autolabel_job(..., existing_annotations=...)turns the mode into the API's booleans throughexisting_annotations_flagsinroboflow/util/autolabel_utils.py. Merge sendspreserveExistingAnnotationsandmergeExistingAnnotations, the way the web app does, so a server without merge would still keep the annotations.Existing callers keep working:
Project.autolabel(..., preserve_existing_annotations=True)still preserves and raises aDeprecationWarning.existing_annotationswins when both are set.--preserve-existingis a hidden alias of--existing-annotations preserve.CLI-COMMANDS.mdandCHANGELOG.md(Unreleased: Added and Deprecated) describe the new option.Type of change
How has this change been tested?
Project.autolabelwith the new parameter and with the deprecated flag, and the CLI option, the hidden alias and an unknown value.python -m unitteston Python 3.12: 1277 tests OK (1 skipped).ruff format --check,ruff checkandmypy robofloware clean.Any specific deployment considerations
None. The API already accepts both flags in production. The MCP server gets the same
existing_annotationsparameter in roboflow/roboflow-mcp#266.🤖 Generated with Claude Code