Chain-of-Look Spatial Reasoning for Dense Surgical Instrument Counting
Rishikesh Bhyri, Brian R. Quaranto, Junsong Yuan, Peter C. W. Kim*, Nan Xi* (*equal advising)
IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), 2026

Problem
Surgical teams count every instrument before and after an operation so that nothing is left inside the patient. The count is still done by hand. In our timing study a person needed 25.1 ± 11.6 s to count one tray image, and operating-room time costs roughly $100 per minute.
Trays are hard for vision models as well. Instruments are stacked and overlapping, and their metallic finish makes neighbouring handles look almost the same. Detection-based counters predict an unordered set of boxes and tend to merge or skip items inside a tight cluster. Density-based counters return a total without saying where each item is, so a nurse cannot check the result. General-purpose VLMs do worse still: on one tray with 57 instruments, GPT-5 answered 84.
Approach
People count clutter in order. They move along a row and tag each item once. CoLSR builds that ordering into the model: instead of an unordered set, it predicts a visual chain, a sequence of handle locations that follows a path across the tray.

Visual chain generator. The backbone is CountGD, an open-world counter that takes text and visual-exemplar prompts and uses a Swin-B image encoder. A generic prompt such as “scissor handle” is too weak to separate adjacent handles, so we add class-specific learnable text tokens. Each token is initialised from the projected text embedding plus Gaussian noise and then trained. Their attention maps are contrastive: the tokens attend mostly to the clutter around the handles and very little to the handles themselves. Filtering out that clutter is what lets the rest of the model lock onto the handles.
Neighboring loss. Predicted handles are matched to ground truth with the Hungarian algorithm. Let \(d_P^{i}\) be the distance between the \(i\)-th and \((i{+}1)\)-th predicted handles along the chain, and \(d_G^{i}\) the same distance for their matched ground-truth handles. The loss penalises any mismatch in spacing:
\[\mathcal{L}_{\text{neigh}} = \sum_{i=1}^{N_G} \big\lVert d_P^{i} - d_G^{i} \big\rVert_2\]This discourages a chain that skips a handle (one gap too large) or counts one twice (one gap too small). The full objective adds it to the localisation and focal classification losses:
\[\mathcal{L} = \lambda_{\text{loc}}\,\mathcal{L}_{\text{loc}} + \lambda_{\text{neigh}}\,\mathcal{L}_{\text{neigh}} + \lambda_{\text{cls}}\,\mathcal{L}_{\text{cls}}\]What the attention maps show
The attention maps show where the chain comes from. The neighboring loss changes how the decoder’s queries attend to each other: without it, each predicted handle attends to scattered handles across the tray. With it, attention in the first decoder layer forms a narrow band along the diagonal, so each handle looks mainly at its immediate neighbours. This is the “snake-like” chain the model counts along. In the last layer, the model draws on clearly visible handles (anchors) to resolve the dense cluster it is unsure about, which keeps it from skipping or double-counting overlapping instruments.


SurgCount-HD dataset
We collected and annotated SurgCount-HD: 1,464 images of densely packed instrument trays from real clinical settings, with a box on every instrument handle. The dataset is released with the code.
Results
All counting baselines were fine-tuned on SurgCount-HD. Qwen2.5-VL was evaluated zero-shot.
| Method | MAE ↓ | RMSE ↓ |
|---|---|---|
| CountGD | 7.84 | 10.71 |
| DQ-DETR | 4.24 | 6.81 |
| CrowdDiff | 18.63 | 22.93 |
| REC | 2.82 | 4.50 |
| Qwen2.5-VL-7B-Instruct | 17.06 | 21.72 |
| CoLSR (ours) | 0.88 | 1.27 |
Table 1. Counting error on the SurgCount-HD test set.
| Variant | MAE ↓ | RMSE ↓ |
|---|---|---|
| without neighboring loss | 1.81 | 2.73 |
| without class-specific tokens | 2.05 | 3.30 |
| without visual exemplars | 1.50 | 2.21 |
| without post-processing | 0.996 | 1.48 |
| full model | 0.88 | 1.27 |
Table 2. Ablations. Removing the neighboring loss roughly doubles the error, and removing the class-specific tokens has the largest effect.


The model also runs in a mobile app at 0.28 ± 0.02 s per image (0.32 s worst case), roughly 100× faster than a manual count.
Poster

Video
Citation
@InProceedings{Bhyri_2026_WACV,
author = {Bhyri, Rishikesh and Quaranto, Brian R. and Yuan, Junsong and Kim, Peter C. W. and Xi, Nan},
title = {Chain-of-Look Spatial Reasoning for Dense Surgical Instrument Counting},
booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
month = {March},
year = {2026}
}
