Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ from torch import Tensor
|
|
11 |
from genstereo import GenStereo, AdaptiveFusionLayer
|
12 |
import ssl
|
13 |
from huggingface_hub import hf_hub_download
|
|
|
14 |
|
15 |
from extern.DAM2.depth_anything_v2.dpt import DepthAnythingV2
|
16 |
ssl._create_default_https_context = ssl._create_unverified_context
|
@@ -178,6 +179,7 @@ with tempfile.TemporaryDirectory() as tmpdir:
|
|
178 |
return (disp - disp.min()) / (disp.max() - disp.min())
|
179 |
|
180 |
# Callbacks
|
|
|
181 |
def cb_mde(image_file: str):
|
182 |
if not image_file:
|
183 |
# Return None if no image is provided (e.g., when file is cleared).
|
@@ -195,7 +197,7 @@ with tempfile.TemporaryDirectory() as tmpdir:
|
|
195 |
|
196 |
return image, depth_image, image, depth
|
197 |
|
198 |
-
|
199 |
def cb_generate(image, depth: Tensor, scale_factor):
|
200 |
norm_disp = normalize_disp(depth)
|
201 |
disp = norm_disp * scale_factor / 100 * IMAGE_SIZE
|
|
|
11 |
from genstereo import GenStereo, AdaptiveFusionLayer
|
12 |
import ssl
|
13 |
from huggingface_hub import hf_hub_download
|
14 |
+
import spaces
|
15 |
|
16 |
from extern.DAM2.depth_anything_v2.dpt import DepthAnythingV2
|
17 |
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
179 |
return (disp - disp.min()) / (disp.max() - disp.min())
|
180 |
|
181 |
# Callbacks
|
182 |
+
@spaces.GPU()
|
183 |
def cb_mde(image_file: str):
|
184 |
if not image_file:
|
185 |
# Return None if no image is provided (e.g., when file is cleared).
|
|
|
197 |
|
198 |
return image, depth_image, image, depth
|
199 |
|
200 |
+
@spaces.GPU()
|
201 |
def cb_generate(image, depth: Tensor, scale_factor):
|
202 |
norm_disp = normalize_disp(depth)
|
203 |
disp = norm_disp * scale_factor / 100 * IMAGE_SIZE
|