Instructions to use CAIR-HKISI/SurgMotion-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CAIR-HKISI/SurgMotion-Preview with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "visual-question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("visual-question-answering", model="CAIR-HKISI/SurgMotion-Preview")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("CAIR-HKISI/SurgMotion-Preview", device_map="auto") - Notebooks
- Google Colab
- Kaggle
SurgMotion: surgical phase recognition and QA
Releases follow task/dataset-model-release_date/. The date 20261112 means
this organization/release date; it does not claim a checkpoint training date.
This private repository retains its existing Hub ID for download compatibility.
Releases
| Task | Dataset | Model | Release directory | Checkpoint type |
|---|---|---|---|---|
| Phase recognition | Multiple surgical phase datasets | CASA ep3 | phase/multidataset-casa-ep3-20261112/ |
Full weights |
| QA | ORena FOCUS | CASA v6 | qa/orena-focus-casa-v6-20261112/ |
Stage 1 and Stage 2 PEFT adapters |
| QA | MSQA / MedStreamBench | CASA dense S24 | qa/msqa-casa-dense-s24-20261112/ |
Full weights; standalone inference |
phase/
multidataset-casa-ep3-20261112/
model-*.safetensors # retained ep3 weights
config.json, tokenizer*, ...
stream_train_meta.json
*.py # CASA architecture and inference.py
INFERENCE.md
requirements.txt
qa/
orena-focus-casa-v6-20261112/
checkpoints/stage1_epoch4/
checkpoints/stage2_epoch2/ # final QA adapter
code/ # infer.py, model.py, route.py, run_infer.sh
README.md
RELEASE_MANIFEST.json
BASE_MODEL_NOTICE, ROUTING_LICENSE
msqa-casa-dense-s24-20261112/
checkpoint/ # full train-only S24 dense seed0 weights
code/ # independent evidence-window inference
README.md, VALIDATION.json, RELEASE_MANIFEST.json
multidataset covers the 10 phase datasets: pmlr50, autolaparo, m2cai16,
mb_bern, mb_stras, cholec80, pitvis, renji_colorectal, renji_esophageal and
renji_gastric_cancer. QA releases cover ORena FOCUS and MSQA. These are separate datasets and protocols.
Phase weights come from the former ep3/; the QA release comes from the former
casa-v6/. All weights, architecture files and original training metadata are
preserved byte-for-byte. The QA runtime, licenses and original manifest are also
unchanged. See RELEASES.json for path mappings and provenance.
Quick start
Authenticate with hf auth login or HF_TOKEN, then download one task release.
# Phase recognition
hf download CAIR-HKISI/SurgMotion-Phase2 --include "phase/multidataset-casa-ep3-20261112/*" --local-dir ./SurgMotion-Phase2
cd SurgMotion-Phase2
pip install -r phase/multidataset-casa-ep3-20261112/requirements.txt
python phase/multidataset-casa-ep3-20261112/inference.py --model-dir ./phase/multidataset-casa-ep3-20261112 --image frame.jpg --procedure cholecystectomy
# ORena FOCUS QA; use the ms-swift environment described in its README.
hf download CAIR-HKISI/SurgMotion-Phase2 --include "qa/orena-focus-casa-v6-20261112/*" --local-dir ./SurgMotion-Phase2
cd SurgMotion-Phase2/qa/orena-focus-casa-v6-20261112
CASA_BASE_MODEL=/path/to/CASA-Qwen2_5-VL-3B bash code/run_infer.sh input.jsonl predictions.jsonl
MSQA includes full weights and an independent evidence-window runtime. Its completed in-domain val383 score is 78.93/100 (DeepSeek Flash, score_v2); it is not an official leaderboard result. This checkpoint has not been evaluated on test. See its README for the JSONL input format and exact protocol.
hf download CAIR-HKISI/SurgMotion-Phase2 --include "qa/msqa-casa-dense-s24-20261112/*" --local-dir ./SurgMotion-Phase2
cd SurgMotion-Phase2/qa/msqa-casa-dense-s24-20261112
pip install -r requirements.txt
# Install matching CUDA/PyTorch flash-attn; tested with flash-attn 2.8.1.
python code/inference.py --input /path/to/requests.jsonl --output /path/to/predictions.jsonl
For ORena FOCUS QA inference, load only the Stage 2 adapter. It already includes
the Stage 1 trained ViT blocks. Download the CASA base weights separately.
Root inference.py forwards to the phase entry point.
Phase evaluation
The retained ep3 model uses 47 phase classes, cap 3600, chunk 240, 17 blank
readout slots, frozen ViT and 4096–65536 pixels. Its original training protocol
and hashes remain in stream_train_meta.json.
| Model | Raw acc | Raw macro-F1 | Raw edit | Smooth acc | Smooth macro-F1 |
|---|---|---|---|---|---|
| CASA ep3 | 0.8627 | 0.7936 | 0.1728 | 0.8696 | 0.8005 |
These previously reported val metrics average equally over 10 datasets and exclude three inconsistent classes. Val has 47 videos / 175,366 frames, with 171,444 scored frames. Smoothing uses radius 20. QA results have their own protocol and are documented in the QA release README.
The phase reference script uses blank readout and constrained decoding. Video
mode keeps history only inside each packed chunk; KV is not shared between
chunks. For reproducible evaluation, use the research phase2 eval driver
with checkpoint metadata, the protocol-hash gate, excluded classes and smoothing.
License and intended use
- Base weights CASA-Qwen2_5-VL-3B are released under CC-BY-NC-SA 4.0 (non-commercial, share-alike). These fine-tuned derivatives inherit the same terms.
- The base model also includes Qwen2.5-VL-3B weights, subject to the Qwen RESEARCH LICENSE AGREEMENT.
- Training corpora are academic-use surgical video datasets (CholecT45 and others, each with its own source license). Downstream use must comply with those terms.
- Custom architecture code bundled in each subfolder comes from the base repo (MIT).
- Non-commercial research use only. No clinical / diagnostic deployment.
The VQA release additionally includes qa/orena-focus-casa-v6-20261112/BASE_MODEL_NOTICE and
qa/orena-focus-casa-v6-20261112/ROUTING_LICENSE; keep those notices with redistributed code.
Triplet release (2026-11-16)
Added triplet/cholect45-casa-slots-ep8-20261116/: full CASA fixed-slot weights, cumulative8 epochs; local validation IVT47 36.70%, support≥20 IVT40 42.13%. See the release README for class-set definitions, inference and provenance. These are local validation metrics, not official CholecT45 test results. Existing Phase/QA releases are unchanged.
Streaming captioning
SurgLaVi CASA LiveCC epoch 4 provides full weights, the validation-selected decoder settings, and an MP4-to-JSONL inference script.