feat(cli): adapt raw rf-detr PyTorch-Lightning checkpoints on upload#488
Conversation
Add RFDETR.save_upload_bundle(output_dir) — the network-free core of
deploy_to_roboflow that writes weights.pt ({"model": state_dict, "args": args},
args carrying resolution + embedded class_names) and class_names.txt. Refactor
deploy_to_roboflow to call it; net behavior unchanged.
This gives the Roboflow SDK a single, drift-free way to turn raw PyTorch-Lightning
rf-detr checkpoints into a deploy-ready bundle (companion: roboflow/roboflow-python#488).
Also updates TestDeployToRoboflow, whose MagicMock(spec=RFDETR) fixture was
no-op'ing the now-delegated save_upload_bundle; the real method is bound so those
end-to-end regression tests still exercise it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
318dfbc to
db28572
Compare
Add RFDETR.save_upload_bundle(output_dir) — the network-free core of
deploy_to_roboflow that writes weights.pt ({"model": state_dict, "args": args},
args carrying resolution + embedded class_names) and class_names.txt. Refactor
deploy_to_roboflow to call it; net behavior unchanged.
This gives the Roboflow SDK a single, drift-free way to turn raw PyTorch-Lightning
rf-detr checkpoints into a deploy-ready bundle (companion: roboflow/roboflow-python#488).
Also updates TestDeployToRoboflow, whose MagicMock(spec=RFDETR) fixture was
no-op'ing the now-delegated save_upload_bundle; the real method is bound so those
end-to-end regression tests still exercise it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add RFDETR.export_for_roboflow(output_dir) — the network-free core of
deploy_to_roboflow that writes weights.pt ({"model": state_dict, "args": args},
args carrying resolution + embedded class_names) and class_names.txt. Creates
output_dir if missing. Refactor deploy_to_roboflow to call it; net behavior
unchanged.
Gives the Roboflow SDK a single, drift-free way to turn raw PyTorch-Lightning
rf-detr checkpoints into a deploy-ready bundle (companion: roboflow/roboflow-python#488).
Also updates TestDeployToRoboflow, whose MagicMock(spec=RFDETR) fixture was
no-op'ing the now-delegated method; the real method is bound so those end-to-end
regression tests still exercise it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
7150b7c to
8f5fc73
Compare
11f7758 to
6ebc5fa
Compare
|
Status: ❌ Request Changes — Gist: https://gist.github.com/jarbasrf/4ae989bfd95f2b470e183560724d5a53. Resumo: The raw rf-detr upload path ignores the caller-provided |
d89c8d7 to
f11b48b
Compare
PR Review: feat(cli): adapt raw rf-detr PyTorch-Lightning checkpoints on uploadGenerated by Codex via roboflow-review-pr. Review is advisory; verify before merging. Metadata:
📋 SummaryThe prior filename-selection issue is resolved at current head: I found one current-head blocker. The PR enables raw PyTorch-Lightning rf-detr checkpoints via Previous review context:
🏗️ Architectural ReviewThe adapter boundary is mostly right: the SDK keeps rf-detr-specific bundle adaptation in flowchart LR
A[CLI or SDK deploy] --> B[process model_type]
B --> C[_process_rfdetr]
C --> D[select checkpoint filename]
D --> E[torch.load checkpoint]
E --> F[detect rf-detr task]
F --> G{task matches model_type?}
G -- no --> H[raise ValueError]
G -- yes --> I{PTL checkpoint?}
I -- no --> J[legacy class_names + weights.pt]
I -- yes --> K[RFDETR.from_checkpoint]
K --> L[export_for_roboflow]
J --> M[roboflow_deploy.zip]
L --> M
M --> N[project type validation]
N --> O[upload endpoint]
The risky boundary is the 🐛 Code Quality Issues1.
|
dcc6fed to
5fe1f34
Compare
Detect a raw PTL rf-detr checkpoint (`pytorch-lightning_version` key) in _process_rfdetr and rebuild it into an upload-ready bundle: lazy-import rfdetr (capability-guarded on RFDETR.export_for_roboflow), load via RFDETR.from_checkpoint, falling back to an SDK-local model_type→class map (_RFDETR_MODEL_TYPE_TO_CLASS — also the single source for the supported-type check) when the checkpoint lacks the metadata rf-detr needs to infer its class, then call export_for_roboflow to write weights.pt (args with resolution) + class_names.txt. The legacy path is unchanged and imports no rfdetr. Depends on rf-detr's export_for_roboflow (roboflow/rf-detr#1086); capability- guarded so it works once that release ships. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5fe1f34 to
5c381f2
Compare
PR Review: feat(cli): adapt raw rf-detr PyTorch-Lightning checkpoints on uploadGenerated by Codex via roboflow-review-pr. Review is advisory; verify before merging. Metadata:
📋 SummaryI did a clean-slate review of the current PR head ( Previous review context:
🏗️ Architectural ReviewThe change is in the right boundary: flowchart LR
A[upload_model or deploy] --> B[process model_type]
B --> C[_process_rfdetr]
C --> D[select checkpoint]
D --> E[torch.load]
E --> F[detect checkpoint task]
F --> G{task matches model_type}
G -- no --> H[raise ValueError]
G -- yes --> I{Lightning checkpoint}
I -- no --> J[legacy class_names + weights.pt]
I -- yes --> K[require rfdetr >= 1.8.0]
K --> L[from_checkpoint or model_type fallback]
L --> M[export_for_roboflow]
J --> N[roboflow_deploy.zip]
M --> N
N --> O[project type validation]
O --> P[upload]
The key contracts line up:
🐛 Code Quality IssuesNo correctness, architecture, or test-quality issues found at current PR head. 💡 Recommendations
🧪 TestsStrongest coverage is in Important covered behaviors:
Local verification:
⚖️ Verdict — ✅ ApproveThe current head fixes the prior rf-detr issues and adds focused regression coverage for both. I did not find a current blocker in the raw PyTorch-Lightning adaptation path. Timestamp: 2026-07-07 18:07:40 UTC |
What does this PR do?
Lets
roboflow upload_modelaccept raw rf-detr PyTorch-Lightning checkpoints (e.g.checkpoint_best_ema.pth) and adapt them into the upload-ready bundle the backend conversion expects.In
_process_rfdetr, after loading the checkpoint:pytorch-lightning_versionkey (_is_ptl_checkpoint).rfdetr(capability-guarded onRFDETR.export_for_roboflow; actionableRuntimeErrorif missing/too old — mirrors the ultralytics/yolo pattern).RFDETR.from_checkpoint(pth), falling back to the SDK-localmodel_type→class map (_RFDETR_MODEL_TYPE_TO_CLASS) when the checkpoint lacks the metadata rf-detr needs to infer its class (nomodel_name/pretrain_weights).model.export_for_roboflow(model_path)writesweights.pt(args withresolution) +class_names.txt.rfdetr.Related Issue(s): Requires
rfdetr>=1.8.0, which shipsexport_for_roboflow(roboflow/rf-detr#1086, released in 1.8.0).RFDETR_MIN_VERSIONis pinned to1.8.0.Type of Change
Testing
Test details:
Checklist