SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.15161 · 2023

SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images

arXiv · PDF · Open in the Atlas

Code that ran

7 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 7 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.15161.json · badge: /api/ran/2310.15161.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
uni-medical/sam-med3d canonical (classifier label)
classifier basis: census
7 ran · 7 no recorded run
FunctionStatusWhere it lives
get_next_click3D_torch Ran
ran; our contract draft was wrong, not the code
uni-medical/sam-med3d/utils/click_method.py
code served (permissive licence) · get_code("5319e20cdab18b32")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)
np.random.seed(0)

# Create small 3D tensors for testing
# prev_seg: predicted segmentation masks (batch_size, depth, height, width)
# Shape: (2, 4, 3, 5) - batch=2, depth=4, height=3, width=5
prev_seg = torch.rand(2, 4, 3, 5)

# gt_semantic_seg: ground truth semantic segmentation (batch_size, depth, height, width)
# Shape: (2, 4, 3, 5) - same spatial dims as prev_seg
gt_semantic_seg = torch.rand(2, 4, 3, 5)

# Make some values clearly positive/negative for interesting test case
prev_seg[0, 0:2, 0:2, 0:2] = 0.8  # High predicted values
gt_semantic_seg[0, 1:3, 1:2, 1:3] = 0.8  # Different location for ground truth
prev_seg[1, 2:4, 1:3, 2:4] = 0.2  # Low predicted values
gt_semantic_seg[1, 0:2, 0:2, 0:2] = 0.9  # Different location for ground truth

ARGS = {
    "prev_seg": prev_seg,
    "gt_semantic_seg": gt_semantic_seg,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_next_click3D_torch_no_gt Ran
ran; our contract draft was wrong, not the code
uni-medical/sam-med3d/utils/click_method.py
code served (permissive licence) · get_code("c0a019683e8f8f94")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small test tensors
batch_size = 2
depth = 4
height = 3
width = 5

# prev_seg: segmentation masks from previous iteration
# Shape: (batch_size, depth, height, width)
prev_seg = torch.rand(batch_size, depth, height, width)

# img3D: input images
# Shape: (batch_size, depth, height, width)
img3D = torch.randint(0, 255, (batch_size, depth, height, width)).float()

# threshold: threshold value to apply to image
threshold = 170

ARGS = {
    "prev_seg": prev_seg,
    "img3D": img3D,
    "threshold": threshold,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_rel_pos Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uni-medical/sam-med3d/segment_anything/modeling/image_encoder.py
code served (permissive licence) · get_code("733d7f0bedcb74c2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (3, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small relative position embedding tensor
# Shape: (L, C) where L is the sequence length and C is the channel dimension
# Using a small size that will be resized by the function
rel_pos = torch.randn(5, 4)  # 5 positions, 4 channels

# Define query and key sizes
q_size = 3
k_size = 4

ARGS = {
    "q_size": q_size,
    "k_size": k_size,
    "rel_pos": rel_pos,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (3, 4, 4) — shape (3, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_partition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uni-medical/sam-med3d/segment_anything/modeling/image_encoder.py
code served (permissive licence) · get_code("c71a8b97aab37f0a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Construct a small input tensor with shape [B, H, W, C]
# B=2 (batch), H=5 (height), W=7 (width), C=4 (channels)
x = torch.randn(2, 5, 7, 4)

# window_size parameter
window_size = 3

ARGS = {
    "x": x,
    "window_size": window_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_partition3D Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uni-medical/sam-med3d/segment_anything/modeling/image_encoder3D.py
code served (permissive licence) · get_code("dd47975703efb3d2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small 5D input tensor [B, D, H, W, C]
# Using distinct sizes: B=2, D=4, H=3, W=5, C=2
x = torch.randn(2, 4, 3, 5, 2)

# Window size - should be chosen such that partitioning makes sense
window_size = 2

ARGS = {
    "x": x,
    "window_size": window_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_unpartition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uni-medical/sam-med3d/segment_anything/modeling/image_encoder.py
code served (permissive licence) · get_code("28e31974913a3064")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 7, 6, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct arguments for window_unpartition
# windows: [B * num_windows, window_size, window_size, C]
# window_size: int
# pad_hw: (Hp, Wp) - padded height and width
# hw: (H, W) - original height and width

window_size = 4
C = 3  # channels
Hp, Wp = 8, 8  # padded height and width
H, W = 7, 6    # original height and width (before padding)
B = 2  # batch size

# Calculate number of windows
num_windows = (Hp // window_size) * (Wp // window_size)  # (8//4) * (8//4) = 4

# windows shape: [B * num_windows, window_size, window_size, C]
windows = torch.randn(B * num_windows, window_size, window_size, C)

ARGS = {
    "windows": windows,
    "window_size": window_size,
    "pad_hw": (Hp, Wp),
    "hw": (H, W),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 7, 6, 3) — shape (2, 7, 6, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_unpartition3D Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uni-medical/sam-med3d/segment_anything/modeling/image_encoder3D.py
code served (permissive licence) · get_code("6070079ba9c357d8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 5, dtype family float, shape (2, 4, 4, 4, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyzing the function:
# - windows: torch.Tensor with shape [B * num_windows, window_size, window_size, window_size, C]
#   The function expects shape [B * num_windows, window_size, window_size, C] based on view operation
#   but the docstring mentions 3D, so it's likely [B * num_windows, window_size, window_size, window_size, C]
# - window_size: int, the size of each window
# - pad_dhw: Tuple[int, int, int], padded dimensions (Dp, Hp, Wp)
# - dhw: Tuple[int, int, int], original dimensions (D, H, W)

# Let's construct valid arguments:
# window_size = 2
# Original shape: D=4, H=4, W=4
# Padded shape: Dp=4, Hp=4, Wp=4 (no padding needed in this case)
# Number of windows: (Dp/window_size) * (Hp/window_size) * (Wp/window_size) = 2*2*2 = 8
# Batch size B = 2
# Channel dimension C = 3

window_size = 2
D, H, W = 4, 4, 4
Dp, Hp, Wp = 4, 4, 4
B = 2
C = 3

# Total number of windows: (Dp // window_size) * (Hp // window_size) * (Wp // window_size)
num_windows = (Dp // window_size) * (Hp // window_size) * (Wp // window_size)
# Shape should be [B * num_windows, window_size, window_size, window_size, C]
windows = torch.randn(B * num_windows, window_size, window_size, window_size, C)

ARGS = {
    "windows": windows,
    "window_size": window_size,
    "pad_dhw": (Dp, Hp, Wp),
    "dhw": (D, H, W),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 5, dtype family float, shape (2, 4, 4, 4, 3) — shape (2, 4, 4, 4, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_sam3D_vit_b Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam3D.py
code served (permissive licence) · get_code("c40a5f71e5f13edc")
How it ran

no invocation recorded.

build_sam3D_vit_h Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam3D.py
code served (permissive licence) · get_code("d0dd75537fcd6623")
How it ran

no invocation recorded.

build_sam3D_vit_l Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam3D.py
code served (permissive licence) · get_code("0e52565027a9e6b9")
How it ran

no invocation recorded.

build_sam_vit_b Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("c1d0ad3fa15c7719")
How it ran

no invocation recorded.

build_sam_vit_h Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("670eef4f7f0733c1")
How it ran

no invocation recorded.

build_sam_vit_l Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("66dcf215ad57f76b")
How it ran

no invocation recorded.

get_next_click3D_torch_no_gt_naive Not yet run
unverified (harvested, no recorded run)
uni-medical/sam-med3d/utils/click_method.py
code served (permissive licence) · get_code("8978da605c3303f9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 10 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 10 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_rel_pos 47 other papers
16 dated earlier, 31 later · 5 only as an assembly brick
2304.02643 (2023-04)
Segment Anything
2304.06790 (2023-04)
Inpaint Anything: Segment Anything Meets Image Inpainting
2304.12306 (2023-04)
Segment Anything in Medical Images
and 44 more not named here
window_partition 47 other papers
16 dated earlier, 31 later · 1 only as an assembly brick
2304.02643 (2023-04)
Segment Anything
2304.06790 (2023-04)
Inpaint Anything: Segment Anything Meets Image Inpainting
2304.12306 (2023-04)
Segment Anything in Medical Images
and 44 more not named here
window_unpartition 46 other papers
16 dated earlier, 30 later · 1 only as an assembly brick
2304.02643 (2023-04)
Segment Anything
2304.06790 (2023-04)
Inpaint Anything: Segment Anything Meets Image Inpainting
2304.12306 (2023-04)
Segment Anything in Medical Images
and 43 more not named here
build_sam3D_vit_b 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
build_sam3D_vit_h 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
build_sam3D_vit_l 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
build_sam_vit_b 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
build_sam_vit_h 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
build_sam_vit_l 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images
get_next_click3D_torch 1 other paper
1 later
2403.09827 (2024-03)
FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Existing volumetric medical image segmentation models are typically task-specific, excelling at specific target but struggling to generalize across anatomical structures or modalities. This limitation restricts their broader clinical use. In this paper, we introduce SAM-Med3D for general-purpose segmentation on volumetric medical images. Given only a few 3D prompt points, SAM-Med3D can accurately segment diverse anatomical structures and lesions across various modalities. To achieve this, we gather and process a large-scale 3D medical image dataset, SA-Med3D-140K, from a blend of public sources and licensed private datasets. This dataset includes 22K 3D images and 143K corresponding 3D masks. Then SAM-Med3D, a promptable segmentation model characterized by the fully learnable 3D structure, is trained on this dataset using a two-stage procedure and exhibits impressive performance on both seen and unseen segmentation targets. We comprehensively evaluate SAM-Med3D on 16 datasets covering diverse medical scenarios, including different anatomical structures, modalities, targets, and zero-shot transferability to new/unseen tasks. The evaluation shows the efficiency and efficacy of SAM-Med3D, as well as its promising application to diverse downstream tasks as a pre-trained model. Our approach demonstrates that substantial medical resources can be utilized to develop a general-purpose medical AI for various potential applications. Our dataset, code, and models are available at https://github.com/uni-medical/SAM-Med3D.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.15161")
get_code_for_paper("2310.15161")
have("2310.15161")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.15161.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.15161.svg)](https://syntology.ai/paper/2310.15161)

Connect an agent — have() is free.