Facebook开發『segment anything model』(SAM) 畫面識認,帮『ControlNet/Inpaint』重绘生成遮罩,重畫前後景,此版適合『Automatic1111’s WebUI』.
https://github.com/continue-revolution/sd-webui-segment-anything/archive/refs/heads/master.zip |
https://github.com/continue-revolution/sd-webui-segment-anything |
- 撳『Extensions擴展』->『Install from URL係網裝』
https://github.com/continue-revolution/sd-webui-segment-anything.git |
- 撳『Install』下載.
- 手動下載『Segment Anything』
- 登入CMD命令行模式
- 指定當前資料夾
CD C:\stable-diffusion-webui\extensions\ |
- 下載『segment anything』
git clone https://github.com/continue-revolution/sd-webui-segment-anything.git |
- 如出錯刪下列檔䅁夾,再重新下載
C:\stable-diffusion-webui\extensions\sd-webui-segment-anything |
C:\stable-diffusion-webui\tmp\sd-webui-segment-anything |
手工下載模型『segment anything model』越大越确.
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth |
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth |
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth |
https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_h.pth |
https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_l.pth |
https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_b.pth |
擺係sam資料夾.
C:\stable-diffusion-webui\extensions\sd-webui-segment-anything\models\sam |
手工下載GroundingDINO模型
https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/GroundingDINO_SwinB.cfg.py?download=true |
https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/GroundingDINO_SwinT_OGC.cfg.py?download=true |
https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/groundingdino_swinb_cogcoor.pth?download=true |
https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/groundingdino_swint_ogc.pth?download=true |
擺係grounding-dino資料夾.
C:\stable-diffusion-webui\extensions\sd-webui-segment-anything\models\grounding-dino |
- 使能本地编译『GroundingDINO』
- 撳『Settings』->『Segment Anything』
- 撳『Use local groundingdino to bypass C++ problem』用本地groundingdino繞過C++編譯問題.
- 撳『Apply settings』
- 撳『Reload UI』
- 允許『segment anything』傅递畀『ControlNet』
- 撳『Settings』->『ControlNet』
- 勾『Allow Other script to control this extension允許其他它脚本對擴展插件進行控制』.
- 撳『Apply settings』
- 撳『Reload UI』
- 撳『img2img』->『Segment Anything』
- 『SAM Model』擇『pth』
- 係『single image』上傅圖畫.
- 撳左鍵黑㸃保留區, 撳右鍵紅㸃剔除區.
- 撳『Remove all point prompts』剔除冚辦闌注㸃
- 勾『Enable GroundingDINO』啟用探測詞識認圖畫物件.
- 『GroundingDINO Model』擇『GroundingDNO_SwinB(938MB)』
- 『GroundingDINO Detection Prompt』填探測詞以『.』分割. 例如『text』.
- 『GroundingDINO Box Threshold』邊界框閾值.
- 勾『I want to preview GroundingDINO detection result and select the boxes I want.』預覽GroundingDINO檢測結果並選擇邊界框.
- 撳『Generate bounding box』生成邊界框.
- 『Select your favorite boxes:』勾『邊界框』『0』『1』『2』, 其中壹個.
- 撳『Preview Segmentation』預覽細分
- 勾『Copy to Inpaint Upload & img2img ControlNet Inpainting』自動上傳至『ControlNet』.
- 『Choose your favorite mask:』揀遮罩 勾『0』『1』『2』之壹.
- 勾『Expand Mask』展開遮罩,設『0~30』剔除边缘毛刺.
- 撳『Update Mask』更新遮罩.