import{s as Ue,f as Je,o as je,n as Ee}from"../chunks/scheduler.9bc65507.js";import{S as Ae,i as Ge,g as n,s as a,r as p,A as Be,h as o,f as i,c as s,j as De,u,x as m,k as N,y as Fe,a as l,v as c,d,t as h,w as g}from"../chunks/index.707bf1b6.js";import{T as Ne}from"../chunks/Tip.c2ecdbf4.js";import{C as ve}from"../chunks/CodeBlock.54a9f38d.js";import{P as Ve}from"../chunks/PipelineTag.44585822.js";import{H as be}from"../chunks/Heading.342b1fa6.js";function Ye(V){let r,$='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=$},l(f){r=o(f,"P",{"data-svelte-h":!0}),m(r)!=="svelte-1m8yg77"&&(r.innerHTML=$)},m(f,B){l(f,r,B)},p:Ee,d(f){f&&i(r)}}}function qe(V){let r,$,f,B,y,Y,w,q,T,$e=`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:`,S,M,ye=`<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>`,z,C,we="The abstract from the paper is the following:",X,_,Te="<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>",Q,b,Me,O,x,Ce="Summary of the approach. Taken from the [original paper](https://arxiv.org/abs/2203.02378).",K,k,_e='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>.',ee,L,te,Z,xe="One can directly use the weights of DiT with the AutoModel API:",ie,R,le,I,ke="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.",ae,P,Le="To include the head, you can load the weights into a <code>BeitForMaskedImageModeling</code> model, like so:",se,W,ne,H,Ze='You can also load a fine-tuned model from the <a href="https://huggingface.co/models?other=dit" rel="nofollow">hub</a>, like so:',oe,D,re,U,Re=`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>.`,me,J,fe,j,Ie="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with DiT.",pe,E,ue,A,Pe='<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>',ce,G,We="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.",de,v,he,F,ge;return y=new be({props:{title:"DiT",local:"dit",headingTag:"h1"}}),w=new be({props:{title:"Overview",local:"overview",headingTag:"h2"}}),L=new be({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),R=new ve({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}}),W=new ve({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}}),D=new ve({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}}),J=new be({props:{title:"Resources",local:"resources",headingTag:"h2"}}),E=new Ve({props:{pipeline:"image-classification"}}),v=new Ne({props:{$$slots:{default:[Ye]},$$scope:{ctx:V}}}),{c(){r=n("meta"),$=a(),f=n("p"),B=a(),p(y.$$.fragment),Y=a(),p(w.$$.fragment),q=a(),T=n("p"),T.innerHTML=$e,S=a(),M=n("ul"),M.innerHTML=ye,z=a(),C=n("p"),C.textContent=we,X=a(),_=n("p"),_.innerHTML=Te,Q=a(),b=n("img"),O=a(),x=n("small"),x.textContent=Ce,K=a(),k=n("p"),k.innerHTML=_e,ee=a(),p(L.$$.fragment),te=a(),Z=n("p"),Z.textContent=xe,ie=a(),p(R.$$.fragment),le=a(),I=n("p"),I.textContent=ke,ae=a(),P=n("p"),P.innerHTML=Le,se=a(),p(W.$$.fragment),ne=a(),H=n("p"),H.innerHTML=Ze,oe=a(),p(D.$$.fragment),re=a(),U=n("p"),U.innerHTML=Re,me=a(),p(J.$$.fragment),fe=a(),j=n("p"),j.textContent=Ie,pe=a(),p(E.$$.fragment),ue=a(),A=n("ul"),A.innerHTML=Pe,ce=a(),G=n("p"),G.textContent=We,de=a(),p(v.$$.fragment),he=a(),F=n("p"),this.h()},l(e){const t=Be("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(i),$=s(e),f=o(e,"P",{}),De(f).forEach(i),B=s(e),u(y.$$.fragment,e),Y=s(e),u(w.$$.fragment,e),q=s(e),T=o(e,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1gbdpy8"&&(T.innerHTML=$e),S=s(e),M=o(e,"UL",{"data-svelte-h":!0}),m(M)!=="svelte-1f9lxhv"&&(M.innerHTML=ye),z=s(e),C=o(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-vfdo9a"&&(C.textContent=we),X=s(e),_=o(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-s1efxi"&&(_.innerHTML=Te),Q=s(e),b=o(e,"IMG",{src:!0,alt:!0,width:!0}),O=s(e),x=o(e,"SMALL",{"data-svelte-h":!0}),m(x)!=="svelte-1lej16g"&&(x.textContent=Ce),K=s(e),k=o(e,"P",{"data-svelte-h":!0}),m(k)!=="svelte-1c0fpli"&&(k.innerHTML=_e),ee=s(e),u(L.$$.fragment,e),te=s(e),Z=o(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-vgbz98"&&(Z.textContent=xe),ie=s(e),u(R.$$.fragment,e),le=s(e),I=o(e,"P",{"data-svelte-h":!0}),m(I)!=="svelte-bff7eu"&&(I.textContent=ke),ae=s(e),P=o(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-167pfvb"&&(P.innerHTML=Le),se=s(e),u(W.$$.fragment,e),ne=s(e),H=o(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-imixxa"&&(H.innerHTML=Ze),oe=s(e),u(D.$$.fragment,e),re=s(e),U=o(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-1ixff4z"&&(U.innerHTML=Re),me=s(e),u(J.$$.fragment,e),fe=s(e),j=o(e,"P",{"data-svelte-h":!0}),m(j)!=="svelte-1w25qz0"&&(j.textContent=Ie),pe=s(e),u(E.$$.fragment,e),ue=s(e),A=o(e,"UL",{"data-svelte-h":!0}),m(A)!=="svelte-mtcufn"&&(A.innerHTML=Pe),ce=s(e),G=o(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-1xesile"&&(G.textContent=We),de=s(e),u(v.$$.fragment,e),he=s(e),F=o(e,"P",{}),De(F).forEach(i),this.h()},h(){N(r,"name","hf:doc:metadata"),N(r,"content",Se),Je(b.src,Me="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dit_architecture.jpg")||N(b,"src",Me),N(b,"alt","drawing"),N(b,"width","600")},m(e,t){Fe(document.head,r),l(e,$,t),l(e,f,t),l(e,B,t),c(y,e,t),l(e,Y,t),c(w,e,t),l(e,q,t),l(e,T,t),l(e,S,t),l(e,M,t),l(e,z,t),l(e,C,t),l(e,X,t),l(e,_,t),l(e,Q,t),l(e,b,t),l(e,O,t),l(e,x,t),l(e,K,t),l(e,k,t),l(e,ee,t),c(L,e,t),l(e,te,t),l(e,Z,t),l(e,ie,t),c(R,e,t),l(e,le,t),l(e,I,t),l(e,ae,t),l(e,P,t),l(e,se,t),c(W,e,t),l(e,ne,t),l(e,H,t),l(e,oe,t),c(D,e,t),l(e,re,t),l(e,U,t),l(e,me,t),c(J,e,t),l(e,fe,t),l(e,j,t),l(e,pe,t),c(E,e,t),l(e,ue,t),l(e,A,t),l(e,ce,t),l(e,G,t),l(e,de,t),c(v,e,t),l(e,he,t),l(e,F,t),ge=!0},p(e,[t]){const He={};t&2&&(He.$$scope={dirty:t,ctx:e}),v.$set(He)},i(e){ge||(d(y.$$.fragment,e),d(w.$$.fragment,e),d(L.$$.fragment,e),d(R.$$.fragment,e),d(W.$$.fragment,e),d(D.$$.fragment,e),d(J.$$.fragment,e),d(E.$$.fragment,e),d(v.$$.fragment,e),ge=!0)},o(e){h(y.$$.fragment,e),h(w.$$.fragment,e),h(L.$$.fragment,e),h(R.$$.fragment,e),h(W.$$.fragment,e),h(D.$$.fragment,e),h(J.$$.fragment,e),h(E.$$.fragment,e),h(v.$$.fragment,e),ge=!1},d(e){e&&(i($),i(f),i(B),i(Y),i(q),i(T),i(S),i(M),i(z),i(C),i(X),i(_),i(Q),i(b),i(O),i(x),i(K),i(k),i(ee),i(te),i(Z),i(ie),i(le),i(I),i(ae),i(P),i(se),i(ne),i(H),i(oe),i(re),i(U),i(me),i(fe),i(j),i(pe),i(ue),i(A),i(ce),i(G),i(de),i(he),i(F)),i(r),g(y,e),g(w,e),g(L,e),g(R,e),g(W,e),g(D,e),g(J,e),g(E,e),g(v,e)}}}const Se='{"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 ze(V){return je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class it extends Ae{constructor(r){super(),Ge(this,r,ze,qe,Ue,{})}}export{it as component};
