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