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