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