Files
momentry_core/v1.1/scripts/crop_stamp_v1.11.py
Accusys 2cfcfdd1af 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
2026-06-21 04:47:49 +08:00

41 lines
1005 B
Python

#!/opt/homebrew/bin/python3.11
"""
Crop the detected stamp from the image.
"""
from PIL import Image
import os
UUID = "384b0ff44aaaa1f1"
BASE_DIR = f"output/{UUID}/florence2_results"
IMG_NAME = "raw_6846.jpg"
img_path = os.path.join(BASE_DIR, IMG_NAME)
# Coordinates from the successful run that detected 'stamp'
# Format: [x_min, y_min, x_max, y_max]
box = [1721.28, 23.22, 1813.44, 173.34]
print(f"📷 Loading image: {img_path}")
if not os.path.exists(img_path):
print("❌ Image not found.")
exit()
try:
img = Image.open(img_path)
print(f"📐 Image Size: {img.width}x{img.height}")
# Convert float coordinates to int
box_int = [int(x) for x in box]
print(f"✂️ Cropping box: {box_int}")
# Crop the image
cropped = img.crop(box_int)
# Save
out_path = os.path.join(BASE_DIR, "stamp_crop_detected.jpg")
cropped.save(out_path)
print(f"✅ Successfully saved cropped stamp to {out_path}")
except Exception as e:
print(f"❌ Error: {e}")