import{s as Ie,f as ce,n as je,o as $e}from"../chunks/scheduler.37c15a92.js";import{S as He,i as ve,g as i,s as o,r as f,A as Ze,h as r,f as l,c as n,j as _,u as M,x as g,k as s,y as Ge,a,v as d,d as b,t as h,w as y}from"../chunks/index.2bf4358c.js";import{C as me}from"../chunks/CodeBlock.4e987730.js";import{C as We}from"../chunks/CourseFloatingBanner.9ff4c771.js";import{H as pe,E as ke}from"../chunks/index.b8688d36.js";function Be(ue){let u,F,Y,Q,w,E,J,N,T,ge=`Чтобы сделать вашу жизнь еще проще, Gradio напрямую интегрируется с Hugging Face Hub и Hugging Face Spaces.
Вы можете загружать демо из Hub и Spaces, используя всего <em>одну строку кода</em>.`,V,U,q,x,fe='Для начала выберите одну из тысяч моделей, которые Hugging Face предлагает в Hub, как описано в <a href="../chapter4/2">Главе 4</a>.',z,I,Me=`Используя специальный метод <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>, большой языковой модели, добавьте пару примеров ввода:`,X,j,L,$,de="Код, приведенный выше, приведет к созданию интерфейса, представленного ниже:",A,c,be,P,H,he=`Загрузка модели таким образом использует <a href="https://huggingface.co/inference-api" rel="nofollow">Inference API</a> Hugging Face,
вместо того, чтобы загружать модель в память. Это идеально подходит для огромных моделей, таких как GPT-J или T0pp, которые
которые требуют много RAM.`,D,v,K,Z,ye="Чтобы загрузить любое пространство (Space) из Hugging Face Hub и воссоздать его локально, вы можете передать <code>spaces/</code> в <code>Interface</code>, за которым следует имя пространства.",O,G,we="Помните демо из раздела 1, которое удаляет фон изображения? Давайте загрузим его из Hugging Face Spaces:",ee,W,te,m,Je,le,k,Te=`Одна из особенностей загрузки демо из Hub или Spaces заключается в том, что вы можете настраивать их
переопределив любой из
параметров. Здесь мы добавим заголовок и задействуем веб-камеру:`,ae,B,se,p,Ue,oe,C,xe="Теперь, когда мы изучили несколько способов интеграции Gradio с Hugging Face Hub, давайте рассмотрим некоторые дополнительные возможности класса <code>Interface</code>. Этому будет посвящен следующий раздел!",ne,R,ie,S,re;return w=new pe({props:{title:"Интеграция с Hugging Face Hub",local:"integrations-with-the-hugging-face-hub",headingTag:"h1"}}),J=new We({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"}]}}),U=new pe({props:{title:"Загрузка моделей из Hugging Face Hub",local:"loading-models-from-the-hugging-face-hub",headingTag:"h3"}}),j=new me({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}}),v=new pe({props:{title:"Загрузка с Hugging Face Spaces",local:"loading-from-hugging-face-spaces",headingTag:"h3"}}),W=new me({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIpLmxhdW5jaCgp",highlighted:'gr.Interface.load(<span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>).launch()',wrap:!1}}),B=new me({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}}),R=new ke({props:{source:"https://github.com/huggingface/course/blob/main/chapters/ru/chapter9/5.mdx"}}),{c(){u=i("meta"),F=o(),Y=i("p"),Q=o(),f(w.$$.fragment),E=o(),f(J.$$.fragment),N=o(),T=i("p"),T.innerHTML=ge,V=o(),f(U.$$.fragment),q=o(),x=i("p"),x.innerHTML=fe,z=o(),I=i("p"),I.innerHTML=Me,X=o(),f(j.$$.fragment),L=o(),$=i("p"),$.textContent=de,A=o(),c=i("iframe"),P=o(),H=i("p"),H.innerHTML=he,D=o(),f(v.$$.fragment),K=o(),Z=i("p"),Z.innerHTML=ye,O=o(),G=i("p"),G.textContent=we,ee=o(),f(W.$$.fragment),te=o(),m=i("iframe"),le=o(),k=i("p"),k.textContent=Te,ae=o(),f(B.$$.fragment),se=o(),p=i("iframe"),oe=o(),C=i("p"),C.innerHTML=xe,ne=o(),f(R.$$.fragment),ie=o(),S=i("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(l),F=n(e),Y=r(e,"P",{}),_(Y).forEach(l),Q=n(e),M(w.$$.fragment,e),E=n(e),M(J.$$.fragment,e),N=n(e),T=r(e,"P",{"data-svelte-h":!0}),g(T)!=="svelte-17qv02r"&&(T.innerHTML=ge),V=n(e),M(U.$$.fragment,e),q=n(e),x=r(e,"P",{"data-svelte-h":!0}),g(x)!=="svelte-hdmlos"&&(x.innerHTML=fe),z=n(e),I=r(e,"P",{"data-svelte-h":!0}),g(I)!=="svelte-la64n7"&&(I.innerHTML=Me),X=n(e),M(j.$$.fragment,e),L=n(e),$=r(e,"P",{"data-svelte-h":!0}),g($)!=="svelte-1jejoka"&&($.textContent=de),A=n(e),c=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),_(c).forEach(l),P=n(e),H=r(e,"P",{"data-svelte-h":!0}),g(H)!=="svelte-1j527aq"&&(H.innerHTML=he),D=n(e),M(v.$$.fragment,e),K=n(e),Z=r(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-1hfmqh8"&&(Z.innerHTML=ye),O=n(e),G=r(e,"P",{"data-svelte-h":!0}),g(G)!=="svelte-enuzxx"&&(G.textContent=we),ee=n(e),M(W.$$.fragment,e),te=n(e),m=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),_(m).forEach(l),le=n(e),k=r(e,"P",{"data-svelte-h":!0}),g(k)!=="svelte-anaqim"&&(k.textContent=Te),ae=n(e),M(B.$$.fragment,e),se=n(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),_(p).forEach(l),oe=n(e),C=r(e,"P",{"data-svelte-h":!0}),g(C)!=="svelte-v1bc9b"&&(C.innerHTML=xe),ne=n(e),M(R.$$.fragment,e),ie=n(e),S=r(e,"P",{}),_(S).forEach(l),this.h()},h(){s(u,"name","hf:doc:metadata"),s(u,"content",Ce),ce(c.src,be="https://course-demos-gpt-j-6B.hf.space")||s(c,"src",be),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"),ce(m.src,Je="https://course-demos-remove-bg-original.hf.space")||s(m,"src",Je),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"),ce(p.src,Ue="https://course-demos-Remove-bg.hf.space")||s(p,"src",Ue),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){Ge(document.head,u),a(e,F,t),a(e,Y,t),a(e,Q,t),d(w,e,t),a(e,E,t),d(J,e,t),a(e,N,t),a(e,T,t),a(e,V,t),d(U,e,t),a(e,q,t),a(e,x,t),a(e,z,t),a(e,I,t),a(e,X,t),d(j,e,t),a(e,L,t),a(e,$,t),a(e,A,t),a(e,c,t),a(e,P,t),a(e,H,t),a(e,D,t),d(v,e,t),a(e,K,t),a(e,Z,t),a(e,O,t),a(e,G,t),a(e,ee,t),d(W,e,t),a(e,te,t),a(e,m,t),a(e,le,t),a(e,k,t),a(e,ae,t),d(B,e,t),a(e,se,t),a(e,p,t),a(e,oe,t),a(e,C,t),a(e,ne,t),d(R,e,t),a(e,ie,t),a(e,S,t),re=!0},p:je,i(e){re||(b(w.$$.fragment,e),b(J.$$.fragment,e),b(U.$$.fragment,e),b(j.$$.fragment,e),b(v.$$.fragment,e),b(W.$$.fragment,e),b(B.$$.fragment,e),b(R.$$.fragment,e),re=!0)},o(e){h(w.$$.fragment,e),h(J.$$.fragment,e),h(U.$$.fragment,e),h(j.$$.fragment,e),h(v.$$.fragment,e),h(W.$$.fragment,e),h(B.$$.fragment,e),h(R.$$.fragment,e),re=!1},d(e){e&&(l(F),l(Y),l(Q),l(E),l(N),l(T),l(V),l(q),l(x),l(z),l(I),l(X),l(L),l($),l(A),l(c),l(P),l(H),l(D),l(K),l(Z),l(O),l(G),l(ee),l(te),l(m),l(le),l(k),l(ae),l(se),l(p),l(oe),l(C),l(ne),l(ie),l(S)),l(u),y(w,e),y(J,e),y(U,e),y(j,e),y(v,e),y(W,e),y(B,e),y(R,e)}}}const Ce='{"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 Re(ue){return $e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends He{constructor(u){super(),ve(this,u,Re,Be,Ie,{})}}export{Ee as component};
