Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -291,6 +291,15 @@ def test_sam3d_only(image: np.ndarray):
|
|
| 291 |
print(f" Mask created: {mask.sum()} pixels ({time.time()-t0:.0f}s)")
|
| 292 |
|
| 293 |
from inference import Inference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
print(f" Loading SAM3D... VRAM: {torch.cuda.memory_allocated()/1e9:.1f}GB")
|
| 295 |
sam3d = Inference(CONFIG_PATH, compile=False)
|
| 296 |
print(f" SAM3D loaded ({time.time()-t0:.0f}s, VRAM: {torch.cuda.memory_allocated()/1e9:.1f}GB)")
|
|
|
|
| 291 |
print(f" Mask created: {mask.sum()} pixels ({time.time()-t0:.0f}s)")
|
| 292 |
|
| 293 |
from inference import Inference
|
| 294 |
+
# SAM3D's inference_pipeline.py auto-detects H200 and sets ATTN_BACKEND=flash_attn
|
| 295 |
+
# We must override BACK to sdpa since flash_attn is not available
|
| 296 |
+
import sam3d_objects.model.backbone.tdfy_dit.modules.attention as _attn_mod
|
| 297 |
+
import sam3d_objects.model.backbone.tdfy_dit.modules.sparse as _sparse_mod
|
| 298 |
+
_attn_mod.BACKEND = "sdpa"
|
| 299 |
+
_sparse_mod.ATTN = "sdpa"
|
| 300 |
+
os.environ["ATTN_BACKEND"] = "sdpa"
|
| 301 |
+
os.environ["SPARSE_ATTN_BACKEND"] = "sdpa"
|
| 302 |
+
print(f" Attention backends forced to sdpa")
|
| 303 |
print(f" Loading SAM3D... VRAM: {torch.cuda.memory_allocated()/1e9:.1f}GB")
|
| 304 |
sam3d = Inference(CONFIG_PATH, compile=False)
|
| 305 |
print(f" SAM3D loaded ({time.time()-t0:.0f}s, VRAM: {torch.cuda.memory_allocated()/1e9:.1f}GB)")
|