Upload folder using huggingface_hub
Browse files- app.py +11 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -27,6 +27,7 @@ import subprocess
|
|
| 27 |
import sys
|
| 28 |
import tempfile
|
| 29 |
|
|
|
|
| 30 |
import numpy as np
|
| 31 |
import spaces
|
| 32 |
import torch
|
|
@@ -56,6 +57,10 @@ from omegaconf import OmegaConf
|
|
| 56 |
from src.utils.geometry_utils import erp_to_cubemap
|
| 57 |
from src.utils.utils import prepare_depth_for_logging
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
CHECKPOINT = "prs-eth/PaGeR-metric-depth"
|
| 60 |
MAX_WIDTH = 2048 # our panoramas are 2K native; PaGeR accepts up to 3K
|
| 61 |
|
|
@@ -106,7 +111,7 @@ def predict(image_path: str):
|
|
| 106 |
depth, preview = None, None
|
| 107 |
try:
|
| 108 |
out = prepare_depth_for_logging(
|
| 109 |
-
pager, pred["depth"][0], None, (height, width),
|
| 110 |
)
|
| 111 |
depth, preview = (out if isinstance(out, (tuple, list)) else (out, None))[:2]
|
| 112 |
except Exception as exc: # pragma: no cover
|
|
@@ -118,8 +123,12 @@ def predict(image_path: str):
|
|
| 118 |
depth = depth.detach().float().cpu().numpy()
|
| 119 |
depth = np.squeeze(np.asarray(depth, dtype=np.float32))
|
| 120 |
if depth.shape != (height, width):
|
|
|
|
|
|
|
|
|
|
| 121 |
raise gr.Error(
|
| 122 |
-
f"depth came back as {depth.shape}, expected {(height, width)}"
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
if preview is None:
|
|
|
|
| 27 |
import sys
|
| 28 |
import tempfile
|
| 29 |
|
| 30 |
+
import matplotlib
|
| 31 |
import numpy as np
|
| 32 |
import spaces
|
| 33 |
import torch
|
|
|
|
| 57 |
from src.utils.geometry_utils import erp_to_cubemap
|
| 58 |
from src.utils.utils import prepare_depth_for_logging
|
| 59 |
|
| 60 |
+
# `prepare_depth_for_logging` *calls* its cmap argument, so it needs a
|
| 61 |
+
# colormap object; a name string raises "'str' object is not callable".
|
| 62 |
+
CMAP = matplotlib.colormaps["Spectral"]
|
| 63 |
+
|
| 64 |
CHECKPOINT = "prs-eth/PaGeR-metric-depth"
|
| 65 |
MAX_WIDTH = 2048 # our panoramas are 2K native; PaGeR accepts up to 3K
|
| 66 |
|
|
|
|
| 111 |
depth, preview = None, None
|
| 112 |
try:
|
| 113 |
out = prepare_depth_for_logging(
|
| 114 |
+
pager, pred["depth"][0], None, (height, width), CMAP
|
| 115 |
)
|
| 116 |
depth, preview = (out if isinstance(out, (tuple, list)) else (out, None))[:2]
|
| 117 |
except Exception as exc: # pragma: no cover
|
|
|
|
| 123 |
depth = depth.detach().float().cpu().numpy()
|
| 124 |
depth = np.squeeze(np.asarray(depth, dtype=np.float32))
|
| 125 |
if depth.shape != (height, width):
|
| 126 |
+
# pred["depth"] is the per-face cubemap (6, face, face); the merge back
|
| 127 |
+
# to equirect happens inside prepare_depth_for_logging, so this means
|
| 128 |
+
# that call failed and the fallback cannot substitute for it.
|
| 129 |
raise gr.Error(
|
| 130 |
+
f"depth came back as {depth.shape}, expected {(height, width)} — "
|
| 131 |
+
"the equirect merge did not run; check the Space logs."
|
| 132 |
)
|
| 133 |
|
| 134 |
if preview is None:
|
requirements.txt
CHANGED
|
@@ -11,3 +11,4 @@ huggingface_hub
|
|
| 11 |
omegaconf
|
| 12 |
numpy
|
| 13 |
pillow
|
|
|
|
|
|
| 11 |
omegaconf
|
| 12 |
numpy
|
| 13 |
pillow
|
| 14 |
+
matplotlib
|