Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import urllib
|
3 |
|
4 |
import cv2
|
5 |
import gradio as gr
|
@@ -11,17 +10,8 @@ from PIL import Image
|
|
11 |
from segment_anything import SamAutomaticMaskGenerator, sam_model_registry
|
12 |
|
13 |
|
14 |
-
# download model weights
|
15 |
-
ckpts_dir = os.path.join(os.getcwd() + "/ckpts")
|
16 |
-
if not os.path.exists(ckpts_dir):
|
17 |
-
os.makedirs(ckpts_dir)
|
18 |
-
ckpt_path = os.path.join(ckpts_dir + "/sam_vit_b_01ec64.pth")
|
19 |
-
if not os.path.exists(ckpt_path):
|
20 |
-
url = "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth"
|
21 |
-
urllib.request.urlretrieve(url, filename=ckpt_path)
|
22 |
-
|
23 |
# setup model
|
24 |
-
sam = sam_model_registry["vit_b"](checkpoint=
|
25 |
mask_generator = SamAutomaticMaskGenerator(sam)
|
26 |
|
27 |
# copied from: https://github.com/facebookresearch/segment-anything
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
import cv2
|
4 |
import gradio as gr
|
|
|
10 |
from segment_anything import SamAutomaticMaskGenerator, sam_model_registry
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# setup model
|
14 |
+
sam = sam_model_registry["vit_b"](checkpoint="./sam_vit_b_01ec64.pth")
|
15 |
mask_generator = SamAutomaticMaskGenerator(sam)
|
16 |
|
17 |
# copied from: https://github.com/facebookresearch/segment-anything
|