add sam2
Browse files- app.py +3 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -6,6 +6,7 @@ from torchvision import transforms
|
|
6 |
from transformers import AutoModelForImageSegmentation
|
7 |
from diffusers import FluxFillPipeline
|
8 |
from PIL import Image, ImageOps
|
|
|
9 |
|
10 |
torch.set_float32_matmul_precision(["high", "highest"][0])
|
11 |
|
@@ -14,6 +15,8 @@ birefnet = AutoModelForImageSegmentation.from_pretrained(
|
|
14 |
)
|
15 |
birefnet.to("cuda")
|
16 |
|
|
|
|
|
17 |
transform_image = transforms.Compose(
|
18 |
[
|
19 |
transforms.Resize((1024, 1024)),
|
|
|
6 |
from transformers import AutoModelForImageSegmentation
|
7 |
from diffusers import FluxFillPipeline
|
8 |
from PIL import Image, ImageOps
|
9 |
+
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
10 |
|
11 |
torch.set_float32_matmul_precision(["high", "highest"][0])
|
12 |
|
|
|
15 |
)
|
16 |
birefnet.to("cuda")
|
17 |
|
18 |
+
predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-tiny", device="cpu")
|
19 |
+
|
20 |
transform_image = transforms.Compose(
|
21 |
[
|
22 |
transforms.Resize((1024, 1024)),
|
requirements.txt
CHANGED
@@ -19,3 +19,4 @@ kornia
|
|
19 |
huggingface_hub
|
20 |
sentencepiece
|
21 |
einops
|
|
|
|
19 |
huggingface_hub
|
20 |
sentencepiece
|
21 |
einops
|
22 |
+
git+https://github.com/facebookresearch/sam2.git
|