Stable Diffusion插件-畫面識認segment anything

Stable Diffusion插件-畫面識認segment anything
Stable Diffusion插件-畫面識認segment anything

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

 

  1. 撳『Extensions擴展』->『Install from URL係網裝』
https://github.com/continue-revolution/sd-webui-segment-anything.git
  1. 撳『Install』下載.

 

  1. 手動下載『Segment Anything』
  2. 登入CMD命令行模式
  3. 指定當前資料夾
CD C:\stable-diffusion-webui\extensions\
  1. 下載『segment anything』
git clone https://github.com/continue-revolution/sd-webui-segment-anything.git
  1. 如出錯刪下列檔䅁夾,再重新下載
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
  1. 使能本地编译『GroundingDINO』
  2. 撳『Settings』->『Segment Anything』
  3. 撳『Use local groundingdino to bypass C++ problem』用本地groundingdino繞過C++編譯問題.
  4. 撳『Apply settings』
  5. 撳『Reload UI』

 

  1. 允許『segment anything』傅递畀『ControlNet』
  2. 撳『Settings』->『ControlNet』
  3. 勾『Allow Other script to control this extension允許其他它脚本對擴展插件進行控制』.
  4. 撳『Apply settings』
  5. 撳『Reload UI』

 

  1. 撳『img2img』->『Segment Anything』
  2. 『SAM Model』擇『pth』
  3. 係『single image』上傅圖畫.
  4. 撳左鍵黑㸃保留區, 撳右鍵紅㸃剔除區.
  5. 撳『Remove all point prompts』剔除冚辦闌注㸃
  6. 勾『Enable GroundingDINO』啟用探測詞識認圖畫物件.
  7. 『GroundingDINO Model』擇『GroundingDNO_SwinB(938MB)』
  8. 『GroundingDINO Detection Prompt』填探測詞以『.』分割. 例如『text』.
  9. 『GroundingDINO Box Threshold』邊界框閾值.
  10. 勾『I want to preview GroundingDINO detection result and select the boxes I want.』預覽GroundingDINO檢測結果並選擇邊界框.
  11. 撳『Generate bounding box』生成邊界框.
  12. 『Select your favorite boxes:』勾『邊界框』『0』『1』『2』, 其中壹個.
  13. 撳『Preview Segmentation』預覽細分
  14. 勾『Copy to Inpaint Upload & img2img ControlNet Inpainting』自動上傳至『ControlNet』.
  15. 『Choose your favorite mask:』揀遮罩 勾『0』『1』『2』之壹.
  16. 勾『Expand Mask』展開遮罩,設『0~30』剔除边缘毛刺.
  17. 撳『Update Mask』更新遮罩.

評論