huggingface / controlnet_aux

Apache License 2.0
398 stars 86 forks source link

add Segment anything #40

Closed jinwonkim93 closed 1 year ago

jinwonkim93 commented 1 year ago

This PR is to add segment anything. SamDetector returns segmented map like controlnet-segment-anything.

Usage

from controlnet_aux import SamDetector
from PIL import Image

sam = SamDetector.from_pretrained("./", model_type="vit_b", filename="sam_vit_b_01ec64.pth")
img = Image.open("image.png")
sam(img)

model_type : vit_h, vit_l, vit_b

Limitation

patrickvonplaten commented 1 year ago

Works for me!