Spaces:
Sleeping
Sleeping
Zhen Ye
commited on
Commit
·
ff62bd0
1
Parent(s):
9a35d39
Reduce log verbosity and update default depth scale to 100
Browse files- inference.py +8 -5
inference.py
CHANGED
|
@@ -173,7 +173,7 @@ def _build_detection_records(
|
|
| 173 |
|
| 174 |
_MODEL_LOCKS: Dict[str, RLock] = {}
|
| 175 |
_MODEL_LOCKS_GUARD = RLock()
|
| 176 |
-
_DEPTH_SCALE = float(os.getenv("DEPTH_SCALE", "
|
| 177 |
|
| 178 |
|
| 179 |
def _get_model_lock(kind: str, name: str) -> RLock:
|
|
@@ -312,7 +312,7 @@ def infer_frame(
|
|
| 312 |
# Add depth to label, e.g. "car 12m"
|
| 313 |
depth_str = f"{int(det['depth_est_m'])}m"
|
| 314 |
label = f"{label} {depth_str}"
|
| 315 |
-
logging.
|
| 316 |
display_labels.append(label)
|
| 317 |
|
| 318 |
except Exception:
|
|
@@ -491,7 +491,8 @@ def run_inference(
|
|
| 491 |
detector_instance = detectors[gpu_idx]
|
| 492 |
depth_instance = depth_estimators[gpu_idx] if depth_estimators else None
|
| 493 |
|
| 494 |
-
|
|
|
|
| 495 |
|
| 496 |
# Run depth estimation every 3 frames if configured
|
| 497 |
active_depth_name = depth_estimator_name if (frame_idx % 3 == 0) else None
|
|
@@ -612,7 +613,8 @@ def run_segmentation(
|
|
| 612 |
gpu_idx = frame_idx % len(segmenters)
|
| 613 |
segmenter_instance = segmenters[gpu_idx]
|
| 614 |
|
| 615 |
-
|
|
|
|
| 616 |
|
| 617 |
processed, _ = infer_segmentation_frame(
|
| 618 |
frame_data,
|
|
@@ -757,7 +759,8 @@ def process_frames_depth(
|
|
| 757 |
gpu_idx = frame_idx % len(estimators)
|
| 758 |
estimator_instance = estimators[gpu_idx]
|
| 759 |
|
| 760 |
-
|
|
|
|
| 761 |
|
| 762 |
# Use instance lock
|
| 763 |
if hasattr(estimator_instance, "lock"):
|
|
|
|
| 173 |
|
| 174 |
_MODEL_LOCKS: Dict[str, RLock] = {}
|
| 175 |
_MODEL_LOCKS_GUARD = RLock()
|
| 176 |
+
_DEPTH_SCALE = float(os.getenv("DEPTH_SCALE", "100.0"))
|
| 177 |
|
| 178 |
|
| 179 |
def _get_model_lock(kind: str, name: str) -> RLock:
|
|
|
|
| 312 |
# Add depth to label, e.g. "car 12m"
|
| 313 |
depth_str = f"{int(det['depth_est_m'])}m"
|
| 314 |
label = f"{label} {depth_str}"
|
| 315 |
+
logging.debug("Object '%s' at %s (bbox: %s)", label, depth_str, det['bbox'])
|
| 316 |
display_labels.append(label)
|
| 317 |
|
| 318 |
except Exception:
|
|
|
|
| 491 |
detector_instance = detectors[gpu_idx]
|
| 492 |
depth_instance = depth_estimators[gpu_idx] if depth_estimators else None
|
| 493 |
|
| 494 |
+
if frame_idx % 30 == 0:
|
| 495 |
+
logging.info("Processing frame %d on GPU %d (cuda:%d)", frame_idx, gpu_idx, gpu_idx)
|
| 496 |
|
| 497 |
# Run depth estimation every 3 frames if configured
|
| 498 |
active_depth_name = depth_estimator_name if (frame_idx % 3 == 0) else None
|
|
|
|
| 613 |
gpu_idx = frame_idx % len(segmenters)
|
| 614 |
segmenter_instance = segmenters[gpu_idx]
|
| 615 |
|
| 616 |
+
if frame_idx % 30 == 0:
|
| 617 |
+
logging.info("Segmenting frame %d on GPU %d (cuda:%d)", frame_idx, gpu_idx, gpu_idx)
|
| 618 |
|
| 619 |
processed, _ = infer_segmentation_frame(
|
| 620 |
frame_data,
|
|
|
|
| 759 |
gpu_idx = frame_idx % len(estimators)
|
| 760 |
estimator_instance = estimators[gpu_idx]
|
| 761 |
|
| 762 |
+
if frame_idx % 30 == 0:
|
| 763 |
+
logging.info("Estimating depth for frame %d on GPU %d (cuda:%d)", frame_idx, gpu_idx, gpu_idx)
|
| 764 |
|
| 765 |
# Use instance lock
|
| 766 |
if hasattr(estimator_instance, "lock"):
|