import{s as Ue,f as ie,n as je,o as Ie}from"../chunks/scheduler.37c15a92.js";import{S as xe,i as Ge,g as i,s as o,r as B,A as Ze,h as r,f as l,c as n,j as V,u as H,x as M,k as s,y as ve,a,v as C,d as $,t as W,w as k}from"../chunks/index.2bf4358c.js";import{C as re}from"../chunks/CodeBlock.4f5fc1ad.js";import{D as Be}from"../chunks/DocNotebookDropdown.d9dfeb24.js";import{H as ce}from"../chunks/Heading.8ada512a.js";function He(pe){let u,Q,R,S,g,N,y,X,J,me="為了讓你的生活更輕鬆, Gradio 直接與 Hugging Face Hub 和 Hugging Face Spaces 集成。你可以僅使用 <em>一行代碼</em> 從中心和空間加載演示。",E,f,F,h,ue='首先, 從 Hugging Face 通過 Hub 提供的數千個模型中選擇一個, 如 <a href="/course/chapter4/2">第四章</a> 中所述。',_,d,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>構建演示的代碼, 添加幾個示例輸入:',A,b,z,w,ge="上述代碼將生成以下界面:",q,c,ye,L,T,Je='以這種方式加載模型使用 Hugging Face 的 <a href="https://huggingface.co/inference-api" rel="nofollow">Inference API</a>,而不是將模型加載到內存中。這對於像 GPT-J 或 T0pp這樣需要大量 RAM 的大型模型是理想的。',P,U,D,j,fe="要從hugs Face Hub加載任何空間並在本地重新創建它, 你可以將 <code>spaces/</code> 傳遞給 <code>Interface</code>, 再加上空間的名稱。",K,I,he="還記得第 1 節中刪除圖像背景的演示嗎? 讓我們從 Hugging Face Spaces 加載它:",O,x,ee,p,de,te,G,be="從Hub或Spaces加載演示的一個很酷的地方是, 你可以通過覆蓋任何參數來自定義它們。在這裡, 我們添加一個標題並讓它與網絡攝像頭一起使用:",le,Z,ae,m,we,se,v,Te="現在我們已經探索了幾種將Gradio與hugs Face Hub集成的方法, 讓我們來看看 <code>Interface</code> 類的一些高級功能。這就是下一節的主題！",oe,Y,ne;return g=new ce({props:{title:"與 Hugging Face Hub 整合",local:"與-hugging-face-hub-整合",headingTag:"h1"}}),y=new Be({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter9/section5.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter9/section5.ipynb"}]}}),f=new ce({props:{title:"從 Hugging Face Hub 加載模型",local:"從-hugging-face-hub-加載模型",headingTag:"h3"}}),b=new re({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQXRpdGxlJTIwJTNEJTIwJTIyR1BULUotNkIlMjIlMEFkZXNjcmlwdGlvbiUyMCUzRCUyMCUyMkdyYWRpbyUyMERlbW8lMjBmb3IlMjBHUFQtSiUyMDZCJTJDJTIwYSUyMHRyYW5zZm9ybWVyJTIwbW9kZWwlMjB0cmFpbmVkJTIwdXNpbmclMjBCZW4lMjBXYW5nJ3MlMjBNZXNoJTIwVHJhbnNmb3JtZXIlMjBKQVguJTIwJ0dQVC1KJyUyMHJlZmVycyUyMHRvJTIwdGhlJTIwY2xhc3MlMjBvZiUyMG1vZGVsJTJDJTIwd2hpbGUlMjAnNkInJTIwcmVwcmVzZW50cyUyMHRoZSUyMG51bWJlciUyMG9mJTIwdHJhaW5hYmxlJTIwcGFyYW1ldGVycy4lMjBUbyUyMHVzZSUyMGl0JTJDJTIwc2ltcGx5JTIwYWRkJTIweW91ciUyMHRleHQlMkMlMjBvciUyMGNsaWNrJTIwb25lJTIwb2YlMjB0aGUlMjBleGFtcGxlcyUyMHRvJTIwbG9hZCUyMHRoZW0uJTIwUmVhZCUyMG1vcmUlMjBhdCUyMHRoZSUyMGxpbmtzJTIwYmVsb3cuJTIyJTBBYXJ0aWNsZSUyMCUzRCUyMCUyMiUzQ3AlMjBzdHlsZ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Y2xlJTNEYXJ0aWNsZSUyQyUwQSUyMCUyMCUyMCUyMGV4YW1wbGVzJTNEZXhhbXBsZXMlMkMlMEElMjAlMjAlMjAlMjBlbmFibGVfcXVldWUlM0RUcnVlJTJDJTBBKS5sYXVuY2goKQ==",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>
examples = [
    [<span class="hljs-string">&quot;The tower is 324 metres (1,063 ft) tall,&quot;</span>],
    [<span class="hljs-string">&quot;The Moon&#x27;s orbit around Earth has&quot;</span>],
    [<span class="hljs-string">&quot;The smooth Borealis basin in the Northern Hemisphere covers 40%&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,
    examples=examples,
    enable_queue=<span class="hljs-literal">True</span>,
).launch()`,wrap:!1}}),U=new ce({props:{title:"從 Hugging Face Spaces 空間加載",local:"從-hugging-face-spaces-空間加載",headingTag:"h3"}}),x=new re({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIpLmxhdW5jaCgp",highlighted:'gr.Interface.load(<span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>).launch()',wrap:!1}}),Z=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"),Q=o(),R=i("p"),S=o(),B(g.$$.fragment),N=o(),B(y.$$.fragment),X=o(),J=i("p"),J.innerHTML=me,E=o(),B(f.$$.fragment),F=o(),h=i("p"),h.innerHTML=ue,_=o(),d=i("p"),d.innerHTML=Me,A=o(),B(b.$$.fragment),z=o(),w=i("p"),w.textContent=ge,q=o(),c=i("iframe"),L=o(),T=i("p"),T.innerHTML=Je,P=o(),B(U.$$.fragment),D=o(),j=i("p"),j.innerHTML=fe,K=o(),I=i("p"),I.textContent=he,O=o(),B(x.$$.fragment),ee=o(),p=i("iframe"),te=o(),G=i("p"),G.textContent=be,le=o(),B(Z.$$.fragment),ae=o(),m=i("iframe"),se=o(),v=i("p"),v.innerHTML=Te,oe=o(),Y=i("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(l),Q=n(e),R=r(e,"P",{}),V(R).forEach(l),S=n(e),H(g.$$.fragment,e),N=n(e),H(y.$$.fragment,e),X=n(e),J=r(e,"P",{"data-svelte-h":!0}),M(J)!=="svelte-pi5nrq"&&(J.innerHTML=me),E=n(e),H(f.$$.fragment,e),F=n(e),h=r(e,"P",{"data-svelte-h":!0}),M(h)!=="svelte-1nyj3v3"&&(h.innerHTML=ue),_=n(e),d=r(e,"P",{"data-svelte-h":!0}),M(d)!=="svelte-1yyrm88"&&(d.innerHTML=Me),A=n(e),H(b.$$.fragment,e),z=n(e),w=r(e,"P",{"data-svelte-h":!0}),M(w)!=="svelte-1rnenil"&&(w.textContent=ge),q=n(e),c=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(c).forEach(l),L=n(e),T=r(e,"P",{"data-svelte-h":!0}),M(T)!=="svelte-1lih2u2"&&(T.innerHTML=Je),P=n(e),H(U.$$.fragment,e),D=n(e),j=r(e,"P",{"data-svelte-h":!0}),M(j)!=="svelte-1wgfb6m"&&(j.innerHTML=fe),K=n(e),I=r(e,"P",{"data-svelte-h":!0}),M(I)!=="svelte-n133xu"&&(I.textContent=he),O=n(e),H(x.$$.fragment,e),ee=n(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(p).forEach(l),te=n(e),G=r(e,"P",{"data-svelte-h":!0}),M(G)!=="svelte-1nr7jv2"&&(G.textContent=be),le=n(e),H(Z.$$.fragment,e),ae=n(e),m=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(m).forEach(l),se=n(e),v=r(e,"P",{"data-svelte-h":!0}),M(v)!=="svelte-37gjek"&&(v.innerHTML=Te),oe=n(e),Y=r(e,"P",{}),V(Y).forEach(l),this.h()},h(){s(u,"name","hf:doc:metadata"),s(u,"content",Ce),ie(c.src,ye="https://course-demos-gpt-j-6B.hf.space")||s(c,"src",ye),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(p.src,de="https://course-demos-remove-bg-original.hf.space")||s(p,"src",de),s(p,"frameborder","0"),s(p,"height","650"),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"),ie(m.src,we="https://course-demos-Remove-bg.hf.space")||s(m,"src",we),s(m,"frameborder","0"),s(m,"height","550"),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")},m(e,t){ve(document.head,u),a(e,Q,t),a(e,R,t),a(e,S,t),C(g,e,t),a(e,N,t),C(y,e,t),a(e,X,t),a(e,J,t),a(e,E,t),C(f,e,t),a(e,F,t),a(e,h,t),a(e,_,t),a(e,d,t),a(e,A,t),C(b,e,t),a(e,z,t),a(e,w,t),a(e,q,t),a(e,c,t),a(e,L,t),a(e,T,t),a(e,P,t),C(U,e,t),a(e,D,t),a(e,j,t),a(e,K,t),a(e,I,t),a(e,O,t),C(x,e,t),a(e,ee,t),a(e,p,t),a(e,te,t),a(e,G,t),a(e,le,t),C(Z,e,t),a(e,ae,t),a(e,m,t),a(e,se,t),a(e,v,t),a(e,oe,t),a(e,Y,t),ne=!0},p:je,i(e){ne||($(g.$$.fragment,e),$(y.$$.fragment,e),$(f.$$.fragment,e),$(b.$$.fragment,e),$(U.$$.fragment,e),$(x.$$.fragment,e),$(Z.$$.fragment,e),ne=!0)},o(e){W(g.$$.fragment,e),W(y.$$.fragment,e),W(f.$$.fragment,e),W(b.$$.fragment,e),W(U.$$.fragment,e),W(x.$$.fragment,e),W(Z.$$.fragment,e),ne=!1},d(e){e&&(l(Q),l(R),l(S),l(N),l(X),l(J),l(E),l(F),l(h),l(_),l(d),l(A),l(z),l(w),l(q),l(c),l(L),l(T),l(P),l(D),l(j),l(K),l(I),l(O),l(ee),l(p),l(te),l(G),l(le),l(ae),l(m),l(se),l(v),l(oe),l(Y)),l(u),k(g,e),k(y,e),k(f,e),k(b,e),k(U,e),k(x,e),k(Z,e)}}}const Ce='{"title":"與 Hugging Face Hub 整合","local":"與-hugging-face-hub-整合","sections":[{"title":"從 Hugging Face Hub 加載模型","local":"從-hugging-face-hub-加載模型","sections":[],"depth":3},{"title":"從 Hugging Face Spaces 空間加載","local":"從-hugging-face-spaces-空間加載","sections":[],"depth":3}],"depth":1}';function $e(pe){return Ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends xe{constructor(u){super(),Ge(this,u,$e,He,Ue,{})}}export{Qe as component};
