Spaces:
Running
Running
Load litert-ocr 0.2.1 again: the same start-up check also stalled with 0.2.0 (slow model downloads)
Browse filesFiles changed (3)
- app.js+3-2
- coi-serviceworker.js+2-2
- index.html+1-1
5 unmodified lines6789101112162 unmodified lines1751761771781791801815 unmodified linesimport { renderMarkdown } from './md.js';const LIBRARY = 'https://cdn.jsdelivr.net/npm/litert-ocr@0.2.0/+esm';/** Pages read per PDF on this page; the library itself reads up to `maxPages` (default 100). */const MAX_PAGES = 20;/** convert() reads PDF pages at 150 dpi; block boxes are in pixels of that size. */162 unmodified lineselse if (m.status === 'initializing model') setStatus('busy', 'Preparing the model…');}if (m.status === 'notice' && m.message) {if (/^Recognizer on /.test(m.message)) return;if (/not cross-origin isolated/.test(m.message)) return; // said above in this page's words// a file the browser would not store: the status line must not say the files are keptconst notKept = /^Could not cache (\S+)/.exec(m.message)?.[1];5 unmodified lines6789101112162 unmodified lines1751761771781791801811825 unmodified linesimport { renderMarkdown } from './md.js';const LIBRARY = 'https://cdn.jsdelivr.net/npm/litert-ocr@0.2.1/+esm';/** Pages read per PDF on this page; the library itself reads up to `maxPages` (default 100). */const MAX_PAGES = 20;/** convert() reads PDF pages at 150 dpi; block boxes are in pixels of that size. */162 unmodified lineselse if (m.status === 'initializing model') setStatus('busy', 'Preparing the model…');}if (m.status === 'notice' && m.message) {// where the recognizers run is on the info line: the start notice and the per-width check notices (0.2.1) stay offif (/^Recognizer on |^The \d+-wide recognizer read the check line /.test(m.message)) return;if (/not cross-origin isolated/.test(m.message)) return; // said above in this page's words// a file the browser would not store: the status line must not say the files are keptconst notKept = /^Could not cache (\S+)/.exec(m.message)?.[1];
51 unmodified lines52535455565758596051 unmodified lines});// [litert-ocr demo] the files kept for offline visits: this origin's GET requests, the pinned library module and// the pdf.js version it pins (litert-ocr 0.2.0: pdfjs-dist 6.4.299)const OFFLINE_CACHE = "litert-ocr-demo-page";const keep = (r) => r.method === "GET" && (new URL(r.url).origin === self.location.origin || r.url === "https://cdn.jsdelivr.net/npm/litert-ocr@0.2.0/+esm" || r.url.startsWith("https://cdn.jsdelivr.net/npm/pdfjs-dist@6.4.299/"));function withHeaders(response) {const newHeaders = new Headers(response.headers);51 unmodified lines52535455565758596051 unmodified lines});// [litert-ocr demo] the files kept for offline visits: this origin's GET requests, the pinned library module and// the pdf.js version it pins (litert-ocr 0.2.1: pdfjs-dist 6.4.299)const OFFLINE_CACHE = "litert-ocr-demo-page";const keep = (r) => r.method === "GET" && (new URL(r.url).origin === self.location.origin || r.url === "https://cdn.jsdelivr.net/npm/litert-ocr@0.2.1/+esm" || r.url.startsWith("https://cdn.jsdelivr.net/npm/pdfjs-dist@6.4.299/"));function withHeaders(response) {const newHeaders = new Headers(response.headers);
96 unmodified lines97989910010110210396 unmodified lines<p>Photos and screenshots: every text line and its box, in reading order (<code>worker.recognize(file)</code>). PDFs, scans and the Markdown and JSON tabs: pages with a text layer are read from it, scanned pages by OCR, and the lines become headings, paragraphs, lists and tables (<code>convert(file)</code>). A PDF's page is shown with a frame around each heading, paragraph, list item and table that <code>convert()</code> found on it, colored by type; the arrows under the page turn the pages read.</p><p>Your files are read in this tab. The page downloads only the litert-ocr library, its LiteRT.js runtime and pdf.js from jsDelivr, and the model files from Hugging Face, once: about 80 MB over the network on the first visit (litert-ocr 0.1.0 in Chrome 155 on a Mac, 2026-10-22; 87 MB uncompressed, the size the status line shows). The browser keeps them. A page that is already open goes on reading with no network (tested in Chrome on a Mac and on an Android phone in airplane mode). Opening the page again with no network worked in Chrome on a Mac, not in Chrome on Android.</p><p>The time shown is from handing the file to the library to the result, with the model already loaded. PDFs are read up to 20 pages per file here.</p><p><a href="https://github.com/john-rocky/litert-ocr">Source and documentation</a> · <a href="https://github.com/john-rocky/litert-ocr/tree/main/demo">This page's code</a> · <span id="version">litert-ocr 0.2.0</span></p></section></main></body>96 unmodified lines97989910010110210396 unmodified lines<p>Photos and screenshots: every text line and its box, in reading order (<code>worker.recognize(file)</code>). PDFs, scans and the Markdown and JSON tabs: pages with a text layer are read from it, scanned pages by OCR, and the lines become headings, paragraphs, lists and tables (<code>convert(file)</code>). A PDF's page is shown with a frame around each heading, paragraph, list item and table that <code>convert()</code> found on it, colored by type; the arrows under the page turn the pages read.</p><p>Your files are read in this tab. The page downloads only the litert-ocr library, its LiteRT.js runtime and pdf.js from jsDelivr, and the model files from Hugging Face, once: about 80 MB over the network on the first visit (litert-ocr 0.1.0 in Chrome 155 on a Mac, 2026-10-22; 87 MB uncompressed, the size the status line shows). The browser keeps them. A page that is already open goes on reading with no network (tested in Chrome on a Mac and on an Android phone in airplane mode). Opening the page again with no network worked in Chrome on a Mac, not in Chrome on Android.</p><p>The time shown is from handing the file to the library to the result, with the model already loaded. PDFs are read up to 20 pages per file here.</p><p><a href="https://github.com/john-rocky/litert-ocr">Source and documentation</a> · <a href="https://github.com/john-rocky/litert-ocr/tree/main/demo">This page's code</a> · <span id="version">litert-ocr 0.2.1</span></p></section></main></body>
app.js+3-2
coi-serviceworker.js+2-2
index.html+1-1