Spaces:
Running
on
Zero
Running
on
Zero
use ZeroGPU
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
| 5 |
#
|
| 6 |
# This source code is licensed under the license found in the
|
| 7 |
# LICENSE file in the root directory of this source tree.
|
|
|
|
| 8 |
import os
|
| 9 |
import cv2
|
| 10 |
import torch
|
|
@@ -35,9 +36,8 @@ path = hf_hub_download(
|
|
| 35 |
force_download=True
|
| 36 |
)
|
| 37 |
model = StreamVGGT()
|
| 38 |
-
ckpt = torch.load(path, map_location=
|
| 39 |
model.load_state_dict(ckpt, strict=True)
|
| 40 |
-
model = model.to(device)
|
| 41 |
model.eval()
|
| 42 |
del ckpt
|
| 43 |
|
|
@@ -45,6 +45,7 @@ del ckpt
|
|
| 45 |
# -------------------------------------------------------------------------
|
| 46 |
# 1) Core model inference
|
| 47 |
# -------------------------------------------------------------------------
|
|
|
|
| 48 |
def run_model(target_dir, model) -> dict:
|
| 49 |
"""
|
| 50 |
Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
|
|
@@ -187,6 +188,7 @@ def update_gallery_on_upload(input_video, input_images):
|
|
| 187 |
# -------------------------------------------------------------------------
|
| 188 |
# 4) Reconstruction: uses the target_dir plus any viz parameters
|
| 189 |
# -------------------------------------------------------------------------
|
|
|
|
| 190 |
def gradio_demo(
|
| 191 |
target_dir,
|
| 192 |
conf_thres=3.0,
|
|
@@ -524,6 +526,7 @@ with gr.Blocks(
|
|
| 524 |
# ---------------------- Examples section ----------------------
|
| 525 |
examples = get_examples_from_folder(building_folder)
|
| 526 |
|
|
|
|
| 527 |
def example_pipeline(
|
| 528 |
input_video,
|
| 529 |
num_images_str,
|
|
|
|
| 5 |
#
|
| 6 |
# This source code is licensed under the license found in the
|
| 7 |
# LICENSE file in the root directory of this source tree.
|
| 8 |
+
import spaces
|
| 9 |
import os
|
| 10 |
import cv2
|
| 11 |
import torch
|
|
|
|
| 36 |
force_download=True
|
| 37 |
)
|
| 38 |
model = StreamVGGT()
|
| 39 |
+
ckpt = torch.load(path, map_location="cpu")
|
| 40 |
model.load_state_dict(ckpt, strict=True)
|
|
|
|
| 41 |
model.eval()
|
| 42 |
del ckpt
|
| 43 |
|
|
|
|
| 45 |
# -------------------------------------------------------------------------
|
| 46 |
# 1) Core model inference
|
| 47 |
# -------------------------------------------------------------------------
|
| 48 |
+
@spaces.GPU(duration=120)
|
| 49 |
def run_model(target_dir, model) -> dict:
|
| 50 |
"""
|
| 51 |
Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
|
|
|
|
| 188 |
# -------------------------------------------------------------------------
|
| 189 |
# 4) Reconstruction: uses the target_dir plus any viz parameters
|
| 190 |
# -------------------------------------------------------------------------
|
| 191 |
+
@spaces.GPU(duration=180)
|
| 192 |
def gradio_demo(
|
| 193 |
target_dir,
|
| 194 |
conf_thres=3.0,
|
|
|
|
| 526 |
# ---------------------- Examples section ----------------------
|
| 527 |
examples = get_examples_from_folder(building_folder)
|
| 528 |
|
| 529 |
+
@spaces.GPU(duration=180)
|
| 530 |
def example_pipeline(
|
| 531 |
input_video,
|
| 532 |
num_images_str,
|