mirror of
https://github.com/PR0M3TH3AN/unredact.git
synced 2026-11-11 08:01:04 +00:00
feat: wire analyze endpoint to use cached OCR data
Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
1 parent
f24a710b9e
commit
03333e212c
1 file changed
+6
-1
+6
-1
@@ -178,8 +178,9 @@ async def analyze_doc(doc_id: str):
|
||||
async def event_generator():
|
||||
for page_num, pd in doc["pages"].items():
|
||||
page_img = pd["original"]
|
||||
ocr_lines = pd.get("ocr_lines")
|
||||
try:
|
||||
analysis = await analyze_page(page_img)
|
||||
analysis = await analyze_page(page_img, ocr_lines=ocr_lines)
|
||||
except Exception as exc:
|
||||
yield json.dumps({
|
||||
"event": "error",
|
||||
@@ -190,6 +191,10 @@ async def analyze_doc(doc_id: str):
|
||||
|
||||
pd["analysis"] = analysis
|
||||
|
||||
# Cache OCR lines if not already cached
|
||||
if pd.get("ocr_lines") is None:
|
||||
pd["ocr_lines"] = analysis.lines
|
||||
|
||||
redactions_json = []
|
||||
for r in analysis.redactions:
|
||||
font_id = _make_font_id(r.font.font_name)
|
||||
|
||||
Reference in new issue
Block a user