feat: Phase 2.6 edges migration to Qdrant (TKG-only architecture)
Phase 2.6.1: co_occurrence_edges migration - build_co_occurrence_edges_from_qdrant() - Qdrant embeddings → frame grouping → YOLO objects - Result: 6679 edges (vs 6701 PostgreSQL) Phase 2.6.2: face_face_edges migration - build_face_face_edges_from_qdrant() - Qdrant embeddings → frame grouping → face pairs - mutual_gaze detection preserved - Result: 6 edges (exact match) Phase 2.6.3: speaker_face_edges migration - build_speaker_face_edges_from_qdrant() - Qdrant embeddings → trace_id frame ranges - SPEAKS_AS edge creation Architecture: - All edges use Qdrant payload (no face_detections queries) - PostgreSQL fallback for empty Qdrant - Estimated 3.6x performance improvement Testing: - Playground (3003): ✓ All Phase 2.6 logs verified - Edge counts: ✓ Close match with PostgreSQL - Fallback: ✓ Working Docs: - docs_v1.0/DESIGN/TKG_PHASE2_6_EDGES_MIGRATION.md - docs_v1.0/M4_workspace/2026-06-21_phase2_6_test.md
This commit is contained in:
48
v1.1/scripts/insert_chunks_v1.11.py
Normal file
48
v1.1/scripts/insert_chunks_v1.11.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/opt/homebrew/bin/python3.11
|
||||
"""Insert sentence chunks from transcribe.py output into dev.chunk table."""
|
||||
import json, sys
|
||||
import psycopg2
|
||||
|
||||
DB = "dbname=momentry user=accusys"
|
||||
UUID = sys.argv[1] if len(sys.argv) > 1 else "23b1c872379d4ec06479e5ed39eef4c5"
|
||||
ASR_PATH = f"/Users/accusys/momentry/output_dev/{UUID}.asr.json"
|
||||
FPS = 23.976023976023978
|
||||
|
||||
with open(ASR_PATH) as f:
|
||||
asr = json.load(f)
|
||||
|
||||
segments = asr.get("segments", [])
|
||||
print(f"Inserting {len(segments)} sentence chunks for {UUID}...")
|
||||
|
||||
conn = psycopg2.connect(DB)
|
||||
cur = conn.cursor()
|
||||
|
||||
inserted = 0
|
||||
for seg in segments:
|
||||
chunk_id = seg["chunk_id"]
|
||||
start_time = seg["start_time"]
|
||||
end_time = seg["end_time"]
|
||||
start_frame = int(start_time * FPS)
|
||||
end_frame = int(end_time * FPS)
|
||||
text = seg.get("text", "")
|
||||
speaker_change = seg.get("speaker_change", False)
|
||||
|
||||
content = json.dumps({
|
||||
"source": "transcribe",
|
||||
"speaker_change": speaker_change,
|
||||
"pass1_index": seg.get("pass1_index", 0),
|
||||
})
|
||||
|
||||
cur.execute("""
|
||||
INSERT INTO dev.chunk (file_uuid, chunk_id, chunk_type, start_time, end_time,
|
||||
start_frame, end_frame, fps, text_content, content, created_at)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s::jsonb, NOW())
|
||||
ON CONFLICT (file_uuid, chunk_id) DO NOTHING
|
||||
""", (UUID, chunk_id, "sentence", start_time, end_time,
|
||||
start_frame, end_frame, FPS, text, content))
|
||||
inserted += 1
|
||||
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print(f"Done: {inserted} chunks inserted")
|
||||
Reference in New Issue
Block a user