import{s as rt,f as mt,n as ft,o as pt}from"../chunks/scheduler.9bc65507.js";import{S as ct,i as ut,g as i,s as n,u as S,A as ht,h as s,f as t,c as o,j as p,v as G,y as r,k as m,o as f,a as l,w as B,d as F,t as V,x as Y}from"../chunks/index.78c82d43.js";import{I as Ae}from"../chunks/IconCopyLink.bedaa44d.js";import{C as He}from"../chunks/CodeBlock.73e038be.js";import{P as dt}from"../chunks/PipelineTag.75b0f707.js";function vt(We){let c,ae,Q,le,u,v,O,y,Ee,q,De="DiT",ie,h,g,K,T,Ie,z,Je="Overview",se,C,Ne=`DiT was proposed in <a href="https://arxiv.org/abs/2203.02378" rel="nofollow">DiT: Self-supervised Pre-training for Document Image Transformer</a> by Junlong Li, Yiheng Xu, Tengchao Lv, Lei Cui, Cha Zhang, Furu Wei.
DiT applies the self-supervised objective of <a href="beit">BEiT</a> (BERT pre-training of Image Transformers) to 42 million document images, allowing for state-of-the-art results on tasks including:`,ne,_,je=`<li>document image classification: the <a href="https://www.cs.cmu.edu/~aharley/rvl-cdip/" rel="nofollow">RVL-CDIP</a> dataset (a collection of
400,000 images belonging to one of 16 classes).</li> <li>document layout analysis: the <a href="https://github.com/ibm-aur-nlp/PubLayNet" rel="nofollow">PubLayNet</a> dataset (a collection of more
than 360,000 document images constructed by automatically parsing PubMed XML files).</li> <li>table detection: the <a href="https://github.com/cndplab-founder/ICDAR2019_cTDaR" rel="nofollow">ICDAR 2019 cTDaR</a> dataset (a collection of
600 training images and 240 testing images).</li>`,oe,x,Ue="The abstract from the paper is the following:",re,$,Se="<em>Image Transformer has recently achieved significant progress for natural image understanding, either using supervised (ViT, DeiT, etc.) or self-supervised (BEiT, MAE, etc.) pre-training techniques. In this paper, we propose DiT, a self-supervised pre-trained Document Image Transformer model using large-scale unlabeled text images for Document AI tasks, which is essential since no supervised counterparts ever exist due to the lack of human labeled document images. We leverage DiT as the backbone network in a variety of vision-based Document AI tasks, including document image classification, document layout analysis, as well as table detection. Experiment results have illustrated that the self-supervised pre-trained DiT model achieves new state-of-the-art results on these downstream tasks, e.g. document image classification (91.11 → 92.69), document layout analysis (91.0 → 94.9) and table detection (94.23 → 96.55).</em>",me,b,Ge,fe,M,Be="Summary of the approach. Taken from the [original paper](https://arxiv.org/abs/2203.02378).",pe,k,Fe="One can directly use the weights of DiT with the AutoModel API:",ce,L,ue,P,Ve="This will load the model pre-trained on masked image modeling. Note that this won’t include the language modeling head on top, used to predict visual tokens.",he,Z,Ye="To include the head, you can load the weights into a <code>BeitForMaskedImageModeling</code> model, like so:",de,E,ve,I,qe='You can also load a fine-tuned model from the <a href="https://huggingface.co/models?other=dit" rel="nofollow">hub</a>, like so:',ge,R,be,A,ze=`This particular checkpoint was fine-tuned on <a href="https://www.cs.cmu.edu/~aharley/rvl-cdip/" rel="nofollow">RVL-CDIP</a>, an important benchmark for document image classification.
A notebook that illustrates inference for document image classification can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/DiT/Inference_with_DiT_(Document_Image_Transformer)_for_document_image_classification.ipynb" rel="nofollow">here</a>.`,we,H,Xe='As DiT’s architecture is equivalent to that of BEiT, one can refer to <a href="beit">BEiT’s documentation page</a> for all tips, code examples and notebooks.',ye,W,Qe='This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>. The original code can be found <a href="https://github.com/microsoft/unilm/tree/master/dit" rel="nofollow">here</a>.',Te,d,w,ee,D,Re,X,Oe="Resources",Ce,J,Ke="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with DiT.",_e,N,xe,j,et='<li><a href="/docs/transformers/v4.34.0/en/model_doc/beit#transformers.BeitForImageClassification">BeitForImageClassification</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification" rel="nofollow">example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb" rel="nofollow">notebook</a>.</li>',$e,U,tt="If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",Me,te,ke;return y=new Ae({}),T=new Ae({}),L=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZkaXQtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

model = AutoModel.from_pretrained(<span class="hljs-string">&quot;microsoft/dit-base&quot;</span>)`,wrap:!1}}),E=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlaXRGb3JNYXNrZWRJbWFnZU1vZGVsaW5nJTBBJTBBbW9kZWwlMjAlM0QlMjBCZWl0Rm9yTWFza2VkSW1hZ2VNb2RlbGluZy5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGZGl0LWJhc2UlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BeitForMaskedImageModeling

model = BeitForMaskedImageModeling.from_pretrained(<span class="hljs-string">&quot;microsoft/dit-base&quot;</span>)`,wrap:!1}}),R=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmRpdC1iYXNlLWZpbmV0dW5lZC1ydmxjZGlwJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageClassification

model = AutoModelForImageClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/dit-base-finetuned-rvlcdip&quot;</span>)`,wrap:!1}}),D=new Ae({}),N=new dt({props:{pipeline:"image-classification"}}),{c(){c=i("meta"),ae=n(),Q=i("p"),le=n(),u=i("h1"),v=i("a"),O=i("span"),S(y.$$.fragment),Ee=n(),q=i("span"),q.textContent=De,ie=n(),h=i("h2"),g=i("a"),K=i("span"),S(T.$$.fragment),Ie=n(),z=i("span"),z.textContent=Je,se=n(),C=i("p"),C.innerHTML=Ne,ne=n(),_=i("ul"),_.innerHTML=je,oe=n(),x=i("p"),x.textContent=Ue,re=n(),$=i("p"),$.innerHTML=Se,me=n(),b=i("img"),fe=n(),M=i("small"),M.textContent=Be,pe=n(),k=i("p"),k.textContent=Fe,ce=n(),S(L.$$.fragment),ue=n(),P=i("p"),P.textContent=Ve,he=n(),Z=i("p"),Z.innerHTML=Ye,de=n(),S(E.$$.fragment),ve=n(),I=i("p"),I.innerHTML=qe,ge=n(),S(R.$$.fragment),be=n(),A=i("p"),A.innerHTML=ze,we=n(),H=i("p"),H.innerHTML=Xe,ye=n(),W=i("p"),W.innerHTML=Qe,Te=n(),d=i("h2"),w=i("a"),ee=i("span"),S(D.$$.fragment),Re=n(),X=i("span"),X.textContent=Oe,Ce=n(),J=i("p"),J.textContent=Ke,_e=n(),S(N.$$.fragment),xe=n(),j=i("ul"),j.innerHTML=et,$e=n(),U=i("p"),U.textContent=tt,Me=n(),te=i("p"),this.h()},l(e){const a=ht("svelte-1phssyn",document.head);c=s(a,"META",{name:!0,content:!0}),a.forEach(t),ae=o(e),Q=s(e,"P",{}),p(Q).forEach(t),le=o(e),u=s(e,"H1",{class:!0});var Le=p(u);v=s(Le,"A",{id:!0,class:!0,href:!0});var at=p(v);O=s(at,"SPAN",{});var lt=p(O);G(y.$$.fragment,lt),lt.forEach(t),at.forEach(t),Ee=o(Le),q=s(Le,"SPAN",{"data-svelte-h":!0}),r(q)!=="svelte-152lf9a"&&(q.textContent=De),Le.forEach(t),ie=o(e),h=s(e,"H2",{class:!0});var Pe=p(h);g=s(Pe,"A",{id:!0,class:!0,href:!0});var it=p(g);K=s(it,"SPAN",{});var st=p(K);G(T.$$.fragment,st),st.forEach(t),it.forEach(t),Ie=o(Pe),z=s(Pe,"SPAN",{"data-svelte-h":!0}),r(z)!=="svelte-1jsw1pg"&&(z.textContent=Je),Pe.forEach(t),se=o(e),C=s(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1gbdpy8"&&(C.innerHTML=Ne),ne=o(e),_=s(e,"UL",{"data-svelte-h":!0}),r(_)!=="svelte-1f9lxhv"&&(_.innerHTML=je),oe=o(e),x=s(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-vfdo9a"&&(x.textContent=Ue),re=o(e),$=s(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-s1efxi"&&($.innerHTML=Se),me=o(e),b=s(e,"IMG",{src:!0,alt:!0,width:!0}),fe=o(e),M=s(e,"SMALL",{"data-svelte-h":!0}),r(M)!=="svelte-1lej16g"&&(M.textContent=Be),pe=o(e),k=s(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-vgbz98"&&(k.textContent=Fe),ce=o(e),G(L.$$.fragment,e),ue=o(e),P=s(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-bff7eu"&&(P.textContent=Ve),he=o(e),Z=s(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-167pfvb"&&(Z.innerHTML=Ye),de=o(e),G(E.$$.fragment,e),ve=o(e),I=s(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-imixxa"&&(I.innerHTML=qe),ge=o(e),G(R.$$.fragment,e),be=o(e),A=s(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1ixff4z"&&(A.innerHTML=ze),we=o(e),H=s(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1qancw3"&&(H.innerHTML=Xe),ye=o(e),W=s(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1c0fpli"&&(W.innerHTML=Qe),Te=o(e),d=s(e,"H2",{class:!0});var Ze=p(d);w=s(Ze,"A",{id:!0,class:!0,href:!0});var nt=p(w);ee=s(nt,"SPAN",{});var ot=p(ee);G(D.$$.fragment,ot),ot.forEach(t),nt.forEach(t),Re=o(Ze),X=s(Ze,"SPAN",{"data-svelte-h":!0}),r(X)!=="svelte-w4zzv6"&&(X.textContent=Oe),Ze.forEach(t),Ce=o(e),J=s(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-1w25qz0"&&(J.textContent=Ke),_e=o(e),G(N.$$.fragment,e),xe=o(e),j=s(e,"UL",{"data-svelte-h":!0}),r(j)!=="svelte-1aadkhz"&&(j.innerHTML=et),$e=o(e),U=s(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1xesile"&&(U.textContent=tt),Me=o(e),te=s(e,"P",{}),p(te).forEach(t),this.h()},h(){m(c,"name","hf:doc:metadata"),m(c,"content",JSON.stringify(gt)),m(v,"id","dit"),m(v,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(v,"href","#dit"),m(u,"class","relative group"),m(g,"id","overview"),m(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(g,"href","#overview"),m(h,"class","relative group"),mt(b.src,Ge="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dit_architecture.jpg")||m(b,"src",Ge),m(b,"alt","drawing"),m(b,"width","600"),m(w,"id","resources"),m(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(w,"href","#resources"),m(d,"class","relative group")},m(e,a){f(document.head,c),l(e,ae,a),l(e,Q,a),l(e,le,a),l(e,u,a),f(u,v),f(v,O),B(y,O,null),f(u,Ee),f(u,q),l(e,ie,a),l(e,h,a),f(h,g),f(g,K),B(T,K,null),f(h,Ie),f(h,z),l(e,se,a),l(e,C,a),l(e,ne,a),l(e,_,a),l(e,oe,a),l(e,x,a),l(e,re,a),l(e,$,a),l(e,me,a),l(e,b,a),l(e,fe,a),l(e,M,a),l(e,pe,a),l(e,k,a),l(e,ce,a),B(L,e,a),l(e,ue,a),l(e,P,a),l(e,he,a),l(e,Z,a),l(e,de,a),B(E,e,a),l(e,ve,a),l(e,I,a),l(e,ge,a),B(R,e,a),l(e,be,a),l(e,A,a),l(e,we,a),l(e,H,a),l(e,ye,a),l(e,W,a),l(e,Te,a),l(e,d,a),f(d,w),f(w,ee),B(D,ee,null),f(d,Re),f(d,X),l(e,Ce,a),l(e,J,a),l(e,_e,a),B(N,e,a),l(e,xe,a),l(e,j,a),l(e,$e,a),l(e,U,a),l(e,Me,a),l(e,te,a),ke=!0},p:ft,i(e){ke||(F(y.$$.fragment,e),F(T.$$.fragment,e),F(L.$$.fragment,e),F(E.$$.fragment,e),F(R.$$.fragment,e),F(D.$$.fragment,e),F(N.$$.fragment,e),ke=!0)},o(e){V(y.$$.fragment,e),V(T.$$.fragment,e),V(L.$$.fragment,e),V(E.$$.fragment,e),V(R.$$.fragment,e),V(D.$$.fragment,e),V(N.$$.fragment,e),ke=!1},d(e){e&&(t(ae),t(Q),t(le),t(u),t(ie),t(h),t(se),t(C),t(ne),t(_),t(oe),t(x),t(re),t($),t(me),t(b),t(fe),t(M),t(pe),t(k),t(ce),t(ue),t(P),t(he),t(Z),t(de),t(ve),t(I),t(ge),t(be),t(A),t(we),t(H),t(ye),t(W),t(Te),t(d),t(Ce),t(J),t(_e),t(xe),t(j),t($e),t(U),t(Me),t(te)),t(c),Y(y),Y(T),Y(L,e),Y(E,e),Y(R,e),Y(D),Y(N,e)}}}const gt={local:"dit",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"}],title:"DiT"};function bt(We){return pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xt extends ct{constructor(c){super(),ut(this,c,bt,vt,rt,{})}}export{xt as component};
