Spaces:
Runtime error
Runtime error
Prune unused helpers and video stubs
Browse files- README.md +1 -1
- app/config.py +0 -4
- app/data_sources.py +1 -11
- app/depth_pipeline.py +0 -22
README.md
CHANGED
|
@@ -9,7 +9,7 @@ Analyze aerial RGB imagery to detect safe drone landing sites. Combines monocula
|
|
| 9 |
</p>
|
| 10 |
|
| 11 |
## What’s inside
|
| 12 |
-
- **Main app (`landing_app.py`)** — runs full inference with adjustable thresholds, overlays, and camera assumptions; >8GB VRAM
|
| 13 |
- **Curated gallery (`demo/curated_app.py`)** — precomputed PNG/JPG/JSON artifacts for fast, zero-GPU browsing.
|
| 14 |
|
| 15 |
## Prereqs
|
|
|
|
| 9 |
</p>
|
| 10 |
|
| 11 |
## What’s inside
|
| 12 |
+
- **Main app (`landing_app.py`)** — runs full inference with adjustable thresholds, overlays, and camera assumptions; requires >8GB VRAM (assuming default 1024px processing resolution); runtime is ~1000ms per image.
|
| 13 |
- **Curated gallery (`demo/curated_app.py`)** — precomputed PNG/JPG/JSON artifacts for fast, zero-GPU browsing.
|
| 14 |
|
| 15 |
## Prereqs
|
app/config.py
CHANGED
|
@@ -5,9 +5,7 @@ from pathlib import Path
|
|
| 5 |
|
| 6 |
VISLOC_DIR = Path("data/Image/VISLOC")
|
| 7 |
IMAGE_ROOT = Path("data/Image")
|
| 8 |
-
VIDEO_DIR = Path("data/Video")
|
| 9 |
IMAGE_EXTS = (".jpg", ".jpeg", ".png", ".JPG", ".JPEG", ".PNG")
|
| 10 |
-
VIDEO_EXTS = {".mp4", ".avi", ".mov", ".mkv", ".flv", ".wmv", ".webm", ".m4v"}
|
| 11 |
DEFAULT_ALTITUDE_M = 450.0
|
| 12 |
ASSUMED_FOV_DEG = 90.0
|
| 13 |
DEFAULT_MODEL_ID = "depth-anything/DA3MONO-LARGE"
|
|
@@ -51,9 +49,7 @@ DEFAULT_ANALYZER_SETTINGS = AnalyzerSettings()
|
|
| 51 |
__all__ = [
|
| 52 |
"VISLOC_DIR",
|
| 53 |
"IMAGE_ROOT",
|
| 54 |
-
"VIDEO_DIR",
|
| 55 |
"IMAGE_EXTS",
|
| 56 |
-
"VIDEO_EXTS",
|
| 57 |
"DEFAULT_ALTITUDE_M",
|
| 58 |
"ASSUMED_FOV_DEG",
|
| 59 |
"DEFAULT_MODEL_ID",
|
|
|
|
| 5 |
|
| 6 |
VISLOC_DIR = Path("data/Image/VISLOC")
|
| 7 |
IMAGE_ROOT = Path("data/Image")
|
|
|
|
| 8 |
IMAGE_EXTS = (".jpg", ".jpeg", ".png", ".JPG", ".JPEG", ".PNG")
|
|
|
|
| 9 |
DEFAULT_ALTITUDE_M = 450.0
|
| 10 |
ASSUMED_FOV_DEG = 90.0
|
| 11 |
DEFAULT_MODEL_ID = "depth-anything/DA3MONO-LARGE"
|
|
|
|
| 49 |
__all__ = [
|
| 50 |
"VISLOC_DIR",
|
| 51 |
"IMAGE_ROOT",
|
|
|
|
| 52 |
"IMAGE_EXTS",
|
|
|
|
| 53 |
"DEFAULT_ALTITUDE_M",
|
| 54 |
"ASSUMED_FOV_DEG",
|
| 55 |
"DEFAULT_MODEL_ID",
|
app/data_sources.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
| 3 |
from functools import lru_cache
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
-
from .config import IMAGE_EXTS, IMAGE_ROOT,
|
| 7 |
|
| 8 |
|
| 9 |
@lru_cache(maxsize=1)
|
|
@@ -14,14 +14,6 @@ def list_visloc_images() -> list[Path]:
|
|
| 14 |
return sorted(files)
|
| 15 |
|
| 16 |
|
| 17 |
-
@lru_cache(maxsize=1)
|
| 18 |
-
def list_videos() -> list[Path]:
|
| 19 |
-
if not VIDEO_DIR.exists():
|
| 20 |
-
return []
|
| 21 |
-
files = [p for p in VIDEO_DIR.iterdir() if p.suffix.lower() in VIDEO_EXTS]
|
| 22 |
-
return sorted(files)
|
| 23 |
-
|
| 24 |
-
|
| 25 |
@lru_cache(maxsize=1)
|
| 26 |
def list_all_data_inputs() -> list[str]:
|
| 27 |
paths: list[Path] = []
|
|
@@ -46,13 +38,11 @@ def list_all_data_inputs() -> list[str]:
|
|
| 46 |
|
| 47 |
def clear_caches() -> None:
|
| 48 |
list_visloc_images.cache_clear()
|
| 49 |
-
list_videos.cache_clear()
|
| 50 |
list_all_data_inputs.cache_clear()
|
| 51 |
|
| 52 |
|
| 53 |
__all__ = [
|
| 54 |
"list_visloc_images",
|
| 55 |
-
"list_videos",
|
| 56 |
"list_all_data_inputs",
|
| 57 |
"clear_caches",
|
| 58 |
]
|
|
|
|
| 3 |
from functools import lru_cache
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
+
from .config import IMAGE_EXTS, IMAGE_ROOT, VISLOC_DIR
|
| 7 |
|
| 8 |
|
| 9 |
@lru_cache(maxsize=1)
|
|
|
|
| 14 |
return sorted(files)
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
@lru_cache(maxsize=1)
|
| 18 |
def list_all_data_inputs() -> list[str]:
|
| 19 |
paths: list[Path] = []
|
|
|
|
| 38 |
|
| 39 |
def clear_caches() -> None:
|
| 40 |
list_visloc_images.cache_clear()
|
|
|
|
| 41 |
list_all_data_inputs.cache_clear()
|
| 42 |
|
| 43 |
|
| 44 |
__all__ = [
|
| 45 |
"list_visloc_images",
|
|
|
|
| 46 |
"list_all_data_inputs",
|
| 47 |
"clear_caches",
|
| 48 |
]
|
app/depth_pipeline.py
CHANGED
|
@@ -48,27 +48,6 @@ def compute_roof_mask_depth(depth: np.ndarray, aggressiveness: float = 1.3, morp
|
|
| 48 |
return mask > 0
|
| 49 |
|
| 50 |
|
| 51 |
-
def fit_plane_ransac(points: np.ndarray, values: np.ndarray, iterations: int = 200, threshold: float = 0.01):
|
| 52 |
-
best_coef = None
|
| 53 |
-
best_inliers = -1
|
| 54 |
-
n_samples = points.shape[0]
|
| 55 |
-
if n_samples < 3:
|
| 56 |
-
return None
|
| 57 |
-
for _ in range(iterations):
|
| 58 |
-
idx = np.random.choice(n_samples, 3, replace=False)
|
| 59 |
-
A = np.concatenate([points[idx], np.ones((3, 1))], axis=1)
|
| 60 |
-
try:
|
| 61 |
-
coef = np.linalg.lstsq(A, values[idx], rcond=None)[0]
|
| 62 |
-
except np.linalg.LinAlgError:
|
| 63 |
-
continue
|
| 64 |
-
residuals = np.abs(points[:, 0] * coef[0] + points[:, 1] * coef[1] + coef[2] - values.flatten())
|
| 65 |
-
inliers = np.sum(residuals < threshold)
|
| 66 |
-
if inliers > best_inliers:
|
| 67 |
-
best_inliers = inliers
|
| 68 |
-
best_coef = coef
|
| 69 |
-
return best_coef
|
| 70 |
-
|
| 71 |
-
|
| 72 |
def remove_global_plane(depth: np.ndarray, method: str = "least_squares") -> np.ndarray:
|
| 73 |
if depth.ndim != 2:
|
| 74 |
return depth
|
|
@@ -205,7 +184,6 @@ __all__ = [
|
|
| 205 |
"DepthEngine",
|
| 206 |
"compute_roof_mask_depth",
|
| 207 |
"crop_nonblack",
|
| 208 |
-
"fit_plane_ransac",
|
| 209 |
"pick_flat_patch",
|
| 210 |
"remove_global_plane",
|
| 211 |
"smooth_depth",
|
|
|
|
| 48 |
return mask > 0
|
| 49 |
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def remove_global_plane(depth: np.ndarray, method: str = "least_squares") -> np.ndarray:
|
| 52 |
if depth.ndim != 2:
|
| 53 |
return depth
|
|
|
|
| 184 |
"DepthEngine",
|
| 185 |
"compute_roof_mask_depth",
|
| 186 |
"crop_nonblack",
|
|
|
|
| 187 |
"pick_flat_patch",
|
| 188 |
"remove_global_plane",
|
| 189 |
"smooth_depth",
|