phase 7
This commit is contained in:
@@ -18,6 +18,8 @@ from detect.state import DetectState
|
||||
from detect.stages.frame_extractor import extract_frames
|
||||
from detect.stages.scene_filter import scene_filter
|
||||
from detect.stages.yolo_detector import detect_objects
|
||||
from detect.stages.ocr_stage import run_ocr
|
||||
from detect.stages.brand_resolver import resolve_brands
|
||||
|
||||
INFERENCE_URL = os.environ.get("INFERENCE_URL") # None = local mode
|
||||
|
||||
@@ -101,23 +103,43 @@ def node_detect_objects(state: DetectState) -> dict:
|
||||
stats.regions_detected = sum(len(boxes) for boxes in all_boxes.values())
|
||||
|
||||
_emit_transition(state, "detect_objects", "done")
|
||||
return {"stats": stats}
|
||||
return {"boxes_by_frame": all_boxes, "stats": stats}
|
||||
|
||||
|
||||
def node_run_ocr(state: DetectState) -> dict:
|
||||
_emit_transition(state, "run_ocr", "running")
|
||||
|
||||
profile = _get_profile(state)
|
||||
config = profile.ocr_config()
|
||||
frames = state.get("filtered_frames", [])
|
||||
boxes = state.get("boxes_by_frame", {})
|
||||
job_id = state.get("job_id")
|
||||
emit.log(job_id, "OCRStage", "INFO", "Stub: OCR not yet implemented")
|
||||
|
||||
candidates = run_ocr(frames, boxes, config, inference_url=INFERENCE_URL, job_id=job_id)
|
||||
|
||||
stats = state.get("stats", PipelineStats())
|
||||
stats.regions_resolved_by_ocr = len(candidates)
|
||||
|
||||
_emit_transition(state, "run_ocr", "done")
|
||||
return {}
|
||||
return {"text_candidates": candidates, "stats": stats}
|
||||
|
||||
|
||||
def node_match_brands(state: DetectState) -> dict:
|
||||
_emit_transition(state, "match_brands", "running")
|
||||
|
||||
profile = _get_profile(state)
|
||||
dictionary = profile.brand_dictionary()
|
||||
resolver_config = profile.resolver_config()
|
||||
candidates = state.get("text_candidates", [])
|
||||
job_id = state.get("job_id")
|
||||
emit.log(job_id, "BrandResolver", "INFO", "Stub: brand matching not yet implemented")
|
||||
|
||||
matched, unresolved = resolve_brands(
|
||||
candidates, dictionary, resolver_config,
|
||||
content_type=profile.name, job_id=job_id,
|
||||
)
|
||||
|
||||
_emit_transition(state, "match_brands", "done")
|
||||
return {"detections": []}
|
||||
return {"detections": matched, "unresolved_candidates": unresolved}
|
||||
|
||||
|
||||
def node_escalate_vlm(state: DetectState) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user