File size: 4,643 Bytes
e1b0735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972a3c6
 
 
 
 
e1b0735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
license: other
license_name: penn-academic-software-license
license_link: LICENSE
pipeline_tag: image-segmentation
tags:
  - pathology
  - histopathology
  - medical-imaging
  - segmentation
  - whole-slide-image
  - interactive-segmentation
  - foundation-model
---

# VISTA-PATH

An interactive foundation model for pathology image segmentation and quantitative
analysis in computational pathology.

- 📄 Paper: https://www.arxiv.org/abs/2601.16451
- 💻 Code: https://github.com/zhihuanglab/VISTA-PATH
- 🔬 Integrated in [TissueLab](https://www.tissuelab.org/)

VISTA-PATH integrates visual context, textual class prompts and expert-guided
interaction. Pre-trained on over 1.6 million samples, it generalizes across
organs and tissue types, supports human-in-the-loop refinement, and enables
clinically interpretable analysis through survival-associated morphological
features.

## Architecture

| Component | Source | Role |
|---|---|---|
| Text encoder | `vinid/plip` (CLIP text tower) | Encodes the class prompt `"an image of {class_name}"` as a token sequence |
| Segmentation trunk | `facebook/mask2former-swin-small-ade-semantic` | Swin encoder + pixel decoder + masked-attention transformer decoder |
| Box prompt encoder | `facebook/sam-vit-base` (frozen `prompt_encoder`) | Encodes an optional bounding-box prompt as two corner tokens |

Twenty object queries cross-attend to the concatenated `[text tokens ; box tokens]`
sequence before the Mask2Former decoder, and a per-query binary head produces a
foreground probability map for the prompted class. When no box is given, two
learnable "no-box" tokens replace the SAM corner tokens, so the same checkpoint
serves both the prompt-free and the box-prompted settings.

Inference settings that must match the checkpoint: input resolution 512, 20 queries.

## Files

```
pytorch_model.bin     # released weights (~506 MB)
models/backbones.py   # CustomSegmentationModel
inference.py          # prompt-free / tissue-box whole-slide inference
inference_bbx.py      # box-prompted inference driven by a label mask
inference_utils.py    # model construction, checkpoint loading, sliding windows
utils.py              # visualization + segmentation metrics
idx_to_names/         # label index -> class name mappings
examples_BRCA/        # toy ROI image/mask pairs
```

## Usage

Download the repository and run either entrypoint. The three backbones above are
pulled from the Hub on first run.

```python
from huggingface_hub import snapshot_download
local = snapshot_download("zhihuanglab/VISTA-PATH")
```

Prompt-free segmentation of named classes over a slide:

```bash
python3 inference.py \
  --infer_vis_dir ./results \
  --checkpoint_file pytorch_model.bin \
  --image_file /path/to/slide.svs \
  --class_names "Tumor" "Stroma" \
  --crop_size 2048 --overlap 256 \
  --bbx_random 1
```

Box-prompted segmentation, where a label mask supplies one box per class present
in each window:

```bash
python3 inference_bbx.py \
  --infer_vis_dir ./results \
  --json_file ./idx_to_names/BRCA.json \
  --checkpoint_file pytorch_model.bin \
  --image_dir ./examples_BRCA/images \
  --mask_dir ./examples_BRCA/masks \
  --bbx_random 0
```

`--bbx_random` is the probability of dropping the box prompt: `1` runs prompt-free,
`0` conditions every window on its box. Only a `.jpg` overview is written by
default; add `--save_mask` for the full-resolution label mask and `--save_prob`
for per-class probability maps.

Environment: Python 3.12, torch 2.4.0+cu118 with torchvision 0.19.0+cu118,
transformers 4.46.1, openslide-python with `openslide-bin`. The cu118 build covers
`sm_50` through `sm_90` (V100 up to H200); Blackwell cards (RTX 50 series, B200)
need a cu128 build instead - torch 2.10.0+cu128 with torchvision 0.25.0+cu128.
See `environment.yml` and the installation section of the README in the GitHub repo.

## Citation

```bibtex
@misc{liang2026vistapath,
  title        = {VISTA-PATH: An interactive foundation model for pathology image segmentation and quantitative analysis in computational pathology},
  author       = {Liang, Peixian and Li, Songhao and Koga, Shunsuke and Li, Yutong and Alipour, Zahra and Tang, Yucheng and Xu, Daguang and Huang, Zhi},
  year         = {2026},
  eprint       = {2601.16451},
  archivePrefix= {arXiv},
  primaryClass = {cs.CV},
  doi          = {10.48550/arXiv.2601.16451},
}
```

## License

Released under the Penn Academic Software License Agreement (see `LICENSE`):
non-commercial academic research use only, with attribution. Commercial use,
sale, or other monetization of the model or its derivatives requires prior
approval.