Zhen Ye Claude Opus 4.6 commited on
Commit
afbbf27
·
1 Parent(s): 078b447

feat: expose num_maskmem parameter in benchmark profile/analysis endpoints

Browse files
Files changed (2) hide show
  1. app.py +5 -0
  2. utils/profiler.py +2 -0
app.py CHANGED
@@ -1041,6 +1041,7 @@ async def benchmark_profile(
1041
  max_frames: int = Form(100),
1042
  warmup_frames: int = Form(5),
1043
  step: int = Form(20),
 
1044
  ):
1045
  """Run profiled inference and return per-frame timing breakdown.
1046
 
@@ -1053,6 +1054,7 @@ async def benchmark_profile(
1053
  max_frames: Maximum frames to profile.
1054
  warmup_frames: Warmup frames (detection only).
1055
  step: Keyframe interval (segmentation only).
 
1056
  """
1057
  import dataclasses
1058
  from utils.profiler import run_profiled_detection, run_profiled_segmentation
@@ -1077,6 +1079,7 @@ async def benchmark_profile(
1077
  run_profiled_segmentation,
1078
  input_path, segmenter, query_list,
1079
  max_frames=max_frames, step=step,
 
1080
  )
1081
  except Exception as exc:
1082
  _safe_delete(input_path)
@@ -1104,6 +1107,7 @@ async def benchmark_analysis(
1104
  max_frames: int = Form(100),
1105
  warmup_frames: int = Form(5),
1106
  step: int = Form(20),
 
1107
  ):
1108
  """Full roofline analysis: hardware + profiling + theoretical ceilings + bottleneck ID.
1109
 
@@ -1139,6 +1143,7 @@ async def benchmark_analysis(
1139
  run_profiled_segmentation,
1140
  input_path, segmenter, query_list,
1141
  max_frames=max_frames, step=step,
 
1142
  )
1143
 
1144
  # Compute roofline
 
1041
  max_frames: int = Form(100),
1042
  warmup_frames: int = Form(5),
1043
  step: int = Form(20),
1044
+ num_maskmem: Optional[int] = Form(None),
1045
  ):
1046
  """Run profiled inference and return per-frame timing breakdown.
1047
 
 
1054
  max_frames: Maximum frames to profile.
1055
  warmup_frames: Warmup frames (detection only).
1056
  step: Keyframe interval (segmentation only).
1057
+ num_maskmem: SAM2 memory frames (None = model default 7).
1058
  """
1059
  import dataclasses
1060
  from utils.profiler import run_profiled_detection, run_profiled_segmentation
 
1079
  run_profiled_segmentation,
1080
  input_path, segmenter, query_list,
1081
  max_frames=max_frames, step=step,
1082
+ num_maskmem=num_maskmem,
1083
  )
1084
  except Exception as exc:
1085
  _safe_delete(input_path)
 
1107
  max_frames: int = Form(100),
1108
  warmup_frames: int = Form(5),
1109
  step: int = Form(20),
1110
+ num_maskmem: Optional[int] = Form(None),
1111
  ):
1112
  """Full roofline analysis: hardware + profiling + theoretical ceilings + bottleneck ID.
1113
 
 
1143
  run_profiled_segmentation,
1144
  input_path, segmenter, query_list,
1145
  max_frames=max_frames, step=step,
1146
+ num_maskmem=num_maskmem,
1147
  )
1148
 
1149
  # Compute roofline
utils/profiler.py CHANGED
@@ -328,6 +328,7 @@ def run_profiled_segmentation(
328
  queries: List[str],
329
  max_frames: int = 100,
330
  step: int = 20,
 
331
  ) -> ProfilingResult:
332
  """Run profiled segmentation (GSAM2) on a video file.
333
 
@@ -393,6 +394,7 @@ def run_profiled_segmentation(
393
  max_frames=max_frames,
394
  _perf_metrics=metrics,
395
  _perf_lock=lock,
 
396
  )
397
  except Exception as e:
398
  logger.error("Profiled segmentation failed: %s", e)
 
328
  queries: List[str],
329
  max_frames: int = 100,
330
  step: int = 20,
331
+ num_maskmem: Optional[int] = None,
332
  ) -> ProfilingResult:
333
  """Run profiled segmentation (GSAM2) on a video file.
334
 
 
394
  max_frames=max_frames,
395
  _perf_metrics=metrics,
396
  _perf_lock=lock,
397
+ num_maskmem=num_maskmem,
398
  )
399
  except Exception as e:
400
  logger.error("Profiled segmentation failed: %s", e)