Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,17 @@ from transformers import (
|
|
| 18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 19 |
print(f"Using device: {device}")
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# -----------------------------
|
| 22 |
# Model loading
|
| 23 |
# -----------------------------
|
|
@@ -27,8 +38,8 @@ print(f"Using device: {device}")
|
|
| 27 |
# a HF token that has accepted the model license (e.g. `huggingface-cli login`
|
| 28 |
# or the `HF_TOKEN` env var) or `from_pretrained` will fail to download it.
|
| 29 |
SAM3_ID = "facebook/sam3"
|
| 30 |
-
sam3_processor = Sam3Processor.from_pretrained(SAM3_ID)
|
| 31 |
-
sam3_model = Sam3Model.from_pretrained(SAM3_ID).to(device).eval()
|
| 32 |
|
| 33 |
# 2. Depth Anything V2 Large (monocular depth estimation)
|
| 34 |
DEPTH_ID = "depth-anything/Depth-Anything-V2-Large-hf"
|
|
|
|
| 18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 19 |
print(f"Using device: {device}")
|
| 20 |
|
| 21 |
+
print(f"🖥️ Using compute device: {device}")
|
| 22 |
+
|
| 23 |
+
HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
|
| 24 |
+
if HF_TOKEN:
|
| 25 |
+
print("🔐 Hugging Face token detected for gated model access.")
|
| 26 |
+
else:
|
| 27 |
+
print("⚠️ No Hugging Face token found in env (HF_TOKEN or HUGGINGFACE_HUB_TOKEN).")
|
| 28 |
+
|
| 29 |
+
print("⏳ Loading SAM3 Models permanently into memory...")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
# -----------------------------
|
| 33 |
# Model loading
|
| 34 |
# -----------------------------
|
|
|
|
| 38 |
# a HF token that has accepted the model license (e.g. `huggingface-cli login`
|
| 39 |
# or the `HF_TOKEN` env var) or `from_pretrained` will fail to download it.
|
| 40 |
SAM3_ID = "facebook/sam3"
|
| 41 |
+
sam3_processor = Sam3Processor.from_pretrained(SAM3_ID, token=HF_TOKEN)
|
| 42 |
+
sam3_model = Sam3Model.from_pretrained(SAM3_ID, token=HF_TOKEN).to(device).eval()
|
| 43 |
|
| 44 |
# 2. Depth Anything V2 Large (monocular depth estimation)
|
| 45 |
DEPTH_ID = "depth-anything/Depth-Anything-V2-Large-hf"
|