Spaces:
Running
on
Zero
Running
on
Zero
download pretrained models
Browse files- app.py +11 -0
- get_pretrained_models.sh +8 -0
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import rerun as rr
|
2 |
import rerun.blueprint as rrb
|
3 |
import depth_pro
|
|
|
4 |
|
5 |
import torch
|
6 |
import cv2
|
@@ -8,6 +9,16 @@ from pathlib import Path
|
|
8 |
import gradio as gr
|
9 |
from gradio_rerun import Rerun
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
@rr.thread_local_stream("rerun_example_ml_depth_pro")
|
13 |
def run_ml_depth_pro(model, transform, frames):
|
|
|
1 |
import rerun as rr
|
2 |
import rerun.blueprint as rrb
|
3 |
import depth_pro
|
4 |
+
import subprocess
|
5 |
|
6 |
import torch
|
7 |
import cv2
|
|
|
9 |
import gradio as gr
|
10 |
from gradio_rerun import Rerun
|
11 |
|
12 |
+
# Run the script to get pretrained models
|
13 |
+
subprocess.run(["bash", "get_pretrained_models.sh"])
|
14 |
+
|
15 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
16 |
+
|
17 |
+
# Load model and preprocessing transform
|
18 |
+
model, transform = depth_pro.create_model_and_transforms()
|
19 |
+
model = model.to(device)
|
20 |
+
model.eval()
|
21 |
+
|
22 |
|
23 |
@rr.thread_local_stream("rerun_example_ml_depth_pro")
|
24 |
def run_ml_depth_pro(model, transform, frames):
|
get_pretrained_models.sh
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
#
|
3 |
+
# For licensing see accompanying LICENSE file.
|
4 |
+
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
|
5 |
+
#
|
6 |
+
mkdir -p checkpoints
|
7 |
+
# Place final weights here:
|
8 |
+
wget https://ml-site.cdn-apple.com/models/depth-pro/depth_pro.pt -P checkpoints
|