import{s as Ue,n as _e,o as je}from"../chunks/scheduler.7bc62968.js";import{S as He,i as Je,g as a,s as l,r as p,A as We,h as o,f as i,c as s,j as Te,u as f,x as r,k as Ce,y as ke,a as n,v as c,d as u,t as h,w as d}from"../chunks/index.2f8492b0.js";import{C as xe}from"../chunks/CodeBlock.bb61a5a9.js";import{H as P,E as Ne}from"../chunks/index.71444864.js";function Be(pe){let m,Z,G,L,b,S,w,Q,M,V,y,fe="MobileNet can be integrated with transformer models in various ways to enhance image processing tasks.",z,$,ce="One approach is to use MobileNet as a feature extractor, where its convolutional layers process images and the resultant features are fed into a transformer model for further analysis.",R,g,ue="Another approach is training MobileNet and a Vision Transformer separately and then combining their predictions through ensemble techniques, potentially boosting performance as each model may capture distinct facets of the data. This multifaceted integration showcases the flexibility and potential of combining convolutional and transformer architectures in image processing.",Y,v,he="There is an implementation of this concept, called Mobile-Former.",X,T,A,C,de="Mobile-Former is a neural network architecture that aims to combine both MobileNet and Transformers for effective image processing tasks. It’s designed to leverage MobileNet for local feature extraction, and Transformers for context understanding.",D,x,be='<img src="https://www.researchgate.net/publication/370058769/figure/fig1/AS:11431281148324026@1681702186116/The-overall-architecture-of-Dynamic-Mobile-FormerDMF-and-details-of-DMF-block.png" alt="Mobile-Former Architecture"/>',q,U,we='You can find other detailed explanations from <a href="https://arxiv.org/abs/2108.05895" rel="nofollow">Mobile-Former’s paper</a>.',K,_,O,j,ee,H,Me="<code>timm</code> (or Py<strong>T</strong>orch <strong>Im</strong>age <strong>M</strong>odels) is a Python library that provides a collection of pre-trained deep learning models, primarily focused on computer vision tasks, along with utilities for training, fine-tuning, and inference.",te,J,ye=`Using MobileNet through the <code>timm</code> library in PyTorch is straightforward, as <code>timm</code> provides an easy way to access a wide range of pre-trained models, including various versions of MobileNet.
Here’s a basic implementation on how to use MobileNet with <code>timm</code>.`,ie,W,$e="You must install <code>timm</code> with <code>pip</code> first:",ne,k,le,N,ge="Here is the basic code:",se,B,ae,I,ve='You can go to <a href="https://huggingface.co/timm" rel="nofollow">Timm’s Hugging Face Page</a> and find other pretrained models and datasets for various tasks.',oe,F,re,E,me;return b=new P({props:{title:"Let’s Dive Further with MobileNet",local:"lets-dive-further-with-mobilenet",headingTag:"h1"}}),w=new P({props:{title:"Can We Use Vision Transformers with MobileNet?",local:"can-we-use-vision-transformers-with-mobilenet",headingTag:"h2"}}),M=new P({props:{title:"Not directly, but we can!",local:"not-directly-but-we-can",headingTag:"h3"}}),T=new P({props:{title:"Mobile-Former",local:"mobile-former",headingTag:"h3"}}),_=new P({props:{title:"MobileNet with Timm",local:"mobilenet-with-timm",headingTag:"h2"}}),j=new P({props:{title:"What is Timm?",local:"what-is-timm",headingTag:"h3"}}),k=new xe({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRpbW0=",highlighted:"pip install timm",wrap:!1}}),B=new xe({props:{code:"aW1wb3J0JTIwdGltbSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBJTIzJTIwTG9hZCUyMGElMjBwcmUtdHJhaW5lZCUyME1vYmlsZU5ldCUyMG1vZGVsJTBBbW9kZWxfbmFtZSUyMCUzRCUyMCUyMm1vYmlsZW5ldHYzX2xhcmdlXzEwMCUyMiUwQSUwQW1vZGVsJTIwJTNEJTIwdGltbS5jcmVhdGVfbW9kZWwobW9kZWxfbmFtZSUyQyUyMHByZXRyYWluZWQlM0RUcnVlKSUwQSUwQSUyMyUyMElmJTIweW91JTIwd2FudCUyMHRvJTIwdXNlJTIwdGhlJTIwbW9kZWwlMjBmb3IlMjBpbmZlcmVuY2UlMEFtb2RlbC5ldmFsKCklMEElMEElMjMlMjBGb3J3YXJkJTIwcGFzcyUyMHdpdGglMjBhJTIwZHVtbXklMjBpbnB1dCUwQSUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMkMlMjAzJTIwY29sb3IlMjBjaGFubmVscyUyQyUyMDIyNHgyMjQlMjBpbWFnZSUwQWlucHV0X3RlbnNvciUyMCUzRCUyMHRvcmNoLnJhbmQoMSUyQyUyMDMlMkMlMjAyMjQlMkMlMjAyMjQpJTBBJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwoaW5wdXRfdGVuc29yKSUwQXByaW50KG91dHB1dCk=",highlighted:`<span class="hljs-keyword">import</span> timm
<span class="hljs-keyword">import</span> torch

<span class="hljs-comment"># Load a pre-trained MobileNet model</span>
model_name = <span class="hljs-string">&quot;mobilenetv3_large_100&quot;</span>

model = timm.create_model(model_name, pretrained=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># If you want to use the model for inference</span>
model.<span class="hljs-built_in">eval</span>()

<span class="hljs-comment"># Forward pass with a dummy input</span>
<span class="hljs-comment"># Batch size 1, 3 color channels, 224x224 image</span>
input_tensor = torch.rand(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>, <span class="hljs-number">224</span>, <span class="hljs-number">224</span>)

output = model(input_tensor)
<span class="hljs-built_in">print</span>(output)`,wrap:!1}}),F=new Ne({props:{source:"https://github.com/huggingface/computer-vision-course/blob/main/chapters/en/unit2/cnns/mobilenetextra.mdx"}}),{c(){m=a("meta"),Z=l(),G=a("p"),L=l(),p(b.$$.fragment),S=l(),p(w.$$.fragment),Q=l(),p(M.$$.fragment),V=l(),y=a("p"),y.textContent=fe,z=l(),$=a("p"),$.textContent=ce,R=l(),g=a("p"),g.textContent=ue,Y=l(),v=a("p"),v.textContent=he,X=l(),p(T.$$.fragment),A=l(),C=a("p"),C.textContent=de,D=l(),x=a("p"),x.innerHTML=be,q=l(),U=a("p"),U.innerHTML=we,K=l(),p(_.$$.fragment),O=l(),p(j.$$.fragment),ee=l(),H=a("p"),H.innerHTML=Me,te=l(),J=a("p"),J.innerHTML=ye,ie=l(),W=a("p"),W.innerHTML=$e,ne=l(),p(k.$$.fragment),le=l(),N=a("p"),N.textContent=ge,se=l(),p(B.$$.fragment),ae=l(),I=a("p"),I.innerHTML=ve,oe=l(),p(F.$$.fragment),re=l(),E=a("p"),this.h()},l(e){const t=We("svelte-u9bgzb",document.head);m=o(t,"META",{name:!0,content:!0}),t.forEach(i),Z=s(e),G=o(e,"P",{}),Te(G).forEach(i),L=s(e),f(b.$$.fragment,e),S=s(e),f(w.$$.fragment,e),Q=s(e),f(M.$$.fragment,e),V=s(e),y=o(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-yybgbl"&&(y.textContent=fe),z=s(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-18s0bin"&&($.textContent=ce),R=s(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-7wmhfy"&&(g.textContent=ue),Y=s(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1puogxn"&&(v.textContent=he),X=s(e),f(T.$$.fragment,e),A=s(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-vbor24"&&(C.textContent=de),D=s(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-ywr9bo"&&(x.innerHTML=be),q=s(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1gfcy2c"&&(U.innerHTML=we),K=s(e),f(_.$$.fragment,e),O=s(e),f(j.$$.fragment,e),ee=s(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-15d2ss9"&&(H.innerHTML=Me),te=s(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-1twk0vr"&&(J.innerHTML=ye),ie=s(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1u7cyxb"&&(W.innerHTML=$e),ne=s(e),f(k.$$.fragment,e),le=s(e),N=o(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-1xhn0zu"&&(N.textContent=ge),se=s(e),f(B.$$.fragment,e),ae=s(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-zzaks2"&&(I.innerHTML=ve),oe=s(e),f(F.$$.fragment,e),re=s(e),E=o(e,"P",{}),Te(E).forEach(i),this.h()},h(){Ce(m,"name","hf:doc:metadata"),Ce(m,"content",Ie)},m(e,t){ke(document.head,m),n(e,Z,t),n(e,G,t),n(e,L,t),c(b,e,t),n(e,S,t),c(w,e,t),n(e,Q,t),c(M,e,t),n(e,V,t),n(e,y,t),n(e,z,t),n(e,$,t),n(e,R,t),n(e,g,t),n(e,Y,t),n(e,v,t),n(e,X,t),c(T,e,t),n(e,A,t),n(e,C,t),n(e,D,t),n(e,x,t),n(e,q,t),n(e,U,t),n(e,K,t),c(_,e,t),n(e,O,t),c(j,e,t),n(e,ee,t),n(e,H,t),n(e,te,t),n(e,J,t),n(e,ie,t),n(e,W,t),n(e,ne,t),c(k,e,t),n(e,le,t),n(e,N,t),n(e,se,t),c(B,e,t),n(e,ae,t),n(e,I,t),n(e,oe,t),c(F,e,t),n(e,re,t),n(e,E,t),me=!0},p:_e,i(e){me||(u(b.$$.fragment,e),u(w.$$.fragment,e),u(M.$$.fragment,e),u(T.$$.fragment,e),u(_.$$.fragment,e),u(j.$$.fragment,e),u(k.$$.fragment,e),u(B.$$.fragment,e),u(F.$$.fragment,e),me=!0)},o(e){h(b.$$.fragment,e),h(w.$$.fragment,e),h(M.$$.fragment,e),h(T.$$.fragment,e),h(_.$$.fragment,e),h(j.$$.fragment,e),h(k.$$.fragment,e),h(B.$$.fragment,e),h(F.$$.fragment,e),me=!1},d(e){e&&(i(Z),i(G),i(L),i(S),i(Q),i(V),i(y),i(z),i($),i(R),i(g),i(Y),i(v),i(X),i(A),i(C),i(D),i(x),i(q),i(U),i(K),i(O),i(ee),i(H),i(te),i(J),i(ie),i(W),i(ne),i(le),i(N),i(se),i(ae),i(I),i(oe),i(re),i(E)),i(m),d(b,e),d(w,e),d(M,e),d(T,e),d(_,e),d(j,e),d(k,e),d(B,e),d(F,e)}}}const Ie='{"title":"Let’s Dive Further with MobileNet","local":"lets-dive-further-with-mobilenet","sections":[{"title":"Can We Use Vision Transformers with MobileNet?","local":"can-we-use-vision-transformers-with-mobilenet","sections":[{"title":"Not directly, but we can!","local":"not-directly-but-we-can","sections":[],"depth":3},{"title":"Mobile-Former","local":"mobile-former","sections":[],"depth":3}],"depth":2},{"title":"MobileNet with Timm","local":"mobilenet-with-timm","sections":[{"title":"What is Timm?","local":"what-is-timm","sections":[],"depth":3}],"depth":2}],"depth":1}';function Fe(pe){return je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends He{constructor(m){super(),Je(this,m,Fe,Be,Ue,{})}}export{Le as component};
