feat: batch LLM OCR — multiple images in one API call + downscaling
- Add run_ocr_llm_batch() — sends N images in a single vision API call with structured JSON prompt, up to 20 images per batch - Add _resize_for_llm() — downscales images to 1600px max dimension before sending to LLM, reducing per-image token cost - Update bulk_process() to pre-read all files and batch-OCR in one call - Graceful fallback: if batch JSON parsing fails, retries individually - Frontend shows llm_batch engine badge Without batch: N photos = N API calls (each with full prompt overhead) With batch: N photos = ceil(N/20) API calls + image downscaling savings
This commit is contained in:
+2
-2
@@ -487,8 +487,8 @@ async function uploadSelected() {
|
||||
|
||||
// OCR
|
||||
const ocr = data.ocr;
|
||||
const engineCls = ocr.engine === 'llm' ? 'llm' : 'tesseract';
|
||||
html += '<div style="margin-top:10px;font-weight:600;">🔤 OCR <span class="engine-badge ' + engineCls + '">' + esc(ocr.engine || 'tesseract') + (ocr.llm_model ? ' ' + ocr.llm_model : '') + '</span></div>';
|
||||
const engineCls = ocr.engine === 'llm' || ocr.engine === 'llm_batch' ? 'llm' : 'tesseract';
|
||||
html += '<div style="margin-top:10px;font-weight:600;">🔤 OCR <span class="engine-badge ' + engineCls + '">' + esc(ocr.engine || 'tesseract') + (ocr.llm_model ? ' ' + esc(ocr.llm_model) : '') + '</span></div>';
|
||||
if (ocr.raw_text) {
|
||||
html += '<div class="ocr-text">' + esc(ocr.raw_text) + '</div>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user