compare view

This commit is contained in:
2026-03-30 13:05:28 -03:00
parent aac27b8504
commit 55e83e4203
23 changed files with 1321 additions and 201 deletions

View File

@@ -2,8 +2,8 @@
"""
Seed a scenario from a video chunk.
Creates a Timeline (frames in MinIO) + Branch + Checkpoint marked
as a scenario. No pipeline, no Redis, no SSE.
Creates a Timeline + caches frames + Checkpoint marked as scenario.
No pipeline, no Redis, no SSE.
Prerequisites:
- Postgres reachable (Kind NodePort or local)
@@ -14,7 +14,7 @@ Usage:
python tests/detect/manual/seed_scenario.py --video media/mpr/out/chunks/.../chunk_0001.mp4
Then open:
http://mpr.local.ar/detection/?job=<TIMELINE_ID>#/editor/detect_edges
http://mpr.local.ar/detection/?job=<JOB_ID>#/editor/detect_edges
"""
from __future__ import annotations
@@ -110,36 +110,41 @@ def main():
frames = extract_frames_ffmpeg(video_path, args.fps, args.max_frames)
logger.info("Extracted %d frames", len(frames))
# Create timeline + branch + checkpoint
from core.detect.checkpoint.storage import create_timeline, save_stage_output
# Create timeline
from core.detect.checkpoint.storage import (
create_timeline, save_checkpoint, update_timeline_status,
)
from core.detect.checkpoint.frames import cache_frames
timeline_id, branch_id = create_timeline(
source_video=video_path,
timeline_id = create_timeline(
chunk_paths=[video_path],
profile_name="soccer_broadcast",
frames=frames,
name=args.label,
fps=args.fps,
)
# Mark as scenario
from core.db import get_latest_checkpoint
from core.db.connection import get_session
# Cache frames on the timeline
cache_frames(timeline_id, frames)
update_timeline_status(timeline_id, "cached", frame_count=len(frames))
with get_session() as session:
checkpoint = get_latest_checkpoint(session, branch_id)
if checkpoint:
checkpoint.is_scenario = True
checkpoint.scenario_label = args.label
session.commit()
# Create scenario checkpoint
checkpoint_id = save_checkpoint(
timeline_id=timeline_id,
stage_name="extract_frames",
is_scenario=True,
scenario_label=args.label,
stats={"frames_extracted": len(frames)},
)
logger.info("")
logger.info("Scenario created:")
logger.info(" Timeline: %s", timeline_id)
logger.info(" Branch: %s", branch_id)
logger.info(" Checkpoint: %s", checkpoint_id)
logger.info(" Label: %s", args.label)
logger.info(" Frames: %d", len(frames))
logger.info("")
logger.info("Open in editor:")
logger.info(" http://mpr.local.ar/detection/?job=%s#/editor/detect_edges", timeline_id)
logger.info("Open in source selector to see the timeline:")
logger.info(" http://mpr.local.ar/detection/")
if __name__ == "__main__":