import{s as je,n as He,o as Je}from"../chunks/scheduler.35aab934.js";import{S as We,i as ke,e as a,s as l,c as m,h as Ne,a as o,d as i,b as s,f as Ce,g as p,j as r,k as Ue,l as Be,m as n,n as f,t as c,o as u,p as h}from"../chunks/index.de17b971.js";import{C as Ie}from"../chunks/CopyLLMTxtMenu.48bc5cc2.js";import{C as _e}from"../chunks/CodeBlock.c1f62de5.js";import{H as G,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8fdece89.js";function Pe(ce){let d,Z,E,S,b,Q,w,V,M,z,$,R,y,ue="MobileNet can be integrated with transformer models in various ways to enhance image processing tasks.",Y,g,he="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.",X,T,de="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.",D,v,be="There is an implementation of this concept, called Mobile-Former.",A,x,q,C,we="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.",K,U,Me='<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"/>',O,_,$e='You can find other detailed explanations from <a href="https://arxiv.org/abs/2108.05895" rel="nofollow">Mobile-Former’s paper</a>.',ee,j,te,H,ie,J,ye="<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.",ne,W,ge=`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>.`,le,k,Te="You must install <code>timm</code> with <code>pip</code> first:",se,N,ae,B,ve="Here is the basic code:",oe,I,re,F,xe='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.',me,P,pe,L,fe;return b=new Ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new G({props:{title:"Let’s Dive Further with MobileNet",local:"lets-dive-further-with-mobilenet",headingTag:"h1"}}),M=new G({props:{title:"Can We Use Vision Transformers with MobileNet?",local:"can-we-use-vision-transformers-with-mobilenet",headingTag:"h2"}}),$=new G({props:{title:"Not directly, but we can!",local:"not-directly-but-we-can",headingTag:"h3"}}),x=new G({props:{title:"Mobile-Former",local:"mobile-former",headingTag:"h3"}}),j=new G({props:{title:"MobileNet with Timm",local:"mobilenet-with-timm",headingTag:"h2"}}),H=new G({props:{title:"What is Timm?",local:"what-is-timm",headingTag:"h3"}}),N=new _e({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRpbW0=",highlighted:"pip install timm",wrap:!1}}),I=new _e({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}}),P=new Fe({props:{source:"https://github.com/huggingface/computer-vision-course/blob/main/chapters/en/unit2/cnns/mobilenetextra.mdx"}}),{c(){d=a("meta"),Z=l(),E=a("p"),S=l(),m(b.$$.fragment),Q=l(),m(w.$$.fragment),V=l(),m(M.$$.fragment),z=l(),m($.$$.fragment),R=l(),y=a("p"),y.textContent=ue,Y=l(),g=a("p"),g.textContent=he,X=l(),T=a("p"),T.textContent=de,D=l(),v=a("p"),v.textContent=be,A=l(),m(x.$$.fragment),q=l(),C=a("p"),C.textContent=we,K=l(),U=a("p"),U.innerHTML=Me,O=l(),_=a("p"),_.innerHTML=$e,ee=l(),m(j.$$.fragment),te=l(),m(H.$$.fragment),ie=l(),J=a("p"),J.innerHTML=ye,ne=l(),W=a("p"),W.innerHTML=ge,le=l(),k=a("p"),k.innerHTML=Te,se=l(),m(N.$$.fragment),ae=l(),B=a("p"),B.textContent=ve,oe=l(),m(I.$$.fragment),re=l(),F=a("p"),F.innerHTML=xe,me=l(),m(P.$$.fragment),pe=l(),L=a("p"),this.h()},l(e){const t=Ne("svelte-u9bgzb",document.head);d=o(t,"META",{name:!0,content:!0}),t.forEach(i),Z=s(e),E=o(e,"P",{}),Ce(E).forEach(i),S=s(e),p(b.$$.fragment,e),Q=s(e),p(w.$$.fragment,e),V=s(e),p(M.$$.fragment,e),z=s(e),p($.$$.fragment,e),R=s(e),y=o(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-yybgbl"&&(y.textContent=ue),Y=s(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-18s0bin"&&(g.textContent=he),X=s(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-7wmhfy"&&(T.textContent=de),D=s(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1puogxn"&&(v.textContent=be),A=s(e),p(x.$$.fragment,e),q=s(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-vbor24"&&(C.textContent=we),K=s(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-ywr9bo"&&(U.innerHTML=Me),O=s(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1gfcy2c"&&(_.innerHTML=$e),ee=s(e),p(j.$$.fragment,e),te=s(e),p(H.$$.fragment,e),ie=s(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-15d2ss9"&&(J.innerHTML=ye),ne=s(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1twk0vr"&&(W.innerHTML=ge),le=s(e),k=o(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1u7cyxb"&&(k.innerHTML=Te),se=s(e),p(N.$$.fragment,e),ae=s(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1xhn0zu"&&(B.textContent=ve),oe=s(e),p(I.$$.fragment,e),re=s(e),F=o(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-zzaks2"&&(F.innerHTML=xe),me=s(e),p(P.$$.fragment,e),pe=s(e),L=o(e,"P",{}),Ce(L).forEach(i),this.h()},h(){Ue(d,"name","hf:doc:metadata"),Ue(d,"content",Ge)},m(e,t){Be(document.head,d),n(e,Z,t),n(e,E,t),n(e,S,t),f(b,e,t),n(e,Q,t),f(w,e,t),n(e,V,t),f(M,e,t),n(e,z,t),f($,e,t),n(e,R,t),n(e,y,t),n(e,Y,t),n(e,g,t),n(e,X,t),n(e,T,t),n(e,D,t),n(e,v,t),n(e,A,t),f(x,e,t),n(e,q,t),n(e,C,t),n(e,K,t),n(e,U,t),n(e,O,t),n(e,_,t),n(e,ee,t),f(j,e,t),n(e,te,t),f(H,e,t),n(e,ie,t),n(e,J,t),n(e,ne,t),n(e,W,t),n(e,le,t),n(e,k,t),n(e,se,t),f(N,e,t),n(e,ae,t),n(e,B,t),n(e,oe,t),f(I,e,t),n(e,re,t),n(e,F,t),n(e,me,t),f(P,e,t),n(e,pe,t),n(e,L,t),fe=!0},p:He,i(e){fe||(c(b.$$.fragment,e),c(w.$$.fragment,e),c(M.$$.fragment,e),c($.$$.fragment,e),c(x.$$.fragment,e),c(j.$$.fragment,e),c(H.$$.fragment,e),c(N.$$.fragment,e),c(I.$$.fragment,e),c(P.$$.fragment,e),fe=!0)},o(e){u(b.$$.fragment,e),u(w.$$.fragment,e),u(M.$$.fragment,e),u($.$$.fragment,e),u(x.$$.fragment,e),u(j.$$.fragment,e),u(H.$$.fragment,e),u(N.$$.fragment,e),u(I.$$.fragment,e),u(P.$$.fragment,e),fe=!1},d(e){e&&(i(Z),i(E),i(S),i(Q),i(V),i(z),i(R),i(y),i(Y),i(g),i(X),i(T),i(D),i(v),i(A),i(q),i(C),i(K),i(U),i(O),i(_),i(ee),i(te),i(ie),i(J),i(ne),i(W),i(le),i(k),i(se),i(ae),i(B),i(oe),i(re),i(F),i(me),i(pe),i(L)),i(d),h(b,e),h(w,e),h(M,e),h($,e),h(x,e),h(j,e),h(H,e),h(N,e),h(I,e),h(P,e)}}}const Ge='{"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 Ee(ce){return Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ze extends We{constructor(d){super(),ke(this,d,Ee,Pe,je,{})}}export{ze as component};
