feat(sam3): add class_mapping support to SAM3 v3 block#2196
Open
felipe-tomino wants to merge 2 commits intomainfrom
Open
feat(sam3): add class_mapping support to SAM3 v3 block#2196felipe-tomino wants to merge 2 commits intomainfrom
felipe-tomino wants to merge 2 commits intomainfrom
Conversation
Add an optional `class_mapping` parameter to the SAM3 v3 workflow block
that remaps prediction class names before returning results.
This enables Rapid to send English prompts to SAM3 for optimal detection
while returning the user's original class names (e.g., non-English terms)
in the API response. For example, SAM3 detects with prompt "cat" but
returns predictions with class "gato" when class_mapping={"cat": "gato"}.
18b8cb0 to
6719d7c
Compare
dkosowski87
reviewed
Apr 2, 2026
Contributor
dkosowski87
left a comment
There was a problem hiding this comment.
Could we add also a test for the whole workflow block with this scenario pls.
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.
Summary
Adds an optional
class_mappingparameter to theroboflow_core/sam3@v3workflow block that remaps prediction class names before returning results.Use case: Rapid's non-English users type class names like "gato" (Spanish for cat). SAM3 works best with English prompts, so Rapid sends "cat" as the prompt but needs the API to return predictions with
class: "gato"— what the user expects.How it works:
class_mapping: Dict[str, str](e.g.,{"cat": "gato"})class_namevalues are remappedNonedefault — no behavior change for existing workflowsChanges
inference/core/workflows/core_steps/models/foundation/segment_anything3/v3.pyclass_mappingfield toBlockManifestclass_mappingparameter torun()method_apply_class_mapping()static method that remapsclass_nameinsv.Detectionsdatatests/workflows/unit_tests/core_steps/models/foundation/test_segment_anything3_v3.py(new)Test plan
pytest tests/workflows/unit_tests/core_steps/models/foundation/test_segment_anything3_v3.py