chore: update demo runtime, tests, and agent docs
This commit is contained in:
+53
-22
@@ -3,8 +3,16 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
from typing import cast
|
||||
|
||||
from .pipeline import ScoliosisPipeline
|
||||
from .pipeline import ScoliosisPipeline, WindowMode, resolve_stride
|
||||
|
||||
|
||||
def _positive_float(value: str) -> float:
|
||||
parsed = float(value)
|
||||
if parsed <= 0:
|
||||
raise argparse.ArgumentTypeError("target-fps must be positive")
|
||||
return parsed
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -29,6 +37,24 @@ if __name__ == "__main__":
|
||||
"--window", type=int, default=30, help="Window size for classification"
|
||||
)
|
||||
parser.add_argument("--stride", type=int, default=30, help="Stride for window")
|
||||
parser.add_argument(
|
||||
"--target-fps",
|
||||
type=_positive_float,
|
||||
default=15.0,
|
||||
help="Target FPS for temporal downsampling before windowing",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--window-mode",
|
||||
type=str,
|
||||
choices=["manual", "sliding", "chunked"],
|
||||
default="manual",
|
||||
help="Window scheduling mode: manual uses --stride; sliding uses stride=1; chunked uses stride=window",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-target-fps",
|
||||
action="store_true",
|
||||
help="Disable temporal downsampling and use all frames",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--nats-url", type=str, default=None, help="NATS URL for result publishing"
|
||||
)
|
||||
@@ -88,27 +114,32 @@ if __name__ == "__main__":
|
||||
source=args.source, checkpoint=args.checkpoint, config=args.config
|
||||
)
|
||||
|
||||
# Build kwargs based on what ScoliosisPipeline accepts
|
||||
pipeline_kwargs = {
|
||||
"source": args.source,
|
||||
"checkpoint": args.checkpoint,
|
||||
"config": args.config,
|
||||
"device": args.device,
|
||||
"yolo_model": args.yolo_model,
|
||||
"window": args.window,
|
||||
"stride": args.stride,
|
||||
"nats_url": args.nats_url,
|
||||
"nats_subject": args.nats_subject,
|
||||
"max_frames": args.max_frames,
|
||||
"preprocess_only": args.preprocess_only,
|
||||
"silhouette_export_path": args.silhouette_export_path,
|
||||
"silhouette_export_format": args.silhouette_export_format,
|
||||
"silhouette_visualize_dir": args.silhouette_visualize_dir,
|
||||
"result_export_path": args.result_export_path,
|
||||
"result_export_format": args.result_export_format,
|
||||
"visualize": args.visualize,
|
||||
}
|
||||
pipeline = ScoliosisPipeline(**pipeline_kwargs)
|
||||
effective_stride = resolve_stride(
|
||||
window=cast(int, args.window),
|
||||
stride=cast(int, args.stride),
|
||||
window_mode=cast(WindowMode, args.window_mode),
|
||||
)
|
||||
|
||||
pipeline = ScoliosisPipeline(
|
||||
source=cast(str, args.source),
|
||||
checkpoint=cast(str, args.checkpoint),
|
||||
config=cast(str, args.config),
|
||||
device=cast(str, args.device),
|
||||
yolo_model=cast(str, args.yolo_model),
|
||||
window=cast(int, args.window),
|
||||
stride=effective_stride,
|
||||
target_fps=(None if args.no_target_fps else cast(float, args.target_fps)),
|
||||
nats_url=cast(str | None, args.nats_url),
|
||||
nats_subject=cast(str, args.nats_subject),
|
||||
max_frames=cast(int | None, args.max_frames),
|
||||
preprocess_only=cast(bool, args.preprocess_only),
|
||||
silhouette_export_path=cast(str | None, args.silhouette_export_path),
|
||||
silhouette_export_format=cast(str, args.silhouette_export_format),
|
||||
silhouette_visualize_dir=cast(str | None, args.silhouette_visualize_dir),
|
||||
result_export_path=cast(str | None, args.result_export_path),
|
||||
result_export_format=cast(str, args.result_export_format),
|
||||
visualize=cast(bool, args.visualize),
|
||||
)
|
||||
raise SystemExit(pipeline.run())
|
||||
except ValueError as err:
|
||||
print(f"Error: {err}", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user