import{s as Ue,f as ie,n as xe,o as Ie}from"../chunks/scheduler.37c15a92.js";import{S as je,i as He,g as i,s as o,r as $,A as ve,h as r,f as l,c as n,j as S,u as G,x as g,k as s,y as Ze,a,v as W,d as k,t as B,w as C}from"../chunks/index.2bf4358c.js";import{C as re}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as $e}from"../chunks/CourseFloatingBanner.06521e8b.js";import{H as ce}from"../chunks/Heading.8ada512a.js";function Ge(me){let u,_,R,F,f,Q,M,N,d,pe=`Чтобы сделать вашу жизнь еще проще, Gradio напрямую интегрируется с Hugging Face Hub и Hugging Face Spaces.
Вы можете загружать демо из Hub и Spaces, используя всего <em>одну строку кода</em>.`,V,b,q,h,ue='Для начала выберите одну из тысяч моделей, которые Hugging Face предлагает в Hub, как описано в <a href="../chapter4/2">Главе 4</a>.',z,y,ge=`Используя специальный метод <code>Interface.load()</code>, вы передаете <code>&quot;model/&quot;</code> (или, эквивалентно, <code>&quot;huggingface/&quot;</code>)
после чего следует имя модели.
Например, здесь приведен код для создания демо для <a href="https://huggingface.co/EleutherAI/gpt-j-6B" rel="nofollow">GPT-J</a>, большой языковой модели, добавьте пару примеров ввода:`,E,J,X,w,fe="Код, приведенный выше, приведет к созданию интерфейса, представленного ниже:",L,c,Me,A,T,de=`Загрузка модели таким образом использует <a href="https://huggingface.co/inference-api" rel="nofollow">Inference API</a> Hugging Face,
вместо того, чтобы загружать модель в память. Это идеально подходит для огромных моделей, таких как GPT-J или T0pp, которые
которые требуют много RAM.`,P,U,D,x,be="Чтобы загрузить любое пространство (Space) из Hugging Face Hub и воссоздать его локально, вы можете передать <code>spaces/</code> в <code>Interface</code>, за которым следует имя пространства.",K,I,he="Помните демо из раздела 1, которое удаляет фон изображения? Давайте загрузим его из Hugging Face Spaces:",O,j,ee,m,ye,te,H,Je=`Одна из особенностей загрузки демо из Hub или Spaces заключается в том, что вы можете настраивать их
переопределив любой из
параметров. Здесь мы добавим заголовок и задействуем веб-камеру:`,le,v,ae,p,we,se,Z,Te="Теперь, когда мы изучили несколько способов интеграции Gradio с Hugging Face Hub, давайте рассмотрим некоторые дополнительные возможности класса <code>Interface</code>. Этому будет посвящен следующий раздел!",oe,Y,ne;return f=new ce({props:{title:"Интеграция с Hugging Face Hub",local:"integrations-with-the-hugging-face-hub",headingTag:"h1"}}),M=new $e({props:{chapter:9,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter9/section5.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter9/section5.ipynb"}]}}),b=new ce({props:{title:"Загрузка моделей из Hugging Face Hub",local:"loading-models-from-the-hugging-face-hub",headingTag:"h3"}}),J=new re({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQXRpdGxlJTIwJTNEJTIwJTIyR1BULUotNkIlMjIlMEFkZXNjcmlwdGlvbiUyMCUzRCUyMCUyMkdyYWRpbyUyMERlbW8lMjBmb3IlMjBHUFQtSiUyMDZCJTJDJTIwYSUyMHRyYW5zZm9ybWVyJTIwbW9kZWwlMjB0cmFpbmVkJTIwdXNpbmclMjBCZW4lMjBXYW5nJ3MlMjBNZXNoJTIwVHJhbnNmb3JtZXIlMjBKQVguJTIwJ0dQVC1KJyUyMHJlZmVycyUyMHRvJTIwdGhlJTIwY2xhc3MlMjBvZiUyMG1vZGVsJTJDJTIwd2hpbGUlMjAnNkInJTIwcmVwcmVzZW50cyUyMHRoZSUyMG51bWJlciUyMG9mJTIwdHJhaW5hYmxlJTIwcGFyYW1ldGVycy4lMjBUbyUyMHVzZSUyMGl0JTJDJTIwc2ltcGx5JTIwYWRkJTIweW91ciUyMHRleHQlMkMlMjBvciUyMGNsaWNrJTIwb25lJTIwb2YlMjB0aGUlMjBleGFtcGxlcyUyMHRvJTIwbG9hZCUyMHRoZW0uJTIwUmVhZCUyMG1vcmUlMjBhdCUyMHRoZSUyMGxpbmtzJTIwYmVsb3cuJTIyJTBBYXJ0aWNsZSUyMCUzRCUyMCUyMiUzQ3AlMjBzdHlsZSUzRCd0ZXh0LWFsaWduJTNBJTIwY2VudGVyJyUzRSUzQ2ElMjBocmVmJTNEJ2h0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmtpbmdvZmxvbHolMkZtZXNoLXRyYW5zZm9ybWVyLWpheCclMjB0YXJnZXQlM0QnX2JsYW5rJyUzRUdQVC1KLTZCJTNBJTIwQSUyMDYlMjBCaWxsaW9uJTIwUGFyYW1ldGVyJTIwQXV0b3JlZ3Jlc3NpdmUlMjBMYW5ndWFnZSUyME1vZGVsJTNDJTJGYSUzRSUzQyUyRnAlM0UlMjIlMEElMEFnci5JbnRlcmZhY2UubG9hZCglMEElMjAlMjAlMjAlMjAlMjJodWdnaW5nZmFjZSUyRkVsZXV0aGVyQUklMkZncHQtai02QiUyMiUyQyUwQSUyMCUyMCUyMCUyMGlucHV0cyUzRGdyLlRleHRib3gobGluZXMlM0Q1JTJDJTIwbGFiZWwlM0QlMjJJbnB1dCUyMFRleHQlMjIpJTJDJTBBJTIwJTIwJTIwJTIwdGl0bGUlM0R0aXRsZSUyQyUwQSUyMCUyMCUyMCUyMGRlc2NyaXB0aW9uJTNEZGVzY3JpcHRpb24lMkMlMEElMjAlMjAlMjAlMjBhcnRpY2xlJTNEYXJ0aWNsZSUyQyUwQSkubGF1bmNoKCk=",highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr

title = <span class="hljs-string">&quot;GPT-J-6B&quot;</span>
description = <span class="hljs-string">&quot;Gradio Demo for GPT-J 6B, a transformer model trained using Ben Wang&#x27;s Mesh Transformer JAX. &#x27;GPT-J&#x27; refers to the class of model, while &#x27;6B&#x27; represents the number of trainable parameters. To use it, simply add your text, or click one of the examples to load them. Read more at the links below.&quot;</span>
article = <span class="hljs-string">&quot;&lt;p style=&#x27;text-align: center&#x27;&gt;&lt;a href=&#x27;https://github.com/kingoflolz/mesh-transformer-jax&#x27; target=&#x27;_blank&#x27;&gt;GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model&lt;/a&gt;&lt;/p&gt;&quot;</span>

gr.Interface.load(
    <span class="hljs-string">&quot;huggingface/EleutherAI/gpt-j-6B&quot;</span>,
    inputs=gr.Textbox(lines=<span class="hljs-number">5</span>, label=<span class="hljs-string">&quot;Input Text&quot;</span>),
    title=title,
    description=description,
    article=article,
).launch()`,wrap:!1}}),U=new ce({props:{title:"Загрузка с Hugging Face Spaces",local:"loading-from-hugging-face-spaces",headingTag:"h3"}}),j=new re({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIpLmxhdW5jaCgp",highlighted:'gr.Interface.load(<span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>).launch()',wrap:!1}}),v=new re({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTBBJTIwJTIwJTIwJTIwJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIlMkMlMjBpbnB1dHMlM0QlMjJ3ZWJjYW0lMjIlMkMlMjB0aXRsZSUzRCUyMlJlbW92ZSUyMHlvdXIlMjB3ZWJjYW0lMjBiYWNrZ3JvdW5kISUyMiUwQSkubGF1bmNoKCk=",highlighted:`gr.Interface.load(
    <span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>, inputs=<span class="hljs-string">&quot;webcam&quot;</span>, title=<span class="hljs-string">&quot;Remove your webcam background!&quot;</span>
).launch()`,wrap:!1}}),{c(){u=i("meta"),_=o(),R=i("p"),F=o(),$(f.$$.fragment),Q=o(),$(M.$$.fragment),N=o(),d=i("p"),d.innerHTML=pe,V=o(),$(b.$$.fragment),q=o(),h=i("p"),h.innerHTML=ue,z=o(),y=i("p"),y.innerHTML=ge,E=o(),$(J.$$.fragment),X=o(),w=i("p"),w.textContent=fe,L=o(),c=i("iframe"),A=o(),T=i("p"),T.innerHTML=de,P=o(),$(U.$$.fragment),D=o(),x=i("p"),x.innerHTML=be,K=o(),I=i("p"),I.textContent=he,O=o(),$(j.$$.fragment),ee=o(),m=i("iframe"),te=o(),H=i("p"),H.textContent=Je,le=o(),$(v.$$.fragment),ae=o(),p=i("iframe"),se=o(),Z=i("p"),Z.innerHTML=Te,oe=o(),Y=i("p"),this.h()},l(e){const t=ve("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(l),_=n(e),R=r(e,"P",{}),S(R).forEach(l),F=n(e),G(f.$$.fragment,e),Q=n(e),G(M.$$.fragment,e),N=n(e),d=r(e,"P",{"data-svelte-h":!0}),g(d)!=="svelte-17qv02r"&&(d.innerHTML=pe),V=n(e),G(b.$$.fragment,e),q=n(e),h=r(e,"P",{"data-svelte-h":!0}),g(h)!=="svelte-hdmlos"&&(h.innerHTML=ue),z=n(e),y=r(e,"P",{"data-svelte-h":!0}),g(y)!=="svelte-la64n7"&&(y.innerHTML=ge),E=n(e),G(J.$$.fragment,e),X=n(e),w=r(e,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1jejoka"&&(w.textContent=fe),L=n(e),c=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),S(c).forEach(l),A=n(e),T=r(e,"P",{"data-svelte-h":!0}),g(T)!=="svelte-1j527aq"&&(T.innerHTML=de),P=n(e),G(U.$$.fragment,e),D=n(e),x=r(e,"P",{"data-svelte-h":!0}),g(x)!=="svelte-1hfmqh8"&&(x.innerHTML=be),K=n(e),I=r(e,"P",{"data-svelte-h":!0}),g(I)!=="svelte-enuzxx"&&(I.textContent=he),O=n(e),G(j.$$.fragment,e),ee=n(e),m=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),S(m).forEach(l),te=n(e),H=r(e,"P",{"data-svelte-h":!0}),g(H)!=="svelte-anaqim"&&(H.textContent=Je),le=n(e),G(v.$$.fragment,e),ae=n(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),S(p).forEach(l),se=n(e),Z=r(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-v1bc9b"&&(Z.innerHTML=Te),oe=n(e),Y=r(e,"P",{}),S(Y).forEach(l),this.h()},h(){s(u,"name","hf:doc:metadata"),s(u,"content",We),ie(c.src,Me="https://course-demos-gpt-j-6B.hf.space")||s(c,"src",Me),s(c,"frameborder","0"),s(c,"height","750"),s(c,"title","Gradio app"),s(c,"class","container p-0 flex-grow space-iframe"),s(c,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),s(c,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),ie(m.src,ye="https://course-demos-remove-bg-original.hf.space")||s(m,"src",ye),s(m,"frameborder","0"),s(m,"height","650"),s(m,"title","Gradio app"),s(m,"class","container p-0 flex-grow space-iframe"),s(m,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),s(m,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),ie(p.src,we="https://course-demos-Remove-bg.hf.space")||s(p,"src",we),s(p,"frameborder","0"),s(p,"height","550"),s(p,"title","Gradio app"),s(p,"class","container p-0 flex-grow space-iframe"),s(p,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),s(p,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads")},m(e,t){Ze(document.head,u),a(e,_,t),a(e,R,t),a(e,F,t),W(f,e,t),a(e,Q,t),W(M,e,t),a(e,N,t),a(e,d,t),a(e,V,t),W(b,e,t),a(e,q,t),a(e,h,t),a(e,z,t),a(e,y,t),a(e,E,t),W(J,e,t),a(e,X,t),a(e,w,t),a(e,L,t),a(e,c,t),a(e,A,t),a(e,T,t),a(e,P,t),W(U,e,t),a(e,D,t),a(e,x,t),a(e,K,t),a(e,I,t),a(e,O,t),W(j,e,t),a(e,ee,t),a(e,m,t),a(e,te,t),a(e,H,t),a(e,le,t),W(v,e,t),a(e,ae,t),a(e,p,t),a(e,se,t),a(e,Z,t),a(e,oe,t),a(e,Y,t),ne=!0},p:xe,i(e){ne||(k(f.$$.fragment,e),k(M.$$.fragment,e),k(b.$$.fragment,e),k(J.$$.fragment,e),k(U.$$.fragment,e),k(j.$$.fragment,e),k(v.$$.fragment,e),ne=!0)},o(e){B(f.$$.fragment,e),B(M.$$.fragment,e),B(b.$$.fragment,e),B(J.$$.fragment,e),B(U.$$.fragment,e),B(j.$$.fragment,e),B(v.$$.fragment,e),ne=!1},d(e){e&&(l(_),l(R),l(F),l(Q),l(N),l(d),l(V),l(q),l(h),l(z),l(y),l(E),l(X),l(w),l(L),l(c),l(A),l(T),l(P),l(D),l(x),l(K),l(I),l(O),l(ee),l(m),l(te),l(H),l(le),l(ae),l(p),l(se),l(Z),l(oe),l(Y)),l(u),C(f,e),C(M,e),C(b,e),C(J,e),C(U,e),C(j,e),C(v,e)}}}const We='{"title":"Интеграция с Hugging Face Hub","local":"integrations-with-the-hugging-face-hub","sections":[{"title":"Загрузка моделей из Hugging Face Hub","local":"loading-models-from-the-hugging-face-hub","sections":[],"depth":3},{"title":"Загрузка с Hugging Face Spaces","local":"loading-from-hugging-face-spaces","sections":[],"depth":3}],"depth":1}';function ke(me){return Ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _e extends je{constructor(u){super(),He(this,u,ke,Ge,Ue,{})}}export{_e as component};
