import{s as Se,A as Qe,o as Ye,n as je}from"../chunks/scheduler.01eeda35.js";import{S as Oe,i as qe,g as n,s as i,r as f,A as Ve,h as o,f as a,c as s,j as He,u,x as m,k as O,y as _e,a as l,v as c,d,t as g,w as h}from"../chunks/index.6dd51b66.js";import{T as Ke}from"../chunks/Tip.de9bae2b.js";import{C as Ae}from"../chunks/CodeBlock.864da1b0.js";import{P as ze}from"../chunks/PipelineTag.5efc345e.js";import{H as we,E as Xe}from"../chunks/EditOnGithub.7faefd25.js";function Be(V){let r,y='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.';return{c(){r=n("p"),r.innerHTML=y},l(p){r=o(p,"P",{"data-svelte-h":!0}),m(r)!=="svelte-1m8yg77"&&(r.innerHTML=y)},m(p,j){l(p,r,j)},p:je,d(p){p&&a(r)}}}function Fe(V){let r,y,p,j,w,_,b,Ce=`<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/> <img alt="Flax" src="https://img.shields.io/badge/Flax-29a79b.svg?style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAMAAAANxBKoAAAC7lBMVEUAAADg5vYHPVgAoJH+/v76+v39/f9JbLP///9+AIgAnY3///+mcqzt8fXy9fgkXa3Ax9709fr+///9/f8qXq49qp5AaLGMwrv8/P0eW60VWawxYq8yqJzG2dytt9Wyu9elzci519Lf3O3S2efY3OrY0+Xp7PT///////+dqNCexMc6Z7AGpJeGvbenstPZ5ejQ1OfJzOLa7ejh4+/r8fT29vpccbklWK8PVa0AS6ghW63O498vYa+lsdKz1NDRt9Kw1c672tbD3tnAxt7R6OHp5vDe7OrDyuDn6vLl6/EAQKak0MgATakkppo3ZK/Bz9y8w9yzu9jey97axdvHzeG21NHH4trTwthKZrVGZLSUSpuPQJiGAI+GAI8SWKydycLL4d7f2OTi1+S9xNzL0ePT6OLGzeEAo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fLyW8iW4kdka+nEMjxpL2NCwsYNBp+Q61PF43zyDg9Bm9+3NNySn78jMZUUkumqE4Gp7JmFOdP1vc8PpRrzj9+wPinCy8K1PiJ4aYbnTYpCCbDkBSbzhu2QJ1Gd82t8jI8TH51+OzvXoWbnXUOBkNW+0mWFwGcGOUVpU81/n3TOHb5oMt2FgYGjzau0Nif0Ss7Q3XB33hjjQHjHA5E5aOyIQc8CBrLdQSs3j92VG+3nNEjbkbdbBr9zm04ruvw37vh0QKOdeGIkckc80fX3KH/h7PT4BOjgCty8VZ5ux1MoO5Cf5naca2LAsEgehI+drX8o/0Nu+W0m6K/I9gGPd/dfx/EN/wN62AhsBWuAAAAAElFTkSuQmCC
"/>`,K,A,z,C,xe=`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:`,X,x,Me=`<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>`,B,M,$e="The abstract from the paper is the following:",F,$,Le="<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>",ee,v,Ze,te,L,ke="Summary of the approach. Taken from the [original paper](https://arxiv.org/abs/2203.02378).",ae,Z,Je='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>.',le,k,ie,J,Pe="One can directly use the weights of DiT with the AutoModel API:",se,P,ne,G,Ge="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.",oe,E,Ee="To include the head, you can load the weights into a <code>BeitForMaskedImageModeling</code> model, like so:",re,I,me,U,Ie='You can also load a fine-tuned model from the <a href="https://huggingface.co/models?other=dit" rel="nofollow">hub</a>, like so:',pe,W,fe,N,Ue=`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>.`,ue,R,ce,D,We="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with DiT.",de,H,ge,S,Ne='<li><a href="/docs/transformers/main/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>',he,Q,Re="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.",be,T,ve,Y,Te,q,ye;return w=new we({props:{title:"DiT",local:"dit",headingTag:"h1"}}),A=new we({props:{title:"Overview",local:"overview",headingTag:"h2"}}),k=new we({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),P=new Ae({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}}),I=new Ae({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}}),W=new Ae({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}}),R=new we({props:{title:"Resources",local:"resources",headingTag:"h2"}}),H=new ze({props:{pipeline:"image-classification"}}),T=new Ke({props:{$$slots:{default:[Be]},$$scope:{ctx:V}}}),Y=new Xe({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/dit.md"}}),{c(){r=n("meta"),y=i(),p=n("p"),j=i(),f(w.$$.fragment),_=i(),b=n("div"),b.innerHTML=Ce,K=i(),f(A.$$.fragment),z=i(),C=n("p"),C.innerHTML=xe,X=i(),x=n("ul"),x.innerHTML=Me,B=i(),M=n("p"),M.textContent=$e,F=i(),$=n("p"),$.innerHTML=Le,ee=i(),v=n("img"),te=i(),L=n("small"),L.textContent=ke,ae=i(),Z=n("p"),Z.innerHTML=Je,le=i(),f(k.$$.fragment),ie=i(),J=n("p"),J.textContent=Pe,se=i(),f(P.$$.fragment),ne=i(),G=n("p"),G.textContent=Ge,oe=i(),E=n("p"),E.innerHTML=Ee,re=i(),f(I.$$.fragment),me=i(),U=n("p"),U.innerHTML=Ie,pe=i(),f(W.$$.fragment),fe=i(),N=n("p"),N.innerHTML=Ue,ue=i(),f(R.$$.fragment),ce=i(),D=n("p"),D.textContent=We,de=i(),f(H.$$.fragment),ge=i(),S=n("ul"),S.innerHTML=Ne,he=i(),Q=n("p"),Q.textContent=Re,be=i(),f(T.$$.fragment),ve=i(),f(Y.$$.fragment),Te=i(),q=n("p"),this.h()},l(e){const t=Ve("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(a),y=s(e),p=o(e,"P",{}),He(p).forEach(a),j=s(e),u(w.$$.fragment,e),_=s(e),b=o(e,"DIV",{class:!0,"data-svelte-h":!0}),m(b)!=="svelte-1l5icot"&&(b.innerHTML=Ce),K=s(e),u(A.$$.fragment,e),z=s(e),C=o(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-1gbdpy8"&&(C.innerHTML=xe),X=s(e),x=o(e,"UL",{"data-svelte-h":!0}),m(x)!=="svelte-1f9lxhv"&&(x.innerHTML=Me),B=s(e),M=o(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-vfdo9a"&&(M.textContent=$e),F=s(e),$=o(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-s1efxi"&&($.innerHTML=Le),ee=s(e),v=o(e,"IMG",{src:!0,alt:!0,width:!0}),te=s(e),L=o(e,"SMALL",{"data-svelte-h":!0}),m(L)!=="svelte-1lej16g"&&(L.textContent=ke),ae=s(e),Z=o(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-1c0fpli"&&(Z.innerHTML=Je),le=s(e),u(k.$$.fragment,e),ie=s(e),J=o(e,"P",{"data-svelte-h":!0}),m(J)!=="svelte-vgbz98"&&(J.textContent=Pe),se=s(e),u(P.$$.fragment,e),ne=s(e),G=o(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-bff7eu"&&(G.textContent=Ge),oe=s(e),E=o(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-167pfvb"&&(E.innerHTML=Ee),re=s(e),u(I.$$.fragment,e),me=s(e),U=o(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-imixxa"&&(U.innerHTML=Ie),pe=s(e),u(W.$$.fragment,e),fe=s(e),N=o(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-1ixff4z"&&(N.innerHTML=Ue),ue=s(e),u(R.$$.fragment,e),ce=s(e),D=o(e,"P",{"data-svelte-h":!0}),m(D)!=="svelte-1w25qz0"&&(D.textContent=We),de=s(e),u(H.$$.fragment,e),ge=s(e),S=o(e,"UL",{"data-svelte-h":!0}),m(S)!=="svelte-mtcufn"&&(S.innerHTML=Ne),he=s(e),Q=o(e,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-1xesile"&&(Q.textContent=Re),be=s(e),u(T.$$.fragment,e),ve=s(e),u(Y.$$.fragment,e),Te=s(e),q=o(e,"P",{}),He(q).forEach(a),this.h()},h(){O(r,"name","hf:doc:metadata"),O(r,"content",et),O(b,"class","flex flex-wrap space-x-1"),Qe(v.src,Ze="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dit_architecture.jpg")||O(v,"src",Ze),O(v,"alt","drawing"),O(v,"width","600")},m(e,t){_e(document.head,r),l(e,y,t),l(e,p,t),l(e,j,t),c(w,e,t),l(e,_,t),l(e,b,t),l(e,K,t),c(A,e,t),l(e,z,t),l(e,C,t),l(e,X,t),l(e,x,t),l(e,B,t),l(e,M,t),l(e,F,t),l(e,$,t),l(e,ee,t),l(e,v,t),l(e,te,t),l(e,L,t),l(e,ae,t),l(e,Z,t),l(e,le,t),c(k,e,t),l(e,ie,t),l(e,J,t),l(e,se,t),c(P,e,t),l(e,ne,t),l(e,G,t),l(e,oe,t),l(e,E,t),l(e,re,t),c(I,e,t),l(e,me,t),l(e,U,t),l(e,pe,t),c(W,e,t),l(e,fe,t),l(e,N,t),l(e,ue,t),c(R,e,t),l(e,ce,t),l(e,D,t),l(e,de,t),c(H,e,t),l(e,ge,t),l(e,S,t),l(e,he,t),l(e,Q,t),l(e,be,t),c(T,e,t),l(e,ve,t),c(Y,e,t),l(e,Te,t),l(e,q,t),ye=!0},p(e,[t]){const De={};t&2&&(De.$$scope={dirty:t,ctx:e}),T.$set(De)},i(e){ye||(d(w.$$.fragment,e),d(A.$$.fragment,e),d(k.$$.fragment,e),d(P.$$.fragment,e),d(I.$$.fragment,e),d(W.$$.fragment,e),d(R.$$.fragment,e),d(H.$$.fragment,e),d(T.$$.fragment,e),d(Y.$$.fragment,e),ye=!0)},o(e){g(w.$$.fragment,e),g(A.$$.fragment,e),g(k.$$.fragment,e),g(P.$$.fragment,e),g(I.$$.fragment,e),g(W.$$.fragment,e),g(R.$$.fragment,e),g(H.$$.fragment,e),g(T.$$.fragment,e),g(Y.$$.fragment,e),ye=!1},d(e){e&&(a(y),a(p),a(j),a(_),a(b),a(K),a(z),a(C),a(X),a(x),a(B),a(M),a(F),a($),a(ee),a(v),a(te),a(L),a(ae),a(Z),a(le),a(ie),a(J),a(se),a(ne),a(G),a(oe),a(E),a(re),a(me),a(U),a(pe),a(fe),a(N),a(ue),a(ce),a(D),a(de),a(ge),a(S),a(he),a(Q),a(be),a(ve),a(Te),a(q)),a(r),h(w,e),h(A,e),h(k,e),h(P,e),h(I,e),h(W,e),h(R,e),h(H,e),h(T,e),h(Y,e)}}}const et='{"title":"DiT","local":"dit","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}';function tt(V){return Ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rt extends Oe{constructor(r){super(),qe(this,r,tt,Fe,Se,{})}}export{rt as component};
