Spaces:
Runtime error
Runtime error
snehith18 commited on
Commit ·
696ce2f
1
Parent(s): 53455c9
Enable Segment Anything Model (SAM) for pixel-perfect contour masks
Browse files- download_models.py +18 -0
- requirements.txt +1 -0
download_models.py
CHANGED
|
@@ -59,6 +59,20 @@ for url in gfpgan_urls:
|
|
| 59 |
success_gfpgan = True
|
| 60 |
break
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
if not success_inswapper:
|
| 63 |
print("FATAL: Failed to download inswapper_128.onnx")
|
| 64 |
sys.exit(1)
|
|
@@ -67,4 +81,8 @@ if not success_gfpgan:
|
|
| 67 |
print("FATAL: Failed to download GFPGANv1.4.pth")
|
| 68 |
sys.exit(1)
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
print("All models downloaded successfully!")
|
|
|
|
| 59 |
success_gfpgan = True
|
| 60 |
break
|
| 61 |
|
| 62 |
+
# 3. Download sam_vit_b_01ec64.pth (SAM checkpoint)
|
| 63 |
+
sam_urls = [
|
| 64 |
+
"https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth",
|
| 65 |
+
"https://huggingface.co/YouLiXiya/YL-SAM/resolve/main/sam_vit_b_01ec64.pth",
|
| 66 |
+
"https://huggingface.co/scenario-labs/sam_vit/resolve/main/sam_vit_b_01ec64.pth"
|
| 67 |
+
]
|
| 68 |
+
sam_dest = os.path.join("weights", "sam_vit_b_01ec64.pth")
|
| 69 |
+
# Expected size: ~375 MB (375,042,383 bytes)
|
| 70 |
+
success_sam = False
|
| 71 |
+
for url in sam_urls:
|
| 72 |
+
if download_file(url, sam_dest, 350 * 1024 * 1024):
|
| 73 |
+
success_sam = True
|
| 74 |
+
break
|
| 75 |
+
|
| 76 |
if not success_inswapper:
|
| 77 |
print("FATAL: Failed to download inswapper_128.onnx")
|
| 78 |
sys.exit(1)
|
|
|
|
| 81 |
print("FATAL: Failed to download GFPGANv1.4.pth")
|
| 82 |
sys.exit(1)
|
| 83 |
|
| 84 |
+
if not success_sam:
|
| 85 |
+
print("FATAL: Failed to download sam_vit_b_01ec64.pth")
|
| 86 |
+
sys.exit(1)
|
| 87 |
+
|
| 88 |
print("All models downloaded successfully!")
|
requirements.txt
CHANGED
|
@@ -10,3 +10,4 @@ onnxruntime
|
|
| 10 |
requests==2.32.3
|
| 11 |
rembg[cpu]
|
| 12 |
gradio-client
|
|
|
|
|
|
| 10 |
requests==2.32.3
|
| 11 |
rembg[cpu]
|
| 12 |
gradio-client
|
| 13 |
+
segment-anything
|