torch torchvision opencv-python pyyaml json_tricks yacs scikit-learn pandas timm==0.4.12 numpy==1.23.5 einops fvcore transformers #==4.19.2 sentencepiece ftfy regex nltk vision-datasets==0.2.2 pycocotools diffdist pyarrow cityscapesscripts shapely scikit-image mup #gradio==3.35.2 scann kornia==0.6.4 torchmetrics==0.6.0 progressbar pillow==9.4.0

This is a ComfyUI node based-on Semantic-SAM official implementation. We provide a workflow node for one-click segment. Compared with SAM, Semantic-SAM has better fine-grained capabilities and more candidate masks. Users can take this node as the pre-node for inpainting to obtain the mask region.
This node have been valided on Ubuntu-20.04 & CUDA-11.8. Due to detectron2, this node is currently not supported on Windows (unless the compatibility of Detectron2 on Windows is addressed)
cd ComfyUI/custom
git clone https://github.com/eastoc/ComfyUI_SemanticSAM
cd ComfyUI_SemanticSAM
git clone https://github.com/facebookresearch/detectron2
git clone https://github.com/facebookresearch/Mask2Former
Because detectron2 has not been updated, if the CUDA=11.8, you can
git clone https://github.com/johnnynunez/detectron2
or you can try other 3rd detectron2 implementation.
download Semantic-SAM model to “ComfyUI_SemanticSAM/ckpt”
| Name | Training Dataset | Backbone | 1-IoU@Multi-Granularity | 1-IoU@COCO(Max|Oracle) | download |
|---|---|---|---|---|---|
| Semantic-SAM | config | SA-1B | SwinT | 88.1 | 54.5|73.8 | model |
| Semantic-SAM | config | SA-1B | SwinL | 89.0 | 55.1|74.1 | model |
Install PyTorch & torchvision through the official method. We have been valid that from pytorch 1.13.0 to 2.3.0.
Install Semantic-SAM dependencies
pip install -r requirements.txt
Install detectron2
cd detectron2
pip install -e .
cd ..
Install Mask2Former
cd Mask2Former/mask2former/modeling/pixel_decoder/ops
sh make.sh
one-click segment workflow is in “./workflow/workflow.json”