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

Input tray image, predicted visual chain, and counting result
Figure 1. Left to right: input tray, the visual chain predicted by CoLSR, and the final count. Each dot marks one detected instrument handle. Top row: 57 predicted, 57 in the ground truth. Bottom row: 16 and 16.

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.

CoLSR architecture: visual chain generator and neighboring loss
Figure 2. (a) Visual chain generator, built on CountGD. Learnable class-specific text tokens (green) are added to the text and exemplar prompts. (b) Neighboring loss. After Hungarian matching, the spacing between consecutive predicted handles is compared with the spacing between the matched ground-truth handles.

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.

Decoder self-attention between ten predicted handles with and without the neighboring loss
Figure 3. Decoder self-attention among the 10 handles of the tray on the left, without (−Lneigh) and with (+Lneigh) the neighboring loss. Top, layer 0: the loss turns scattered, high-entropy attention into a band along the diagonal, so each handle attends to its neighbours. Bottom, layer 5: confident anchor handles are used to resolve the uncertain, tightly packed region.
Feature-enhancer attention maps with and without class-specific learnable tokens
Figure 4. Attention in the feature enhancer. With the class-specific tokens, image–text attention concentrates on the row of handles. The image–CSL attention (right) is high on the background and low on the handles: the tokens learn a contrastive signal that filters out clutter.

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.

MethodMAE ↓RMSE ↓
CountGD7.8410.71
DQ-DETR4.246.81
CrowdDiff18.6322.93
REC2.824.50
Qwen2.5-VL-7B-Instruct17.0621.72
CoLSR (ours)0.881.27

Table 1. Counting error on the SurgCount-HD test set.

VariantMAE ↓RMSE ↓
without neighboring loss1.812.73
without class-specific tokens2.053.30
without visual exemplars1.502.21
without post-processing0.9961.48
full model0.881.27

Table 2. Ablations. Removing the neighboring loss roughly doubles the error, and removing the class-specific tokens has the largest effect.

Comparison of CoLSR with CountGD, REC, DQ-DETR and CrowdDiff on one tray
Figure 5. One tray with 69 instruments. Green dots are ground truth and red dots are predictions. All four baselines undercount (CountGD 61, REC 63, DQ-DETR 66, CrowdDiff 25) because they lose handles where instruments overlap (insets). CoLSR predicts 69.
CoLSR predictions on operating-room images outside the training distribution
Figure 6. Operating-room photos taken outside the dataset's capture setup, with different trays, backgrounds and lighting. Counts stay within two of the ground truth.

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

WACV 2026 poster for Chain-of-Look Spatial Reasoning
Figure 7. WACV 2026 poster. Click for the full-resolution PDF.

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}
}