xxyyy123 commited on
Commit
8e1cd13
·
verified ·
1 Parent(s): 5bda61a

Update technical report link

Browse files

Point the Technical Report header link to the OvisOCR2 PDF on GitHub. The frontend asset filename is refreshed to avoid stale browser caches.

dist/assets/{index-uj7s2XQX.js → index-tech-report-20260716.js} RENAMED
@@ -119,4 +119,4 @@ ${r[c]||""}`).join(`
119
 
120
  ---
121
 
122
- `)}function vy(u,c,s){const r=new Map(c.map(p=>[p.page_number,p]));for(const p of u.pages||[]){const b=r.get(p.page_number)||{};r.set(p.page_number,{...b,...p})}const f=Number(u.current_page||1),h=[...r.values()].map(p=>Number(p.page_number)<f&&p.status==="streaming"?{...p,status:"complete"}:p).sort((p,b)=>p.page_number-b.page_number);return{...u,pages:h,markdown:dd(h,"markdown"),render_markdown:dd(h,"render_markdown"),char_count:h.reduce((p,b)=>{var m;return p+(((m=b.markdown)==null?void 0:m.length)||0)},0),elapsed_seconds:(performance.now()-s)/1e3}}function _y(u,c){const s=new Set(u.filter(f=>f.status==="complete").map(f=>Number(f.page_number)));let r=0;for(;r<c&&s.has(r+1);)r+=1;return r}function Sy(){const[u,c]=g.useState(null),[s,r]=g.useState(null),[f,h]=g.useState(null),[p,b]=g.useState(72),[m,v]=g.useState("rendered"),[T,w]=g.useState(null),[H,I]=g.useState(0),[L,$]=g.useState({}),[Z,te]=g.useState({type:"ready",text:"Upload a document to begin"}),[de,Ge]=g.useState(!1),[Se,ke]=g.useState(!1),[oe,ne]=g.useState(""),ut=g.useRef(null),yt=g.useRef(null),at=g.useRef(null),tt=g.useRef(null),Ie=g.useRef(!1),Jt=g.useRef(null),ce=g.useRef(!0),Xe=g.useCallback(Q=>{ne(Q),window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>ne(""),2200)},[]),N=g.useCallback(Q=>{const X=yy(Q);return X.catch(()=>{}),Jt.current={file:Q,promise:X},X},[]),q=g.useCallback((Q,X,be=null)=>{if(!Q)return;if(!my.has(Q.type)){Xe("Please choose a PNG, JPEG, WebP, or PDF file.");return}if(Q.size>gy){Xe("Files must be smaller than 50 MB.");return}at.current&&URL.revokeObjectURL(at.current);const ge=X||URL.createObjectURL(Q);at.current=X?null:ge,c(Q),r(ge),h(be),w(null),I(0),ce.current=!0,$({}),v("rendered"),b(72),te({type:"ready",text:`Ready · ${Q.name}`}),N(Q)},[Xe,N]),J=g.useCallback(async(Q,X)=>{try{Bc.has(Q.filename)||te({type:"ready",text:"Loading example…"});const be=await fd(Q);q(be,Q.src,X)}catch(be){te({type:"error",text:"Example could not be loaded"}),Xe(`Example load failed: ${be.message}`)}},[q,Xe]);g.useEffect(()=>{const Q=()=>{Vc().catch(()=>{})},X=window.requestIdleCallback?window.requestIdleCallback(Q,{timeout:1200}):window.setTimeout(Q,0);return()=>{at.current&&URL.revokeObjectURL(at.current),window.clearTimeout(tt.current),window.cancelIdleCallback?window.cancelIdleCallback(X):window.clearTimeout(X)}},[]);const pe=Q=>{var be;const X=(be=Q.target.files)==null?void 0:be[0];X&&q(X),Q.target.value=""},ve=Q=>{var be;Q.preventDefault(),ke(!1);const X=(be=Q.dataTransfer.files)==null?void 0:be[0];X&&q(X)},S=async()=>{var ge;if(!u||de)return;Ge(!0),w(null),I(0),ce.current=!0,$({}),v("rendered"),te({type:"running",text:"Joining GPU queue…"});const Q=performance.now();let X=[],be=1;try{let De=Jt.current;(!De||De.file!==u)&&(De={file:u,promise:N(u)}),te({type:"running",text:"Finalizing document upload…"});let kt,Re;try{[kt,Re]=await Promise.all([De.promise,Vc()])}catch{De={file:u,promise:N(u)},[kt,Re]=await Promise.all([De.promise,Vc()])}te({type:"running",text:"Requesting ZeroGPU…"});let Ce=null,we=1,xe=0;for(;xe<we;){const fe=xe;let ct=!1;for(let st=1;st<=od;st+=1){const Ee=xe;be=Ee+1;const pt=Re.submit("/run_ocr",{image_path:kt,page_index:Ee,page_count:so});let ka=!1,Ft=!1;for await(const zt of pt){if(Ft=!0,zt.type==="status"){const lt=zt.stage||zt.status||"pending",Pe=zt.position,Ke=we>1?`pages ${be}–${Math.min(we,be+so-1)}/${we}`:`page group starting at ${be}`;if(lt==="error")throw new Error(zt.message||zt.error||`The OCR server rejected ${Ke}.`);te(lt==="pending"||lt==="queued"?{type:"running",text:Number.isFinite(Pe)?`GPU queue · ${Ke} · position ${Pe+1}`:`Waiting for GPU · ${Ke}…`}:{type:"running",text:`Parsing ${Ke} in Base mode…`})}if(zt.type==="data"){const lt=((ge=zt.data)==null?void 0:ge[0])??zt.data;if(lt&&typeof lt=="object"){we=Number(lt.total_pages||we);const Pe=vy(lt,X,Q);Ce=Pe,w(Pe),X=Pe.pages;const Ke=Number(Pe.current_page||be);be=Ke,Pe.page_preview&&($(Ca=>({...Ca,[Ke]:Pe.page_preview})),ce.current&&(r(Pe.page_preview),b(72))),ce.current&&I(Math.max(0,Ke-1));const dl=we>1?`page ${Ke}/${we}`:"page 1/1";Pe.event==="page_start"?te({type:"running",text:`Preparing ${dl}…`}):Pe.event==="stream"?te({type:"running",text:`Streaming ${dl} · ${Pe.char_count.toLocaleString()} chars`}):Pe.event==="page_complete"&&te({type:"running",text:`Page ${Ke}/${we} complete · next page stays on this GPU…`}),Pe.batch_complete&&(ka=!0)}}}const Aa=_y(X,we),hl=Math.min(we,fe+so);if(ka||Aa>=hl||Aa>=we){xe=Aa,ct=!0;break}xe=Math.max(fe,Aa),st<od&&(te({type:"running",text:Ft?`Connection ended before page ${xe+1} completed · reconnecting…`:`GPU queue returned no result for page ${xe+1} · reconnecting…`}),Re=await by(Re,Kd*st))}if(!ct)throw new Error(`Page ${xe+1} could not be completed after reconnecting to the GPU queue.`);xe<we&&te({type:"running",text:`Pages through ${xe} complete · joining the next GPU batch…`})}if(!(Ce!=null&&Ce.markdown))throw new Error("The model returned an empty result.");w(Ce),te({type:"done",text:Ce.total_pages>1?`Done · ${Ce.total_pages} pages · ${Ce.char_count.toLocaleString()} chars · ${hd(Ce.elapsed_seconds)}`:`Done · ${Ce.char_count.toLocaleString()} chars · ${hd(Ce.elapsed_seconds)}`}),Xe("OCR complete")}catch(De){console.error(De);const kt=De instanceof Error?De.message:String(De);te({type:"error",text:`OCR stopped at page ${be} · ${kt}`}),Xe(X.some(Re=>Re.status==="complete")?"OCR stopped; completed pages were kept.":"OCR failed. Check the status for details.")}finally{Ge(!1)}};g.useEffect(()=>{new URLSearchParams(window.location.search).get("preview")==="1"&&u&&!Ie.current&&(Ie.current=!0,S())},[u]);const O=async()=>{var Q;if(T!=null&&T.markdown){try{if(!((Q=navigator.clipboard)!=null&&Q.writeText))throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(T.markdown)}catch{const X=document.createElement("textarea");X.value=T.markdown,X.setAttribute("readonly",""),X.style.position="fixed",X.style.opacity="0",document.body.appendChild(X),X.select(),document.execCommand("copy"),X.remove()}Xe("Markdown copied")}},Y=async()=>{yt.current&&(document.fullscreenElement?await document.exitFullscreen():await yt.current.requestFullscreen())},G=g.useMemo(()=>de?"RUNNING":Z.type==="error"?"ERROR":Z.type==="done"?"DONE":"READY",[de,Z.type]),ee=(T==null?void 0:T.pages)||[],se=g.useMemo(()=>new Map(ee.map(Q=>[Number(Q.page_number),Q])),[ee]),me=Number((T==null?void 0:T.total_pages)||ee.length||1),Ve=se.get(H+1)||ee[ee.length-1]||null,Qe=(Ve==null?void 0:Ve.status)==="streaming",Ht=(Ve==null?void 0:Ve.markdown)||"",Ue=(Ve==null?void 0:Ve.render_markdown)||Ht,Ha=(u==null?void 0:u.type)==="application/pdf"&&s&&!s.startsWith("data:image/"),Le=Q=>{if(!se.has(Q+1))return;ce.current=!1,I(Q);const X=L[Q+1];X&&r(X)};return j.jsxs("div",{className:"app-shell",children:[j.jsxs("header",{className:"topbar",children:[j.jsxs("a",{className:"brand",href:"https://huggingface.co/ATH-MaaS/OvisOCR2",target:"_blank",rel:"noreferrer",children:[j.jsx("img",{src:ri("brand/ovis-logo.png"),alt:"Ovis"}),j.jsx("span",{className:"brand-divider","aria-hidden":"true"}),j.jsxs("span",{className:"product-name",children:["Ovis",j.jsx("span",{children:"OCR2"})]}),j.jsx("span",{className:"model-chip",children:"0.8B"})]}),j.jsxs("nav",{"aria-label":"Project links",children:[j.jsx("a",{href:"https://huggingface.co/ATH-MaaS/OvisOCR2",target:"_blank",rel:"noreferrer",children:"Model"}),j.jsx("a",{href:"https://huggingface.co/ATH-MaaS/OvisOCR2/blob/main/README.md",target:"_blank",rel:"noreferrer",children:"Technical Report"})]})]}),j.jsxs("main",{className:"main-content",children:[j.jsxs("section",{className:"intro-row","aria-labelledby":"page-title",children:[j.jsxs("div",{children:[j.jsx("p",{className:"eyebrow",children:"Document parsing"}),j.jsx("h1",{id:"page-title",children:"Turn documents into structured Markdown"})]}),j.jsxs("div",{className:"intro-actions",children:[j.jsxs("div",{className:`status-line ${Z.type}`,role:"status","aria-live":"polite",children:[j.jsx("span",{className:"status-dot"}),j.jsx("span",{children:Z.text}),j.jsx("span",{className:"status-mode",children:"Base mode · Images & PDF"})]}),j.jsxs("button",{className:"primary-button",onClick:S,disabled:!u||de,children:[de?j.jsx("span",{className:"spinner","aria-hidden":"true"}):j.jsx(Z2,{weight:"fill",size:15}),de?"Parsing…":"Run OCR"]})]})]}),j.jsxs("section",{className:"workspace","aria-label":"OCR workspace",children:[j.jsxs("div",{className:"document-panel",children:[j.jsxs("div",{className:"panel-toolbar",children:[j.jsxs("div",{className:"panel-title",children:[(u==null?void 0:u.type)==="application/pdf"?j.jsx(Bh,{size:17}):j.jsx(Zh,{size:17}),j.jsx("span",{children:(u==null?void 0:u.name)||"Document image"}),j.jsx("strong",{children:G})]}),j.jsxs("button",{className:"text-button",onClick:()=>{var Q;return(Q=ut.current)==null?void 0:Q.click()},children:[j.jsx(Vh,{size:16})," Replace"]})]}),j.jsxs("div",{ref:yt,className:`document-canvas ${Se?"dragging":""}`,onDragOver:Q=>{Q.preventDefault(),ke(!0)},onDragLeave:()=>ke(!1),onDrop:ve,children:[j.jsxs("div",{className:"zoom-toolbar","aria-label":"Preview zoom controls",children:[j.jsx("button",{"aria-label":"Zoom out",onClick:()=>b(Q=>Math.max(40,Q-8)),children:j.jsx(j2,{size:15})}),j.jsxs("span",{children:[p,"%"]}),j.jsx("button",{"aria-label":"Zoom in",onClick:()=>b(Q=>Math.min(120,Q+8)),children:j.jsx(B2,{size:15})}),j.jsx("span",{className:"toolbar-divider"}),j.jsx("button",{"aria-label":"Fullscreen preview",onClick:Y,children:j.jsx(k2,{size:16})})]}),s&&Ha?j.jsx("object",{className:"document-pdf",data:s,type:"application/pdf","aria-label":`Preview of ${(u==null?void 0:u.name)||"PDF document"}`,children:j.jsxs("div",{className:"pdf-fallback",children:[j.jsx(Bh,{size:32}),j.jsx("strong",{children:"PDF ready"}),j.jsx("span",{children:"Run OCR to preview each converted page."})]})}):s?j.jsx("img",{className:"document-image",src:s,alt:u?`Preview of ${u.name}`:"Document preview",style:{width:`${p}%`}}):j.jsxs("button",{className:"upload-empty",onClick:()=>{var Q;return(Q=ut.current)==null?void 0:Q.click()},children:[j.jsx(Vh,{size:26}),j.jsx("strong",{children:"Upload an image or PDF"}),j.jsx("span",{children:"PNG, JPEG, WebP, or PDF · up to 50 MB"})]}),Se&&j.jsx("div",{className:"drop-overlay",children:"Drop document to replace"})]})]}),j.jsxs("div",{className:"result-panel",children:[j.jsxs("div",{className:"result-toolbar",children:[j.jsxs("div",{className:"tabs",role:"tablist","aria-label":"OCR result view",children:[j.jsx("button",{role:"tab","aria-selected":m==="rendered",className:m==="rendered"?"active":"",onClick:()=>v("rendered"),children:"Rendered"}),j.jsx("button",{role:"tab","aria-selected":m==="markdown",className:m==="markdown"?"active":"",onClick:()=>v("markdown"),children:"Markdown"})]}),j.jsxs("button",{className:"copy-button",onClick:O,disabled:!(T!=null&&T.markdown),children:[j.jsx(L2,{size:16})," Copy"]})]}),me>1&&j.jsxs("div",{className:"page-strip",role:"tablist","aria-label":"PDF pages",children:[j.jsx("button",{className:"page-arrow","aria-label":"Previous page",disabled:!se.has(H),onClick:()=>Le(H-1),children:j.jsx(C2,{size:14})}),j.jsx("div",{className:"page-pills",children:Array.from({length:me},(Q,X)=>{const be=se.get(X+1);return j.jsxs("button",{role:"tab","aria-selected":H===X,className:H===X?"active":"",disabled:!be,onClick:()=>Le(X),children:[(be==null?void 0:be.status)==="complete"&&j.jsx(ao,{size:11,weight:"bold"}),"Page ",X+1]},X+1)})}),j.jsx("button",{className:"page-arrow","aria-label":"Next page",disabled:!se.has(H+2),onClick:()=>Le(H+1),children:j.jsx(U2,{size:14})})]}),j.jsxs("div",{className:"result-content",children:[de&&!Ht&&j.jsxs("div",{className:"result-state",children:[j.jsx("span",{className:"processing-mark",children:j.jsx("span",{})}),j.jsx("strong",{children:Z.text}),j.jsx("p",{children:"The first tokens will appear here as soon as ZeroGPU is ready."})]}),!de&&!T&&j.jsxs("div",{className:"result-state empty",children:[j.jsx(Zh,{size:34}),j.jsx("strong",{children:"Structured output appears here"}),j.jsx("p",{children:"Choose an example or upload an image or PDF, then run OCR."})]}),de&&Qe&&Ht&&j.jsxs("div",{className:"stream-banner",children:[j.jsx("span",{}),j.jsx("strong",{children:"Live output"}),j.jsxs("span",{children:["Page ",H+1," is still generating"]})]}),Ht&&m==="rendered"&&j.jsx(dy,{source:Ue,streaming:Qe}),Ht&&m==="markdown"&&j.jsx("pre",{className:"source-code",children:Ht})]})]})]}),j.jsxs("section",{className:"examples-section","aria-labelledby":"examples-title",children:[j.jsxs("div",{className:"examples-heading",children:[j.jsxs("div",{children:[j.jsx("p",{className:"eyebrow",children:"Evaluation samples"}),j.jsx("h2",{id:"examples-title",children:"Try an example"})]}),j.jsx("p",{children:"Tables · handwriting · formulas"})]}),j.jsx("div",{className:"example-grid",children:py.map((Q,X)=>j.jsxs("button",{className:`example-card ${f===X?"active":""}`,onClick:()=>J(Q,X),"aria-label":`Load ${Q.label}`,children:[j.jsxs("span",{className:"example-image-wrap",children:[j.jsx("img",{src:Q.src,alt:"",onError:be=>{Q.fallbackSrc&&be.currentTarget.src!==Q.fallbackSrc&&(be.currentTarget.src=Q.fallbackSrc)},onLoad:()=>{fd(Q).catch(()=>{})}}),f===X&&j.jsxs("span",{className:"selected-badge",children:[j.jsx(ao,{size:13,weight:"bold"})," Selected"]})]}),j.jsx("span",{className:"example-label",children:Q.label})]},Q.filename))})]})]}),j.jsx("input",{ref:ut,className:"file-input",type:"file",accept:"image/png,image/jpeg,image/webp,application/pdf,.pdf",onChange:pe}),j.jsx("div",{className:`toast ${oe?"show":""}`,role:"status",children:oe&&j.jsxs(j.Fragment,{children:[j.jsx(ao,{size:15,weight:"bold"})," ",oe,j.jsx("button",{onClick:()=>ne(""),"aria-label":"Dismiss",children:j.jsx(V2,{size:14})})]})})]})}fg.createRoot(document.getElementById("root")).render(j.jsx(ng.StrictMode,{children:j.jsx(Sy,{})}));
 
119
 
120
  ---
121
 
122
+ `)}function vy(u,c,s){const r=new Map(c.map(p=>[p.page_number,p]));for(const p of u.pages||[]){const b=r.get(p.page_number)||{};r.set(p.page_number,{...b,...p})}const f=Number(u.current_page||1),h=[...r.values()].map(p=>Number(p.page_number)<f&&p.status==="streaming"?{...p,status:"complete"}:p).sort((p,b)=>p.page_number-b.page_number);return{...u,pages:h,markdown:dd(h,"markdown"),render_markdown:dd(h,"render_markdown"),char_count:h.reduce((p,b)=>{var m;return p+(((m=b.markdown)==null?void 0:m.length)||0)},0),elapsed_seconds:(performance.now()-s)/1e3}}function _y(u,c){const s=new Set(u.filter(f=>f.status==="complete").map(f=>Number(f.page_number)));let r=0;for(;r<c&&s.has(r+1);)r+=1;return r}function Sy(){const[u,c]=g.useState(null),[s,r]=g.useState(null),[f,h]=g.useState(null),[p,b]=g.useState(72),[m,v]=g.useState("rendered"),[T,w]=g.useState(null),[H,I]=g.useState(0),[L,$]=g.useState({}),[Z,te]=g.useState({type:"ready",text:"Upload a document to begin"}),[de,Ge]=g.useState(!1),[Se,ke]=g.useState(!1),[oe,ne]=g.useState(""),ut=g.useRef(null),yt=g.useRef(null),at=g.useRef(null),tt=g.useRef(null),Ie=g.useRef(!1),Jt=g.useRef(null),ce=g.useRef(!0),Xe=g.useCallback(Q=>{ne(Q),window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>ne(""),2200)},[]),N=g.useCallback(Q=>{const X=yy(Q);return X.catch(()=>{}),Jt.current={file:Q,promise:X},X},[]),q=g.useCallback((Q,X,be=null)=>{if(!Q)return;if(!my.has(Q.type)){Xe("Please choose a PNG, JPEG, WebP, or PDF file.");return}if(Q.size>gy){Xe("Files must be smaller than 50 MB.");return}at.current&&URL.revokeObjectURL(at.current);const ge=X||URL.createObjectURL(Q);at.current=X?null:ge,c(Q),r(ge),h(be),w(null),I(0),ce.current=!0,$({}),v("rendered"),b(72),te({type:"ready",text:`Ready · ${Q.name}`}),N(Q)},[Xe,N]),J=g.useCallback(async(Q,X)=>{try{Bc.has(Q.filename)||te({type:"ready",text:"Loading example…"});const be=await fd(Q);q(be,Q.src,X)}catch(be){te({type:"error",text:"Example could not be loaded"}),Xe(`Example load failed: ${be.message}`)}},[q,Xe]);g.useEffect(()=>{const Q=()=>{Vc().catch(()=>{})},X=window.requestIdleCallback?window.requestIdleCallback(Q,{timeout:1200}):window.setTimeout(Q,0);return()=>{at.current&&URL.revokeObjectURL(at.current),window.clearTimeout(tt.current),window.cancelIdleCallback?window.cancelIdleCallback(X):window.clearTimeout(X)}},[]);const pe=Q=>{var be;const X=(be=Q.target.files)==null?void 0:be[0];X&&q(X),Q.target.value=""},ve=Q=>{var be;Q.preventDefault(),ke(!1);const X=(be=Q.dataTransfer.files)==null?void 0:be[0];X&&q(X)},S=async()=>{var ge;if(!u||de)return;Ge(!0),w(null),I(0),ce.current=!0,$({}),v("rendered"),te({type:"running",text:"Joining GPU queue…"});const Q=performance.now();let X=[],be=1;try{let De=Jt.current;(!De||De.file!==u)&&(De={file:u,promise:N(u)}),te({type:"running",text:"Finalizing document upload…"});let kt,Re;try{[kt,Re]=await Promise.all([De.promise,Vc()])}catch{De={file:u,promise:N(u)},[kt,Re]=await Promise.all([De.promise,Vc()])}te({type:"running",text:"Requesting ZeroGPU…"});let Ce=null,we=1,xe=0;for(;xe<we;){const fe=xe;let ct=!1;for(let st=1;st<=od;st+=1){const Ee=xe;be=Ee+1;const pt=Re.submit("/run_ocr",{image_path:kt,page_index:Ee,page_count:so});let ka=!1,Ft=!1;for await(const zt of pt){if(Ft=!0,zt.type==="status"){const lt=zt.stage||zt.status||"pending",Pe=zt.position,Ke=we>1?`pages ${be}–${Math.min(we,be+so-1)}/${we}`:`page group starting at ${be}`;if(lt==="error")throw new Error(zt.message||zt.error||`The OCR server rejected ${Ke}.`);te(lt==="pending"||lt==="queued"?{type:"running",text:Number.isFinite(Pe)?`GPU queue · ${Ke} · position ${Pe+1}`:`Waiting for GPU · ${Ke}…`}:{type:"running",text:`Parsing ${Ke} in Base mode…`})}if(zt.type==="data"){const lt=((ge=zt.data)==null?void 0:ge[0])??zt.data;if(lt&&typeof lt=="object"){we=Number(lt.total_pages||we);const Pe=vy(lt,X,Q);Ce=Pe,w(Pe),X=Pe.pages;const Ke=Number(Pe.current_page||be);be=Ke,Pe.page_preview&&($(Ca=>({...Ca,[Ke]:Pe.page_preview})),ce.current&&(r(Pe.page_preview),b(72))),ce.current&&I(Math.max(0,Ke-1));const dl=we>1?`page ${Ke}/${we}`:"page 1/1";Pe.event==="page_start"?te({type:"running",text:`Preparing ${dl}…`}):Pe.event==="stream"?te({type:"running",text:`Streaming ${dl} · ${Pe.char_count.toLocaleString()} chars`}):Pe.event==="page_complete"&&te({type:"running",text:`Page ${Ke}/${we} complete · next page stays on this GPU…`}),Pe.batch_complete&&(ka=!0)}}}const Aa=_y(X,we),hl=Math.min(we,fe+so);if(ka||Aa>=hl||Aa>=we){xe=Aa,ct=!0;break}xe=Math.max(fe,Aa),st<od&&(te({type:"running",text:Ft?`Connection ended before page ${xe+1} completed · reconnecting…`:`GPU queue returned no result for page ${xe+1} · reconnecting…`}),Re=await by(Re,Kd*st))}if(!ct)throw new Error(`Page ${xe+1} could not be completed after reconnecting to the GPU queue.`);xe<we&&te({type:"running",text:`Pages through ${xe} complete · joining the next GPU batch…`})}if(!(Ce!=null&&Ce.markdown))throw new Error("The model returned an empty result.");w(Ce),te({type:"done",text:Ce.total_pages>1?`Done · ${Ce.total_pages} pages · ${Ce.char_count.toLocaleString()} chars · ${hd(Ce.elapsed_seconds)}`:`Done · ${Ce.char_count.toLocaleString()} chars · ${hd(Ce.elapsed_seconds)}`}),Xe("OCR complete")}catch(De){console.error(De);const kt=De instanceof Error?De.message:String(De);te({type:"error",text:`OCR stopped at page ${be} · ${kt}`}),Xe(X.some(Re=>Re.status==="complete")?"OCR stopped; completed pages were kept.":"OCR failed. Check the status for details.")}finally{Ge(!1)}};g.useEffect(()=>{new URLSearchParams(window.location.search).get("preview")==="1"&&u&&!Ie.current&&(Ie.current=!0,S())},[u]);const O=async()=>{var Q;if(T!=null&&T.markdown){try{if(!((Q=navigator.clipboard)!=null&&Q.writeText))throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(T.markdown)}catch{const X=document.createElement("textarea");X.value=T.markdown,X.setAttribute("readonly",""),X.style.position="fixed",X.style.opacity="0",document.body.appendChild(X),X.select(),document.execCommand("copy"),X.remove()}Xe("Markdown copied")}},Y=async()=>{yt.current&&(document.fullscreenElement?await document.exitFullscreen():await yt.current.requestFullscreen())},G=g.useMemo(()=>de?"RUNNING":Z.type==="error"?"ERROR":Z.type==="done"?"DONE":"READY",[de,Z.type]),ee=(T==null?void 0:T.pages)||[],se=g.useMemo(()=>new Map(ee.map(Q=>[Number(Q.page_number),Q])),[ee]),me=Number((T==null?void 0:T.total_pages)||ee.length||1),Ve=se.get(H+1)||ee[ee.length-1]||null,Qe=(Ve==null?void 0:Ve.status)==="streaming",Ht=(Ve==null?void 0:Ve.markdown)||"",Ue=(Ve==null?void 0:Ve.render_markdown)||Ht,Ha=(u==null?void 0:u.type)==="application/pdf"&&s&&!s.startsWith("data:image/"),Le=Q=>{if(!se.has(Q+1))return;ce.current=!1,I(Q);const X=L[Q+1];X&&r(X)};return j.jsxs("div",{className:"app-shell",children:[j.jsxs("header",{className:"topbar",children:[j.jsxs("a",{className:"brand",href:"https://huggingface.co/ATH-MaaS/OvisOCR2",target:"_blank",rel:"noreferrer",children:[j.jsx("img",{src:ri("brand/ovis-logo.png"),alt:"Ovis"}),j.jsx("span",{className:"brand-divider","aria-hidden":"true"}),j.jsxs("span",{className:"product-name",children:["Ovis",j.jsx("span",{children:"OCR2"})]}),j.jsx("span",{className:"model-chip",children:"0.8B"})]}),j.jsxs("nav",{"aria-label":"Project links",children:[j.jsx("a",{href:"https://huggingface.co/ATH-MaaS/OvisOCR2",target:"_blank",rel:"noreferrer",children:"Model"}),j.jsx("a",{href:"https://github.com/ATH-MaaS/Ovis/blob/main/docs/OvisOCR2_Tech_Report.pdf",target:"_blank",rel:"noreferrer",children:"Technical Report"})]})]}),j.jsxs("main",{className:"main-content",children:[j.jsxs("section",{className:"intro-row","aria-labelledby":"page-title",children:[j.jsxs("div",{children:[j.jsx("p",{className:"eyebrow",children:"Document parsing"}),j.jsx("h1",{id:"page-title",children:"Turn documents into structured Markdown"})]}),j.jsxs("div",{className:"intro-actions",children:[j.jsxs("div",{className:`status-line ${Z.type}`,role:"status","aria-live":"polite",children:[j.jsx("span",{className:"status-dot"}),j.jsx("span",{children:Z.text}),j.jsx("span",{className:"status-mode",children:"Base mode · Images & PDF"})]}),j.jsxs("button",{className:"primary-button",onClick:S,disabled:!u||de,children:[de?j.jsx("span",{className:"spinner","aria-hidden":"true"}):j.jsx(Z2,{weight:"fill",size:15}),de?"Parsing…":"Run OCR"]})]})]}),j.jsxs("section",{className:"workspace","aria-label":"OCR workspace",children:[j.jsxs("div",{className:"document-panel",children:[j.jsxs("div",{className:"panel-toolbar",children:[j.jsxs("div",{className:"panel-title",children:[(u==null?void 0:u.type)==="application/pdf"?j.jsx(Bh,{size:17}):j.jsx(Zh,{size:17}),j.jsx("span",{children:(u==null?void 0:u.name)||"Document image"}),j.jsx("strong",{children:G})]}),j.jsxs("button",{className:"text-button",onClick:()=>{var Q;return(Q=ut.current)==null?void 0:Q.click()},children:[j.jsx(Vh,{size:16})," Replace"]})]}),j.jsxs("div",{ref:yt,className:`document-canvas ${Se?"dragging":""}`,onDragOver:Q=>{Q.preventDefault(),ke(!0)},onDragLeave:()=>ke(!1),onDrop:ve,children:[j.jsxs("div",{className:"zoom-toolbar","aria-label":"Preview zoom controls",children:[j.jsx("button",{"aria-label":"Zoom out",onClick:()=>b(Q=>Math.max(40,Q-8)),children:j.jsx(j2,{size:15})}),j.jsxs("span",{children:[p,"%"]}),j.jsx("button",{"aria-label":"Zoom in",onClick:()=>b(Q=>Math.min(120,Q+8)),children:j.jsx(B2,{size:15})}),j.jsx("span",{className:"toolbar-divider"}),j.jsx("button",{"aria-label":"Fullscreen preview",onClick:Y,children:j.jsx(k2,{size:16})})]}),s&&Ha?j.jsx("object",{className:"document-pdf",data:s,type:"application/pdf","aria-label":`Preview of ${(u==null?void 0:u.name)||"PDF document"}`,children:j.jsxs("div",{className:"pdf-fallback",children:[j.jsx(Bh,{size:32}),j.jsx("strong",{children:"PDF ready"}),j.jsx("span",{children:"Run OCR to preview each converted page."})]})}):s?j.jsx("img",{className:"document-image",src:s,alt:u?`Preview of ${u.name}`:"Document preview",style:{width:`${p}%`}}):j.jsxs("button",{className:"upload-empty",onClick:()=>{var Q;return(Q=ut.current)==null?void 0:Q.click()},children:[j.jsx(Vh,{size:26}),j.jsx("strong",{children:"Upload an image or PDF"}),j.jsx("span",{children:"PNG, JPEG, WebP, or PDF · up to 50 MB"})]}),Se&&j.jsx("div",{className:"drop-overlay",children:"Drop document to replace"})]})]}),j.jsxs("div",{className:"result-panel",children:[j.jsxs("div",{className:"result-toolbar",children:[j.jsxs("div",{className:"tabs",role:"tablist","aria-label":"OCR result view",children:[j.jsx("button",{role:"tab","aria-selected":m==="rendered",className:m==="rendered"?"active":"",onClick:()=>v("rendered"),children:"Rendered"}),j.jsx("button",{role:"tab","aria-selected":m==="markdown",className:m==="markdown"?"active":"",onClick:()=>v("markdown"),children:"Markdown"})]}),j.jsxs("button",{className:"copy-button",onClick:O,disabled:!(T!=null&&T.markdown),children:[j.jsx(L2,{size:16})," Copy"]})]}),me>1&&j.jsxs("div",{className:"page-strip",role:"tablist","aria-label":"PDF pages",children:[j.jsx("button",{className:"page-arrow","aria-label":"Previous page",disabled:!se.has(H),onClick:()=>Le(H-1),children:j.jsx(C2,{size:14})}),j.jsx("div",{className:"page-pills",children:Array.from({length:me},(Q,X)=>{const be=se.get(X+1);return j.jsxs("button",{role:"tab","aria-selected":H===X,className:H===X?"active":"",disabled:!be,onClick:()=>Le(X),children:[(be==null?void 0:be.status)==="complete"&&j.jsx(ao,{size:11,weight:"bold"}),"Page ",X+1]},X+1)})}),j.jsx("button",{className:"page-arrow","aria-label":"Next page",disabled:!se.has(H+2),onClick:()=>Le(H+1),children:j.jsx(U2,{size:14})})]}),j.jsxs("div",{className:"result-content",children:[de&&!Ht&&j.jsxs("div",{className:"result-state",children:[j.jsx("span",{className:"processing-mark",children:j.jsx("span",{})}),j.jsx("strong",{children:Z.text}),j.jsx("p",{children:"The first tokens will appear here as soon as ZeroGPU is ready."})]}),!de&&!T&&j.jsxs("div",{className:"result-state empty",children:[j.jsx(Zh,{size:34}),j.jsx("strong",{children:"Structured output appears here"}),j.jsx("p",{children:"Choose an example or upload an image or PDF, then run OCR."})]}),de&&Qe&&Ht&&j.jsxs("div",{className:"stream-banner",children:[j.jsx("span",{}),j.jsx("strong",{children:"Live output"}),j.jsxs("span",{children:["Page ",H+1," is still generating"]})]}),Ht&&m==="rendered"&&j.jsx(dy,{source:Ue,streaming:Qe}),Ht&&m==="markdown"&&j.jsx("pre",{className:"source-code",children:Ht})]})]})]}),j.jsxs("section",{className:"examples-section","aria-labelledby":"examples-title",children:[j.jsxs("div",{className:"examples-heading",children:[j.jsxs("div",{children:[j.jsx("p",{className:"eyebrow",children:"Evaluation samples"}),j.jsx("h2",{id:"examples-title",children:"Try an example"})]}),j.jsx("p",{children:"Tables · handwriting · formulas"})]}),j.jsx("div",{className:"example-grid",children:py.map((Q,X)=>j.jsxs("button",{className:`example-card ${f===X?"active":""}`,onClick:()=>J(Q,X),"aria-label":`Load ${Q.label}`,children:[j.jsxs("span",{className:"example-image-wrap",children:[j.jsx("img",{src:Q.src,alt:"",onError:be=>{Q.fallbackSrc&&be.currentTarget.src!==Q.fallbackSrc&&(be.currentTarget.src=Q.fallbackSrc)},onLoad:()=>{fd(Q).catch(()=>{})}}),f===X&&j.jsxs("span",{className:"selected-badge",children:[j.jsx(ao,{size:13,weight:"bold"})," Selected"]})]}),j.jsx("span",{className:"example-label",children:Q.label})]},Q.filename))})]})]}),j.jsx("input",{ref:ut,className:"file-input",type:"file",accept:"image/png,image/jpeg,image/webp,application/pdf,.pdf",onChange:pe}),j.jsx("div",{className:`toast ${oe?"show":""}`,role:"status",children:oe&&j.jsxs(j.Fragment,{children:[j.jsx(ao,{size:15,weight:"bold"})," ",oe,j.jsx("button",{onClick:()=>ne(""),"aria-label":"Dismiss",children:j.jsx(V2,{size:14})})]})})]})}fg.createRoot(document.getElementById("root")).render(j.jsx(ng.StrictMode,{children:j.jsx(Sy,{})}));
dist/index.html CHANGED
@@ -22,7 +22,7 @@
22
  };
23
  </script>
24
  <script defer src="./vendor/mathjax/tex-chtml-full.js"></script>
25
- <script type="module" crossorigin src="./assets/index-uj7s2XQX.js"></script>
26
  <link rel="stylesheet" crossorigin href="./assets/index-CQtDzYS-.css">
27
  </head>
28
  <body>
 
22
  };
23
  </script>
24
  <script defer src="./vendor/mathjax/tex-chtml-full.js"></script>
25
+ <script type="module" crossorigin src="./assets/index-tech-report-20260716.js"></script>
26
  <link rel="stylesheet" crossorigin href="./assets/index-CQtDzYS-.css">
27
  </head>
28
  <body>