The extension now supports SAM3 models for enhanced segmentation and tracking capabilities.
https://github.com/user-attachments/assets/801d9465-e3d3-47c1-9999-e556b0b4a5d0
The command history is also now available from Automate > Show workflow command history and Automate > Create command history script in the menu bar.
var foregroundObjects = [
PathObjects.createAnnotationObject(
ROIs.createRectangleROI(
433.000000, 194.000000, 21.000000, 37.000000,
new ImagePlane(-1, 0, 0)
),
null
),
PathObjects.createAnnotationObject(
ROIs.createRectangleROI(
416.000000, 174.000000, 23.000000, 32.000000,
new ImagePlane(-1, 0, 0)
),
null
),
]
var backgroundObjects = []
var task = org.elephant.sam.tasks.SAMDetectionTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequest(RegionRequest.createInstance(getCurrentServer().getPath(), 0.934228, 0, 0, 696, 520, 0, 0))
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.VIT_T)
.outputType(org.elephant.sam.entities.SAMOutput.MULTI_SMALLEST)
.setName(true)
.setRandomColor(true)
.checkpointUrl("https://github.com/ChaoningZhang/MobileSAM/raw/master/weights/mobile_sam.pt")
.addForegroundPrompts(foregroundObjects)
.addBackgroundPrompts(backgroundObjects)
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
var clearCurrentObjects = true
var task = org.elephant.sam.tasks.SAMAutoMaskTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequest(RegionRequest.createInstance(getCurrentServer().getPath(), 0.934228, 0, 0, 696, 520, 0, 0))
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.VIT_T)
.outputType(org.elephant.sam.entities.SAMOutput.MULTI_SMALLEST)
.setName(true)
.clearCurrentObjects(clearCurrentObjects)
.setRandomColor(true)
.pointsPerSide(64)
.pointsPerBatch(8)
.predIoUThresh(0.880000)
.stabilityScoreThresh(0.950000)
.stabilityScoreOffset(1.000000)
.boxNmsThresh(0.200000)
.cropNLayers(0)
.cropNmsThresh(0.700000)
.cropOverlapRatio(0.340000)
.cropNPointsDownscaleFactor(1)
.minMaskRegionArea(0)
.includeImageEdge(false)
.checkpointUrl("https://github.com/ChaoningZhang/MobileSAM/raw/master/weights/mobile_sam.pt")
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
if (clearCurrentObjects)
hierarchy.clearAll()
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
def fromIndex = 20
def toIndex = 40
var objs = [
11: [org.elephant.sam.parameters.SAM2VideoPromptObject.builder(0).bbox(352, 142, 463, 287).build(),]
]
var indexToPathClass = [
0: PathClass.getInstance("SAM0"),
]
var regionRequests = (fromIndex..toIndex).collect {RegionRequest.createInstance(getCurrentServer().getPath(), 0.687248, 0, 0, 512, 443, 0, it)}}
var task = org.elephant.sam.tasks.SAMSequenceTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequests(regionRequests)
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.SAM2_S)
.promptMode(org.elephant.sam.entities.SAMPromptMode.XYT)
.objs(objs)
.checkpointUrl("https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_small.pt")
.indexOffset(fromIndex)
.indexToPathClass(indexToPathClass)
.planePosition(0)
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
indexToPathClass.values().stream()
.filter(pathClass -> !getQuPath().getAvailablePathClasses().contains(pathClass))
.sorted(Comparator.comparing(PathClass::getName, new org.elephant.sam.comparators.NaturalOrderComparator()))
.forEachOrdered(pathClass -> getQuPath().getAvailablePathClasses().add(pathClass))
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
This is a QuPath extension for Segment Anything Model (SAM).
This is a part of the following paper. Please cite it when you use this project. You will also cite the original SAM paper and the MobileSAM paper.
Drag and drop the extension file to QuPath and restart it.
Since QuPath v0.5.0, you can install the extension from the extension manager dialog by specifying Owner and Repository as shown below.
If you are using QuPath v0.4.x, you need to install the extension file for QuPath v0.4.x, which is now deprecated.
Please note that you need to set up the server following the instructions in the link below.
https://github.com/ksugar/samapi
To update the qupath-extension-sam, follow the following instructions.
Extensions > Installed extensions > Open extensions directory

qupath-extension-sam-x.y.z.jar with the latest version of the extension file. If you are using QuPath v0.4.x, you need to install the extension file for QuPath v0.4.x, which is now deprecated.Please note that you need to also update the samapi server.
To keep updated with the latest samapi server, follow the instructions here.
Starting from QuPath v0.6, you can receive notifications about new releases of the extension by adding the following settings.
Extensions > SAM from the menu bar.Prompt tab in the Segment Anyghing Model dialog.Alt + Ctrl + A: Select all annotation objects Ctrl or ⌘ + left click: Select multiple objects)Run for selected button.Live mode, SAM predicts a mask every time you add a rectangle.
Extensions > SAM from the menu bar.Prompt tab in the Segment Anything Model dialog.Run for selected button.Live mode, SAM predicts a mask every time you add a foreground point.
| key | value |
|---|---|
| Server | URL of the server. |
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| SAM weights | The SAM weights to use. The options are automatically fetched from the server. |
| Output type | If Single Mask is selected, the model will return single masks per prompt. If Multi-mask is selected, the model will return three masks per prompt. Multi-mask (all) keeps all three masks. One of the three masks is kept if the option Multi-mask (largest), Multi-mask (smallest), or Multi-mask (best quality) is selected. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
| Assign random colors | If checked and no path class is set in Auto set setting, assign random colors to new (unclassified) objects created by SAM. |
| Assign names | If checked, assign names to identify new objects as created by SAM, including quality scores. |
| Keep prompts | If checked, keep the foreground prompts after detection. If not checked, these are deleted. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
Extensions > SAM from the menu bar.Auto mask tab in the Segment Anything Model dialog.Run button.| key | value |
|---|---|
| Server | URL of the server. |
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| SAM weights | The SAM weights to use. The options are automatically fetched from the server. |
| Assign random colors | If checked and no path class is set in Auto set setting, assign random colors to new (unclassified) objects created by SAM. |
| Assign names | If checked, assign names to identify new objects as created by SAM, including quality scores. |
| Keep prompts | If checked, keep the foreground prompts after detection. If not checked, these are deleted. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
| points_per_side | The number of points to be sampled along one side of the image. The total number of points is points_per_side**2. |
| points_per_batch | Sets the number of points run simultaneously by the model. Higher numbers may be faster but use more GPU memory. |
| pred_iou_thresh | A filtering threshold in [0,1], using the model's predicted mask quality. |
| stability_score_thresh | A filtering threshold in [0,1], using the stability of the mask under changes to the cutoff used to binarize the model's mask predictions. |
| stability_score_offset | The amount to shift the cutoff when calculated the stability score. |
| box_nms_thresh | The box IoU cutoff used by non-maximal suppression to filter duplicate masks. |
| crop_n_layers | If >0, mask prediction will be run again on crops of the image. Sets the number of layers to run, where each layer has 2**i_layer number of image crops. |
| crop_nms_thresh | The box IoU cutoff used by non-maximal suppression to filter duplicate masks between different crops. |
| crop_overlap_ratio | Sets the degree to which crops overlap. In the first crop layer, crops will overlap by this fraction of the image length. Later layers with more crops scale down this overlap. |
| crop_n_points_downscale_factor | The number of points-per-side sampled in layer n is scaled down by crop_n_points_downscale_factor**n. |
| min_mask_region_area | If >0, postprocessing will be applied to remove disconnected regions and holes in masks with area smaller than min_mask_region_area. Requires opencv. |
| output_type | If 'Single Mask' is selected, the model will return single masks per prompt. If 'Multi-mask' is selected, the model will return three masks per prompt. 'Multi-mask (all)' keeps all three masks. One of the three masks is kept if the option 'Multi-mask (largest)', 'Multi-mask (smallest)', or 'Multi-mask (best quality)' is selected. |
| include_image_edge | If True, include a crop area at the edge of the original image. |
Extensions > SAM from the menu bar.Register button in the Segment Anything Model dialog.
The weights file is downloaded from the URL and registered on the server. After the registration, you can select the weights from the SAM weights dropdown menu.
| key | value |
|---|---|
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| Name | The SAM weights name to register. It needs to be unique in the same SAM type. |
| URL | The URL to the SAM weights file. |
Here is a list of SAM weights that you can register from the URL.
# MicroSAM models # PathoSAM models| Type | Name (customizable) | URL | Citation |
|---|---|---|---|
| vit_h | vit_h_lm | https://zenodo.org/record/8250299/files/vit_h_lm.pth?download=1 | Archit, A. et al. Segment Anything for
Microscopy. Nature Methods 2025. https://github.com/computational-cell-analytics/micro-sam |
| vit_b | vit_b_lm | https://zenodo.org/record/8250281/files/vit_b_lm.pth?download=1 | |
| vit_h | vit_h_em | https://zenodo.org/record/8250291/files/vit_h_em.pth?download=1 | |
| vit_b | vit_b_em | https://zenodo.org/record/8250260/files/vit_b_em.pth?download=1 | |
| vit_h | vit_h_histopathology | https://owncloud.gwdg.de/index.php/s/L7AcvVz7DoWJ2RZ/download | Greibel, T. et al. Segment Anything for
Histopathology. arXiv 2025. https://github.com/computational-cell-analytics/patho-sam |
| vit_b | vit_b_histopathology | https://owncloud.gwdg.de/index.php/s/sBB4H8CTmIoBZsQ/download |
If you select a class in Auto set in the Annotations tab, it is used for a new annotation generated by SAM.
v0.7.1 or above.v0.7.0 or above).v0.6.0 and above.v0.5.0 and above.Prompt and Auto mask dialogs into a single Segment Anything Model dialog.Support for both point and rectangle foreground prompts by @petebankhead
Support point background prompts by @petebankhead
Implement 'Live mode' and 'Run for selected' by @petebankhead
Support SamAutomaticMaskGenerator
Menu items simplified to a single command to launch a dialog to control annotation with SAM by @petebankhead
Handle changing the current image while the command is running by @petebankhead
Include the 'quality' metric as a measurement for objects that are created by @petebankhead
Support z-stacks/time series (by using the image plane; there's no support for 3D objects) by @petebankhead and @rharkes
Optionally assign names & random colors to identify the generated objects by @petebankhead
Optionally return multiple (3) detections instead of 1 by @petebankhead
Select which detection to retain based upon size or quality, or keep all of them by @petebankhead
Optionally keep the prompt objects, instead of immediately deleting them by @petebankhead
Support any number of channels
Please cite my paper on bioRxiv.
@article {Sugawara2023.06.13.544786,
author = {Ko Sugawara},
title = {Training deep learning models for cell image segmentation with sparse annotations},
elocation-id = {2023.06.13.544786},
year = {2023},
doi = {10.1101/2023.06.13.544786},
publisher = {Cold Spring Harbor Laboratory},
abstract = {Deep learning is becoming more prominent in cell image analysis. However, collecting the annotated data required to train efficient deep-learning models remains a major obstacle. I demonstrate that functional performance can be achieved even with sparsely annotated data. Furthermore, I show that the selection of sparse cell annotations significantly impacts performance. I modified Cellpose and StarDist to enable training with sparsely annotated data and evaluated them in conjunction with ELEPHANT, a cell tracking algorithm that internally uses U-Net based cell segmentation. These results illustrate that sparse annotation is a generally effective strategy in deep learning-based cell image segmentation. Finally, I demonstrate that with the help of the Segment Anything Model (SAM), it is feasible to build an effective deep learning model of cell image segmentation from scratch just in a few minutes.Competing Interest StatementKS is employed part-time by LPIXEL Inc.},
URL = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.13.544786},
eprint = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.13.544786.full.pdf},
journal = {bioRxiv}
}
Java
99.0%
Groovy
1.0%
The extension now supports SAM3 models for enhanced segmentation and tracking capabilities.
https://github.com/user-attachments/assets/801d9465-e3d3-47c1-9999-e556b0b4a5d0
The command history is also now available from Automate > Show workflow command history and Automate > Create command history script in the menu bar.
var foregroundObjects = [
PathObjects.createAnnotationObject(
ROIs.createRectangleROI(
433.000000, 194.000000, 21.000000, 37.000000,
new ImagePlane(-1, 0, 0)
),
null
),
PathObjects.createAnnotationObject(
ROIs.createRectangleROI(
416.000000, 174.000000, 23.000000, 32.000000,
new ImagePlane(-1, 0, 0)
),
null
),
]
var backgroundObjects = []
var task = org.elephant.sam.tasks.SAMDetectionTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequest(RegionRequest.createInstance(getCurrentServer().getPath(), 0.934228, 0, 0, 696, 520, 0, 0))
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.VIT_T)
.outputType(org.elephant.sam.entities.SAMOutput.MULTI_SMALLEST)
.setName(true)
.setRandomColor(true)
.checkpointUrl("https://github.com/ChaoningZhang/MobileSAM/raw/master/weights/mobile_sam.pt")
.addForegroundPrompts(foregroundObjects)
.addBackgroundPrompts(backgroundObjects)
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
var clearCurrentObjects = true
var task = org.elephant.sam.tasks.SAMAutoMaskTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequest(RegionRequest.createInstance(getCurrentServer().getPath(), 0.934228, 0, 0, 696, 520, 0, 0))
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.VIT_T)
.outputType(org.elephant.sam.entities.SAMOutput.MULTI_SMALLEST)
.setName(true)
.clearCurrentObjects(clearCurrentObjects)
.setRandomColor(true)
.pointsPerSide(64)
.pointsPerBatch(8)
.predIoUThresh(0.880000)
.stabilityScoreThresh(0.950000)
.stabilityScoreOffset(1.000000)
.boxNmsThresh(0.200000)
.cropNLayers(0)
.cropNmsThresh(0.700000)
.cropOverlapRatio(0.340000)
.cropNPointsDownscaleFactor(1)
.minMaskRegionArea(0)
.includeImageEdge(false)
.checkpointUrl("https://github.com/ChaoningZhang/MobileSAM/raw/master/weights/mobile_sam.pt")
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
if (clearCurrentObjects)
hierarchy.clearAll()
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
def fromIndex = 20
def toIndex = 40
var objs = [
11: [org.elephant.sam.parameters.SAM2VideoPromptObject.builder(0).bbox(352, 142, 463, 287).build(),]
]
var indexToPathClass = [
0: PathClass.getInstance("SAM0"),
]
var regionRequests = (fromIndex..toIndex).collect {RegionRequest.createInstance(getCurrentServer().getPath(), 0.687248, 0, 0, 512, 443, 0, it)}}
var task = org.elephant.sam.tasks.SAMSequenceTask.builder(getCurrentViewer())
.server(org.elephant.sam.Utils.createRenderedServer(getCurrentViewer()))
.regionRequests(regionRequests)
.serverURL("http://localhost:8000/sam/")
.verifySSL(false)
.model(org.elephant.sam.entities.SAMType.SAM2_S)
.promptMode(org.elephant.sam.entities.SAMPromptMode.XYT)
.objs(objs)
.checkpointUrl("https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_small.pt")
.indexOffset(fromIndex)
.indexToPathClass(indexToPathClass)
.planePosition(0)
.build()
task.setOnSucceeded(event -> {
List<PathObject> detected = task.getValue()
if (detected != null) {
if (!detected.isEmpty()) {
Platform.runLater(() -> {
PathObjectHierarchy hierarchy = getCurrentHierarchy()
indexToPathClass.values().stream()
.filter(pathClass -> !getQuPath().getAvailablePathClasses().contains(pathClass))
.sorted(Comparator.comparing(PathClass::getName, new org.elephant.sam.comparators.NaturalOrderComparator()))
.forEachOrdered(pathClass -> getQuPath().getAvailablePathClasses().add(pathClass))
hierarchy.addObjects(detected)
hierarchy.getSelectionModel().clearSelection()
hierarchy.fireHierarchyChangedEvent(this)
});
} else {
print("No objects detected")
}
}
});
Platform.runLater(task)
This is a QuPath extension for Segment Anything Model (SAM).
This is a part of the following paper. Please cite it when you use this project. You will also cite the original SAM paper and the MobileSAM paper.
Drag and drop the extension file to QuPath and restart it.
Since QuPath v0.5.0, you can install the extension from the extension manager dialog by specifying Owner and Repository as shown below.
If you are using QuPath v0.4.x, you need to install the extension file for QuPath v0.4.x, which is now deprecated.
Please note that you need to set up the server following the instructions in the link below.
https://github.com/ksugar/samapi
To update the qupath-extension-sam, follow the following instructions.
Extensions > Installed extensions > Open extensions directory

qupath-extension-sam-x.y.z.jar with the latest version of the extension file. If you are using QuPath v0.4.x, you need to install the extension file for QuPath v0.4.x, which is now deprecated.Please note that you need to also update the samapi server.
To keep updated with the latest samapi server, follow the instructions here.
Starting from QuPath v0.6, you can receive notifications about new releases of the extension by adding the following settings.
Extensions > SAM from the menu bar.Prompt tab in the Segment Anyghing Model dialog.Alt + Ctrl + A: Select all annotation objects Ctrl or ⌘ + left click: Select multiple objects)Run for selected button.Live mode, SAM predicts a mask every time you add a rectangle.
Extensions > SAM from the menu bar.Prompt tab in the Segment Anything Model dialog.Run for selected button.Live mode, SAM predicts a mask every time you add a foreground point.
| key | value |
|---|---|
| Server | URL of the server. |
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| SAM weights | The SAM weights to use. The options are automatically fetched from the server. |
| Output type | If Single Mask is selected, the model will return single masks per prompt. If Multi-mask is selected, the model will return three masks per prompt. Multi-mask (all) keeps all three masks. One of the three masks is kept if the option Multi-mask (largest), Multi-mask (smallest), or Multi-mask (best quality) is selected. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
| Assign random colors | If checked and no path class is set in Auto set setting, assign random colors to new (unclassified) objects created by SAM. |
| Assign names | If checked, assign names to identify new objects as created by SAM, including quality scores. |
| Keep prompts | If checked, keep the foreground prompts after detection. If not checked, these are deleted. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
Extensions > SAM from the menu bar.Auto mask tab in the Segment Anything Model dialog.Run button.| key | value |
|---|---|
| Server | URL of the server. |
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| SAM weights | The SAM weights to use. The options are automatically fetched from the server. |
| Assign random colors | If checked and no path class is set in Auto set setting, assign random colors to new (unclassified) objects created by SAM. |
| Assign names | If checked, assign names to identify new objects as created by SAM, including quality scores. |
| Keep prompts | If checked, keep the foreground prompts after detection. If not checked, these are deleted. |
| Display names | Display the annotation names in the viewer. (this is a global preference) |
| points_per_side | The number of points to be sampled along one side of the image. The total number of points is points_per_side**2. |
| points_per_batch | Sets the number of points run simultaneously by the model. Higher numbers may be faster but use more GPU memory. |
| pred_iou_thresh | A filtering threshold in [0,1], using the model's predicted mask quality. |
| stability_score_thresh | A filtering threshold in [0,1], using the stability of the mask under changes to the cutoff used to binarize the model's mask predictions. |
| stability_score_offset | The amount to shift the cutoff when calculated the stability score. |
| box_nms_thresh | The box IoU cutoff used by non-maximal suppression to filter duplicate masks. |
| crop_n_layers | If >0, mask prediction will be run again on crops of the image. Sets the number of layers to run, where each layer has 2**i_layer number of image crops. |
| crop_nms_thresh | The box IoU cutoff used by non-maximal suppression to filter duplicate masks between different crops. |
| crop_overlap_ratio | Sets the degree to which crops overlap. In the first crop layer, crops will overlap by this fraction of the image length. Later layers with more crops scale down this overlap. |
| crop_n_points_downscale_factor | The number of points-per-side sampled in layer n is scaled down by crop_n_points_downscale_factor**n. |
| min_mask_region_area | If >0, postprocessing will be applied to remove disconnected regions and holes in masks with area smaller than min_mask_region_area. Requires opencv. |
| output_type | If 'Single Mask' is selected, the model will return single masks per prompt. If 'Multi-mask' is selected, the model will return three masks per prompt. 'Multi-mask (all)' keeps all three masks. One of the three masks is kept if the option 'Multi-mask (largest)', 'Multi-mask (smallest)', or 'Multi-mask (best quality)' is selected. |
| include_image_edge | If True, include a crop area at the edge of the original image. |
Extensions > SAM from the menu bar.Register button in the Segment Anything Model dialog.
The weights file is downloaded from the URL and registered on the server. After the registration, you can select the weights from the SAM weights dropdown menu.
| key | value |
|---|---|
| SAM type | One of vit_h (huge), vit_l (large), vit_b (base), vit_t (mobile), sam2_l (large), sam2_bp (base plus), sam2_s (small), or sam2_t (tiny). |
| Name | The SAM weights name to register. It needs to be unique in the same SAM type. |
| URL | The URL to the SAM weights file. |
Here is a list of SAM weights that you can register from the URL.
# MicroSAM models # PathoSAM models| Type | Name (customizable) | URL | Citation |
|---|---|---|---|
| vit_h | vit_h_lm | https://zenodo.org/record/8250299/files/vit_h_lm.pth?download=1 | Archit, A. et al. Segment Anything for
Microscopy. Nature Methods 2025. https://github.com/computational-cell-analytics/micro-sam |
| vit_b | vit_b_lm | https://zenodo.org/record/8250281/files/vit_b_lm.pth?download=1 | |
| vit_h | vit_h_em | https://zenodo.org/record/8250291/files/vit_h_em.pth?download=1 | |
| vit_b | vit_b_em | https://zenodo.org/record/8250260/files/vit_b_em.pth?download=1 | |
| vit_h | vit_h_histopathology | https://owncloud.gwdg.de/index.php/s/L7AcvVz7DoWJ2RZ/download | Greibel, T. et al. Segment Anything for
Histopathology. arXiv 2025. https://github.com/computational-cell-analytics/patho-sam |
| vit_b | vit_b_histopathology | https://owncloud.gwdg.de/index.php/s/sBB4H8CTmIoBZsQ/download |
If you select a class in Auto set in the Annotations tab, it is used for a new annotation generated by SAM.
v0.7.1 or above.v0.7.0 or above).v0.6.0 and above.v0.5.0 and above.Prompt and Auto mask dialogs into a single Segment Anything Model dialog.Support for both point and rectangle foreground prompts by @petebankhead
Support point background prompts by @petebankhead
Implement 'Live mode' and 'Run for selected' by @petebankhead
Support SamAutomaticMaskGenerator
Menu items simplified to a single command to launch a dialog to control annotation with SAM by @petebankhead
Handle changing the current image while the command is running by @petebankhead
Include the 'quality' metric as a measurement for objects that are created by @petebankhead
Support z-stacks/time series (by using the image plane; there's no support for 3D objects) by @petebankhead and @rharkes
Optionally assign names & random colors to identify the generated objects by @petebankhead
Optionally return multiple (3) detections instead of 1 by @petebankhead
Select which detection to retain based upon size or quality, or keep all of them by @petebankhead
Optionally keep the prompt objects, instead of immediately deleting them by @petebankhead
Support any number of channels
Please cite my paper on bioRxiv.
@article {Sugawara2023.06.13.544786,
author = {Ko Sugawara},
title = {Training deep learning models for cell image segmentation with sparse annotations},
elocation-id = {2023.06.13.544786},
year = {2023},
doi = {10.1101/2023.06.13.544786},
publisher = {Cold Spring Harbor Laboratory},
abstract = {Deep learning is becoming more prominent in cell image analysis. However, collecting the annotated data required to train efficient deep-learning models remains a major obstacle. I demonstrate that functional performance can be achieved even with sparsely annotated data. Furthermore, I show that the selection of sparse cell annotations significantly impacts performance. I modified Cellpose and StarDist to enable training with sparsely annotated data and evaluated them in conjunction with ELEPHANT, a cell tracking algorithm that internally uses U-Net based cell segmentation. These results illustrate that sparse annotation is a generally effective strategy in deep learning-based cell image segmentation. Finally, I demonstrate that with the help of the Segment Anything Model (SAM), it is feasible to build an effective deep learning model of cell image segmentation from scratch just in a few minutes.Competing Interest StatementKS is employed part-time by LPIXEL Inc.},
URL = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.13.544786},
eprint = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.13.544786.full.pdf},
journal = {bioRxiv}
}
Java
99.0%
Groovy
1.0%