Spaces:
Runtime error
Runtime error
Commit ·
ea0a063
1
Parent(s): 26b43e9
download checkpoints
Browse files
app.py
CHANGED
|
@@ -1417,8 +1417,49 @@ def create_ui(
|
|
| 1417 |
return demo
|
| 1418 |
|
| 1419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1420 |
def main():
|
| 1421 |
-
|
|
|
|
| 1422 |
sam_model.to(device="cuda")
|
| 1423 |
sam_predictor = SamPredictor(sam_model)
|
| 1424 |
|
|
|
|
| 1417 |
return demo
|
| 1418 |
|
| 1419 |
|
| 1420 |
+
def download_required_files():
|
| 1421 |
+
import subprocess
|
| 1422 |
+
|
| 1423 |
+
# 1. Download "checkpoints" directory from huggingface.co/gdhe17/Self-Forcing
|
| 1424 |
+
if not os.path.exists("checkpoints"):
|
| 1425 |
+
print("Downloading checkpoints from gdhe17/Self-Forcing...")
|
| 1426 |
+
subprocess.run(
|
| 1427 |
+
[
|
| 1428 |
+
"huggingface-cli", "download",
|
| 1429 |
+
"gdhe17/Self-Forcing",
|
| 1430 |
+
"--include", "checkpoints/*",
|
| 1431 |
+
"--local-dir", ".",
|
| 1432 |
+
],
|
| 1433 |
+
check=True,
|
| 1434 |
+
)
|
| 1435 |
+
|
| 1436 |
+
# 2. Download Wan-AI/Wan2.1-T2V-1.3B and place in wan_models/Wan2.1-T2V-1.3B
|
| 1437 |
+
wan_model_dir = os.path.join("wan_models", "Wan2.1-T2V-1.3B")
|
| 1438 |
+
if not os.path.exists(wan_model_dir):
|
| 1439 |
+
print("Downloading Wan-AI/Wan2.1-T2V-1.3B...")
|
| 1440 |
+
os.makedirs("wan_models", exist_ok=True)
|
| 1441 |
+
subprocess.run(
|
| 1442 |
+
[
|
| 1443 |
+
"huggingface-cli", "download",
|
| 1444 |
+
"Wan-AI/Wan2.1-T2V-1.3B",
|
| 1445 |
+
"--local-dir", wan_model_dir,
|
| 1446 |
+
],
|
| 1447 |
+
check=True,
|
| 1448 |
+
)
|
| 1449 |
+
|
| 1450 |
+
# 3. Download SAM ViT-H checkpoint
|
| 1451 |
+
sam_checkpoint_path = "sam_vit_h_4b8939.pth"
|
| 1452 |
+
if not os.path.exists(sam_checkpoint_path):
|
| 1453 |
+
print("Downloading SAM ViT-H checkpoint...")
|
| 1454 |
+
import urllib.request
|
| 1455 |
+
urllib.request.urlretrieve(
|
| 1456 |
+
"https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth",
|
| 1457 |
+
sam_checkpoint_path,
|
| 1458 |
+
)
|
| 1459 |
+
|
| 1460 |
def main():
|
| 1461 |
+
download_required_files()
|
| 1462 |
+
sam_model = sam_model_registry["vit_h"](checkpoint="./sam_vit_h_4b8939.pth")
|
| 1463 |
sam_model.to(device="cuda")
|
| 1464 |
sam_predictor = SamPredictor(sam_model)
|
| 1465 |
|