Draft
Conversation
Uploading a segmentation .pt with model_type="yolov11" (or any other detect↔seg/pose/cls/obb mismatch) previously succeeded silently and crashed at first inference. Same failure mode for rfdetr-* vs rfdetr-seg-*. Both `Version.deploy()` and `Workspace.deploy_model()` now: - Detect the .pt's task from the Ultralytics class name (SegmentationModel / PoseModel / etc.) or rfdetr's `args.segmentation_head` / future `args.task`. - Auto-append the correct suffix (YOLO) when the user omitted it, or raise ValueError on a conflict. `Version.deploy()` additionally cross-checks the model_type string against the Roboflow project type, catching cases like uploading `rfdetr-seg-medium` to an object-detection project. A single substring scanner (`_task_from_substring`) drives both the class-name check and the deploy model_type string parse. This keeps the logic future-proof — `rfdetr-pose-medium`, `rfdetr-obb-large`, etc. resolve to the right task the day they ship with zero SDK change. Also adds `TYPE_CLASSIFICATION` to `roboflow/config.py` (with the typo'd `TYPE_CLASSICATION` kept as a backwards-compat alias). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Uploading a segmentation
.ptwithmodel_type="yolov11"(or any other detect↔seg/pose/cls/obb mismatch) previously succeeded silently and crashed at first inference withValueError: not enough values to unpack (expected 2, got 1). Same failure mode forrfdetr-*vsrfdetr-seg-*. The.ptalways knew its task — nothing in the SDK or the server conversion was reading it.This change adds client-side task validation on two axes:
.pt↔model_typereconciliation insidemodel_processor.process():type(model_instance).__name__(SegmentationModel/PoseModel/ClassificationModel/OBBModel/DetectionModel) — works across v8/v10/v11/v12/yolo26.args.segmentation_headtoday, with anargs.taskstring path already wired in for future rfdetr-pose/obb/cls variants.model_type="yolov11"+ seg.pt→"yolov11-seg"). RaisesValueErroron conflict.model_type↔ project type cross-check insideVersion.deploy(). Catches uploads likerfdetr-seg-mediumto an object-detection project. Not added toWorkspace.deploy_model()since that path takes aproject_idslist and would need extra fetches.A single substring scanner (
_task_from_substring) drives the class-name check, the rfdetrargs.taskpath, and the deploymodel_typeparse — keeping the logic future-proof (rfdetr-pose-medium, rfdetr-obb-large, etc. resolve correctly with zero SDK change when they ship).Also adds
TYPE_CLASSIFICATIONtoroboflow/config.py; the typo'dTYPE_CLASSICATIONis retained as a backwards-compat alias.Changes
roboflow/util/model_processor.py— new helpers (_task_from_substring,task_of_model_type,_detect_task_from_pt);_process_yoloand_process_rfdetrreconcile model_type against the loaded.pt;process()now returns(zip_file_name, model_type)so callers can use the corrected value.roboflow/core/version.py— unpack tuple, call new_validate_against_project_type.roboflow/core/workspace.py— unpack tuple.roboflow/config.py— addTYPE_CLASSIFICATION.tests/util/test_model_processor.py(new) — 15 cases coveringtask_of_model_typeand_detect_task_from_ptincluding future-proofing for rfdetr-pose/obb.tests/test_version.py— 11 cases covering_validate_against_project_type.Test plan
python -m unittest— 446/446 passruff check roboflow— cleanruff format roboflow— applied.ptwithmodel_type="yolov11"on a segmentation project →model_artifacts.jsoncontains"model_type": "yolov11-seg", upload URL usesmodelType=yolov11-seg, inference returns masks.ptwithmodel_type="yolov11-pose"→ValueErrorat clientmodel_type="yolov11-seg"on a detection project →ValueErrorat client.pt+model_type="yolov11"on a detection project deploys cleanly.pt+model_type="rfdetr-medium"→ValueError(readsargs.segmentation_head=True)model_type="rfdetr-seg-medium"on a detection project →ValueError🤖 Generated with Claude Code