import{s as Se,n as Ee,o as Re}from"../chunks/scheduler.d6170356.js";import{S as Xe,i as ze,g as s,s as i,r as p,A as Qe,h as o,f as l,c as n,j as qe,u as r,x as u,k as Je,y as Ve,a,v as m,d,t as M,w as f}from"../chunks/index.fcd4cc08.js";import{C as je}from"../chunks/CodeBlock.7b16bdef.js";import{H as S}from"../chunks/Heading.8660bd0e.js";function Ne($e){let c,X,E,z,b,Q,w,ve="<code>stable-baselines3</code> is a set of reliable implementations of reinforcement learning algorithms in PyTorch.",V,g,N,T,Ie='You can find Stable-Baselines3 models by filtering at the left of the <a href="https://huggingface.co/models?library=stable-baselines3" rel="nofollow">models page</a>.',D,y,Ce="All models on the Hub come up with useful features:",O,j,_e="<li>An automatically generated model card with a description, a training configuration, and more.</li> <li>Metadata tags that help for discoverability.</li> <li>Evaluation results to compare with other models.</li> <li>A video widget where you can watch your agent performing.</li>",K,J,ee,$,Ue="To install the <code>stable-baselines3</code> library, you need to install two packages:",te,v,Ae="<li><code>stable-baselines3</code>: Stable-Baselines3 library.</li> <li><code>huggingface-sb3</code>: additional code to load and upload Stable-baselines3 models from the Hub.</li>",le,I,ae,C,ie,_,Le="You can simply download a model from the Hub using the <code>load_from_hub</code> function",ne,U,se,A,xe="You need to define two parameters:",oe,L,He="<li><code>--repo-id</code>: the name of the Hugging Face repo you want to download.</li> <li><code>--filename</code>: the file you want to download.</li>",ue,x,pe,H,Be="You can easily upload your models using two different functions:",re,B,ke="<li><code>package_to_hub()</code>: save the model, evaluate it, generate a model card and record a replay video of your agent before pushing the complete repo to the Hub.</li>",me,k,de,W,We="You need to define seven parameters:",Me,Z,Ze="<li><code>--model</code>: your trained model.</li> <li><code>--model_architecture</code>: name of the architecture of your model (DQN, PPO, A2C, SAC…).</li> <li><code>--env_id</code>: name of the environment.</li> <li><code>--eval_env</code>: environment used to evaluate the agent.</li> <li><code>--repo-id</code>: the name of the Hugging Face repo you want to create or update. It’s <code>&lt;your huggingface username&gt;/&lt;the repo name&gt;</code>.</li> <li><code>--commit-message</code>.</li> <li><code>--filename</code>: the file you want to push to the Hub.</li>",fe,h,Ye="<li><code>push_to_hub()</code>: simply push a file to the Hub</li>",ce,Y,he,G,Ge="You need to define three parameters:",be,F,Fe="<li><code>--repo-id</code>: the name of the Hugging Face repo you want to create or update. It’s <code>&lt;your huggingface username&gt;/&lt;the repo name&gt;</code>.</li> <li><code>--filename</code>: the file you want to push to the Hub.</li> <li><code>--commit-message</code>.</li>",we,P,ge,q,Pe='<li>Hugging Face Stable-Baselines3 <a href="https://github.com/huggingface/huggingface_sb3#hugging-face--x-stable-baselines3-v20" rel="nofollow">documentation</a></li> <li>Stable-Baselines3 <a href="https://stable-baselines3.readthedocs.io/en/master/" rel="nofollow">documentation</a></li>',Te,R,ye;return b=new S({props:{title:"Using Stable-Baselines3 at Hugging Face",local:"using-stable-baselines3-at-hugging-face",headingTag:"h1"}}),g=new S({props:{title:"Exploring Stable-Baselines3 in the Hub",local:"exploring-stable-baselines3-in-the-hub",headingTag:"h2"}}),J=new S({props:{title:"Install the library",local:"install-the-library",headingTag:"h2"}}),I=new je({props:{code:"cGlwJTIwaW5zdGFsbCUyMHN0YWJsZS1iYXNlbGluZXMzJTBBcGlwJTIwaW5zdGFsbCUyMGh1Z2dpbmdmYWNlLXNiMw==",highlighted:`pip <span class="hljs-keyword">install </span>stable-<span class="hljs-keyword">baselines3
</span>pip <span class="hljs-keyword">install </span>huggingface-<span class="hljs-keyword">sb3</span>`,wrap:!1}}),C=new S({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),U=new je({props:{code:"Y2hlY2twb2ludCUyMCUzRCUyMGxvYWRfZnJvbV9odWIoJTBBJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMnNiMyUyRmRlbW8taGYtQ2FydFBvbGUtdjElMjIlMkMlMEElMjAlMjAlMjAlMjBmaWxlbmFtZSUzRCUyMnBwby1DYXJ0UG9sZS12MS56aXAlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">checkpoint</span> = load_from_hub(
    repo_id=&quot;sb3/demo-hf-CartPole-v1&quot;,
    filename=&quot;ppo-CartPole-v1.zip&quot;,
)`,wrap:!1}}),x=new S({props:{title:"Sharing your models",local:"sharing-your-models",headingTag:"h2"}}),k=new je({props:{code:"cGFja2FnZV90b19odWIobW9kZWwlM0Rtb2RlbCUyQyUyMCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1vZGVsX25hbWUlM0QlMjJwcG8tTHVuYXJMYW5kZXItdjIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbF9hcmNoaXRlY3R1cmUlM0QlMjJQUE8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbnZfaWQlM0RlbnZfaWQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBldmFsX2VudiUzRGV2YWxfZW52JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMlRob21hc1NpbW9uaW5pJTJGcHBvLUx1bmFyTGFuZGVyLXYyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY29tbWl0X21lc3NhZ2UlM0QlMjJUZXN0JTIwY29tbWl0JTIyKQ==",highlighted:`package_to_hub(<span class="hljs-attribute">model</span>=model, 
               <span class="hljs-attribute">model_name</span>=<span class="hljs-string">&quot;ppo-LunarLander-v2&quot;</span>,
               <span class="hljs-attribute">model_architecture</span>=<span class="hljs-string">&quot;PPO&quot;</span>,
               <span class="hljs-attribute">env_id</span>=env_id,
               <span class="hljs-attribute">eval_env</span>=eval_env,
               <span class="hljs-attribute">repo_id</span>=<span class="hljs-string">&quot;ThomasSimonini/ppo-LunarLander-v2&quot;</span>,
               <span class="hljs-attribute">commit_message</span>=<span class="hljs-string">&quot;Test commit&quot;</span>)`,wrap:!1}}),Y=new je({props:{code:"cHVzaF90b19odWIoJTBBJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMlRob21hc1NpbW9uaW5pJTJGcHBvLUx1bmFyTGFuZGVyLXYyJTIyJTJDJTBBJTIwJTIwJTIwJTIwZmlsZW5hbWUlM0QlMjJwcG8tTHVuYXJMYW5kZXItdjIuemlwJTIyJTJDJTBBJTIwJTIwJTIwJTIwY29tbWl0X21lc3NhZ2UlM0QlMjJBZGRlZCUyMEx1bmFyTGFuZGVyLXYyJTIwbW9kZWwlMjB0cmFpbmVkJTIwd2l0aCUyMFBQTyUyMiUyQyUwQSk=",highlighted:`push_to_hub(
    <span class="hljs-attribute">repo_id</span>=<span class="hljs-string">&quot;ThomasSimonini/ppo-LunarLander-v2&quot;</span>,
    <span class="hljs-attribute">filename</span>=<span class="hljs-string">&quot;ppo-LunarLander-v2.zip&quot;</span>,
    <span class="hljs-attribute">commit_message</span>=<span class="hljs-string">&quot;Added LunarLander-v2 model trained with PPO&quot;</span>,
)`,wrap:!1}}),P=new S({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),{c(){c=s("meta"),X=i(),E=s("p"),z=i(),p(b.$$.fragment),Q=i(),w=s("p"),w.innerHTML=ve,V=i(),p(g.$$.fragment),N=i(),T=s("p"),T.innerHTML=Ie,D=i(),y=s("p"),y.textContent=Ce,O=i(),j=s("ol"),j.innerHTML=_e,K=i(),p(J.$$.fragment),ee=i(),$=s("p"),$.innerHTML=Ue,te=i(),v=s("ul"),v.innerHTML=Ae,le=i(),p(I.$$.fragment),ae=i(),p(C.$$.fragment),ie=i(),_=s("p"),_.innerHTML=Le,ne=i(),p(U.$$.fragment),se=i(),A=s("p"),A.textContent=xe,oe=i(),L=s("ul"),L.innerHTML=He,ue=i(),p(x.$$.fragment),pe=i(),H=s("p"),H.textContent=Be,re=i(),B=s("ol"),B.innerHTML=ke,me=i(),p(k.$$.fragment),de=i(),W=s("p"),W.textContent=We,Me=i(),Z=s("ul"),Z.innerHTML=Ze,fe=i(),h=s("ol"),h.innerHTML=Ye,ce=i(),p(Y.$$.fragment),he=i(),G=s("p"),G.textContent=Ge,be=i(),F=s("ul"),F.innerHTML=Fe,we=i(),p(P.$$.fragment),ge=i(),q=s("ul"),q.innerHTML=Pe,Te=i(),R=s("p"),this.h()},l(e){const t=Qe("svelte-u9bgzb",document.head);c=o(t,"META",{name:!0,content:!0}),t.forEach(l),X=n(e),E=o(e,"P",{}),qe(E).forEach(l),z=n(e),r(b.$$.fragment,e),Q=n(e),w=o(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-1qvbwux"&&(w.innerHTML=ve),V=n(e),r(g.$$.fragment,e),N=n(e),T=o(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-ybuo0r"&&(T.innerHTML=Ie),D=n(e),y=o(e,"P",{"data-svelte-h":!0}),u(y)!=="svelte-1krwbts"&&(y.textContent=Ce),O=n(e),j=o(e,"OL",{"data-svelte-h":!0}),u(j)!=="svelte-117jq8g"&&(j.innerHTML=_e),K=n(e),r(J.$$.fragment,e),ee=n(e),$=o(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1b2iahk"&&($.innerHTML=Ue),te=n(e),v=o(e,"UL",{"data-svelte-h":!0}),u(v)!=="svelte-rs53ls"&&(v.innerHTML=Ae),le=n(e),r(I.$$.fragment,e),ae=n(e),r(C.$$.fragment,e),ie=n(e),_=o(e,"P",{"data-svelte-h":!0}),u(_)!=="svelte-15snlvs"&&(_.innerHTML=Le),ne=n(e),r(U.$$.fragment,e),se=n(e),A=o(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-3zu0j3"&&(A.textContent=xe),oe=n(e),L=o(e,"UL",{"data-svelte-h":!0}),u(L)!=="svelte-btz9m6"&&(L.innerHTML=He),ue=n(e),r(x.$$.fragment,e),pe=n(e),H=o(e,"P",{"data-svelte-h":!0}),u(H)!=="svelte-cgi5ig"&&(H.textContent=Be),re=n(e),B=o(e,"OL",{"data-svelte-h":!0}),u(B)!=="svelte-124e0c9"&&(B.innerHTML=ke),me=n(e),r(k.$$.fragment,e),de=n(e),W=o(e,"P",{"data-svelte-h":!0}),u(W)!=="svelte-1j3q7ku"&&(W.textContent=We),Me=n(e),Z=o(e,"UL",{"data-svelte-h":!0}),u(Z)!=="svelte-1orohkz"&&(Z.innerHTML=Ze),fe=n(e),h=o(e,"OL",{start:!0,"data-svelte-h":!0}),u(h)!=="svelte-ta2cke"&&(h.innerHTML=Ye),ce=n(e),r(Y.$$.fragment,e),he=n(e),G=o(e,"P",{"data-svelte-h":!0}),u(G)!=="svelte-maovvp"&&(G.textContent=Ge),be=n(e),F=o(e,"UL",{"data-svelte-h":!0}),u(F)!=="svelte-2z5aiw"&&(F.innerHTML=Fe),we=n(e),r(P.$$.fragment,e),ge=n(e),q=o(e,"UL",{"data-svelte-h":!0}),u(q)!=="svelte-1h97kql"&&(q.innerHTML=Pe),Te=n(e),R=o(e,"P",{}),qe(R).forEach(l),this.h()},h(){Je(c,"name","hf:doc:metadata"),Je(c,"content",De),Je(h,"start","2")},m(e,t){Ve(document.head,c),a(e,X,t),a(e,E,t),a(e,z,t),m(b,e,t),a(e,Q,t),a(e,w,t),a(e,V,t),m(g,e,t),a(e,N,t),a(e,T,t),a(e,D,t),a(e,y,t),a(e,O,t),a(e,j,t),a(e,K,t),m(J,e,t),a(e,ee,t),a(e,$,t),a(e,te,t),a(e,v,t),a(e,le,t),m(I,e,t),a(e,ae,t),m(C,e,t),a(e,ie,t),a(e,_,t),a(e,ne,t),m(U,e,t),a(e,se,t),a(e,A,t),a(e,oe,t),a(e,L,t),a(e,ue,t),m(x,e,t),a(e,pe,t),a(e,H,t),a(e,re,t),a(e,B,t),a(e,me,t),m(k,e,t),a(e,de,t),a(e,W,t),a(e,Me,t),a(e,Z,t),a(e,fe,t),a(e,h,t),a(e,ce,t),m(Y,e,t),a(e,he,t),a(e,G,t),a(e,be,t),a(e,F,t),a(e,we,t),m(P,e,t),a(e,ge,t),a(e,q,t),a(e,Te,t),a(e,R,t),ye=!0},p:Ee,i(e){ye||(d(b.$$.fragment,e),d(g.$$.fragment,e),d(J.$$.fragment,e),d(I.$$.fragment,e),d(C.$$.fragment,e),d(U.$$.fragment,e),d(x.$$.fragment,e),d(k.$$.fragment,e),d(Y.$$.fragment,e),d(P.$$.fragment,e),ye=!0)},o(e){M(b.$$.fragment,e),M(g.$$.fragment,e),M(J.$$.fragment,e),M(I.$$.fragment,e),M(C.$$.fragment,e),M(U.$$.fragment,e),M(x.$$.fragment,e),M(k.$$.fragment,e),M(Y.$$.fragment,e),M(P.$$.fragment,e),ye=!1},d(e){e&&(l(X),l(E),l(z),l(Q),l(w),l(V),l(N),l(T),l(D),l(y),l(O),l(j),l(K),l(ee),l($),l(te),l(v),l(le),l(ae),l(ie),l(_),l(ne),l(se),l(A),l(oe),l(L),l(ue),l(pe),l(H),l(re),l(B),l(me),l(de),l(W),l(Me),l(Z),l(fe),l(h),l(ce),l(he),l(G),l(be),l(F),l(we),l(ge),l(q),l(Te),l(R)),l(c),f(b,e),f(g,e),f(J,e),f(I,e),f(C,e),f(U,e),f(x,e),f(k,e),f(Y,e),f(P,e)}}}const De='{"title":"Using Stable-Baselines3 at Hugging Face","local":"using-stable-baselines3-at-hugging-face","sections":[{"title":"Exploring Stable-Baselines3 in the Hub","local":"exploring-stable-baselines3-in-the-hub","sections":[],"depth":2},{"title":"Install the library","local":"install-the-library","sections":[],"depth":2},{"title":"Using existing models","local":"using-existing-models","sections":[],"depth":2},{"title":"Sharing your models","local":"sharing-your-models","sections":[],"depth":2},{"title":"Additional resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function Oe($e){return Re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class at extends Xe{constructor(c){super(),ze(this,c,Oe,Ne,Se,{})}}export{at as component};
