import{s as Ie,f as ce,n as ve,o as xe}from"../chunks/scheduler.37c15a92.js";import{S as Ge,i as Ze,g as i,s,r as g,A as Be,h as r,f as l,c as o,j as V,u as M,x as h,k as n,y as $e,a,v as y,d as b,t as d,w as f}from"../chunks/index.2bf4358c.js";import{C as me}from"../chunks/CodeBlock.4e987730.js";import{D as He}from"../chunks/DocNotebookDropdown.efc1fb7c.js";import{H as pe,E as ke}from"../chunks/getInferenceSnippets.8b9eb92a.js";function Ce(ue){let u,Q,S,E,J,N,w,X,T,he="Để làm cho cuộc sống của bạn trở nên dễ dàng hơn, Gradio tích hợp trực tiếp với Hugging Face Hub và Hugging Face Spaces. Bạn có thể tải các bản demo từ Hub và Spaces chỉ với <em>một dòng mã</em>.",F,U,_,j,ge='Để bắt đầu, hãy chọn một trong số hàng nghìn mô hình Hugging Face được cung cấp thông qua Hub, như được mô tả trong <a href="/course/chapter4/2">Chương 4</a>.',z,I,Me='Sử dụng phương thức <code>Interface.load()</code> đặc biệt, bạn truyền <code>&quot;model/&quot;</code> (hoặc, tương đương, <code>&quot;huggingface/&quot;</code>) theo sau là tên mô hình. Ví dụ: đây là mã để tạo bản demo cho <a href="https://huggingface.co/EleutherAI/gpt-j-6B" rel="nofollow">GPT-J</a>, một mô hình ngôn ngữ lớn, hãy thêm một số đầu vào mẫu:',A,v,q,x,ye="Đoạn mã trên sẽ tạo ra giao diện bên dưới:",L,c,be,P,G,de='Tải mô hình theo cách này sử dụng <a href="https://huggingface.co/inference-api" rel="nofollow">API luận suy</a> của Hugging Face, thay vì tải mô hình trong bộ nhớ. Điều này lý tưởng cho các mô hình lớn như GPT-J hoặc T0pp, những mô hình yêu cầu nhiều RAM.',D,Z,K,B,fe="Để tải bất kỳ Space nào từ Hugging Face Hub và tạo lại nó cục bộ, bạn có thể truyền  <code>spaces/</code> vào <code>Interface</code>, theo sau là tên của Space.",O,$,Je="Bạn có nhớ bản demo từ phần 1 xóa nền của hình ảnh không? Hãy tải nó từ Hugging Face Spaces:",ee,H,te,m,we,le,k,Te="Một trong những điều thú vị khi tải các bản demo từ Hub hoặc Spaces là bạn tùy chỉnh chúng bằng cách ghi đè bất kỳ thông số nào. Ở đây, chúng ta thêm tiêu đề và làm cho tiêu đề đó hoạt động với webcam:",ae,C,ne,p,Ue,se,W,je="Bây giờ chúng ta đã khám phá một số cách để tích hợp Gradio với Hugging Face Hub, hãy cùng xem xét một số tính năng nâng cao của lớp <code>Interface</code>. Đó là chủ đề của phần tiếp theo!",oe,R,ie,Y,re;return J=new pe({props:{title:"Tích hợp với Hugging Face Hub",local:"tích-hợp-với-hugging-face-hub",headingTag:"h1"}}),w=new He({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/vi/chapter9/section5.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter9/section5.ipynb"}]}}),U=new pe({props:{title:"Tải mô hình từ Hugging Face Hub",local:"tải-mô-hình-từ-hugging-face-hub",headingTag:"h3"}}),v=new me({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQXRpdGxlJTIwJTNEJTIwJTIyR1BULUotNkIlMjIlMEFkZXNjcmlwdGlvbiUyMCUzRCUyMCUyMkdyYWRpbyUyMERlbW8lMjBmb3IlMjBHUFQtSiUyMDZCJTJDJTIwYSUyMHRyYW5zZm9ybWVyJTIwbW9kZWwlMjB0cmFpbmVkJTIwdXNpbmclMjBCZW4lMjBXYW5nJ3MlMjBNZXNoJTIwVHJhbnNmb3JtZXIlMjBKQVguJTIwJ0dQVC1KJyUyMHJlZmVycyUyMHRvJTIwdGhlJTIwY2xhc3MlMjBvZiUyMG1vZGVsJTJDJTIwd2hpbGUlMjAnNkInJTIwcmVwcmVzZW50cyUyMHRoZSUyMG51bWJlciUyMG9mJTIwdHJhaW5hYmxlJTIwcGFyYW1ldGVycy4lMjBUbyUyMHVzZSUyMGl0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MiUyQyUwQSUyMCUyMCUyMCUyMGlucHV0cyUzRGdyLlRleHRib3gobGluZXMlM0Q1JTJDJTIwbGFiZWwlM0QlMjJJbnB1dCUyMFRleHQlMjIpJTJDJTBBJTIwJTIwJTIwJTIwdGl0bGUlM0R0aXRsZSUyQyUwQSUyMCUyMCUyMCUyMGRlc2NyaXB0aW9uJTNEZGVzY3JpcHRpb24lMkMlMEElMjAlMjAlMjAlMjBhcnRpY2xlJTNEYXJ0aWNsZSUyQyUwQSUyMCUyMCUyMCUyMGV4YW1wbGVzJTNEZXhhbXBsZXMlMkMlMEElMjAlMjAlMjAlMjBlbmFibGVfcXVldWUlM0RUcnVlJTJDJTBBKS5sYXVuY2goKQ==",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}}),Z=new pe({props:{title:"Tải từ Hugging Face Spaces",local:"tải-từ-hugging-face-spaces",headingTag:"h3"}}),H=new me({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIpLmxhdW5jaCgp",highlighted:'gr.Interface.load(<span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>).launch()',wrap:!1}}),C=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/vi/chapter9/5.mdx"}}),{c(){u=i("meta"),Q=s(),S=i("p"),E=s(),g(J.$$.fragment),N=s(),g(w.$$.fragment),X=s(),T=i("p"),T.innerHTML=he,F=s(),g(U.$$.fragment),_=s(),j=i("p"),j.innerHTML=ge,z=s(),I=i("p"),I.innerHTML=Me,A=s(),g(v.$$.fragment),q=s(),x=i("p"),x.textContent=ye,L=s(),c=i("iframe"),P=s(),G=i("p"),G.innerHTML=de,D=s(),g(Z.$$.fragment),K=s(),B=i("p"),B.innerHTML=fe,O=s(),$=i("p"),$.textContent=Je,ee=s(),g(H.$$.fragment),te=s(),m=i("iframe"),le=s(),k=i("p"),k.textContent=Te,ae=s(),g(C.$$.fragment),ne=s(),p=i("iframe"),se=s(),W=i("p"),W.innerHTML=je,oe=s(),g(R.$$.fragment),ie=s(),Y=i("p"),this.h()},l(e){const t=Be("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(l),Q=o(e),S=r(e,"P",{}),V(S).forEach(l),E=o(e),M(J.$$.fragment,e),N=o(e),M(w.$$.fragment,e),X=o(e),T=r(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-1680xok"&&(T.innerHTML=he),F=o(e),M(U.$$.fragment,e),_=o(e),j=r(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1hvmj49"&&(j.innerHTML=ge),z=o(e),I=r(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-1t5ceka"&&(I.innerHTML=Me),A=o(e),M(v.$$.fragment,e),q=o(e),x=r(e,"P",{"data-svelte-h":!0}),h(x)!=="svelte-1mjuzk9"&&(x.textContent=ye),L=o(e),c=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(c).forEach(l),P=o(e),G=r(e,"P",{"data-svelte-h":!0}),h(G)!=="svelte-limtsn"&&(G.innerHTML=de),D=o(e),M(Z.$$.fragment,e),K=o(e),B=r(e,"P",{"data-svelte-h":!0}),h(B)!=="svelte-kb44nt"&&(B.innerHTML=fe),O=o(e),$=r(e,"P",{"data-svelte-h":!0}),h($)!=="svelte-x9x8bs"&&($.textContent=Je),ee=o(e),M(H.$$.fragment,e),te=o(e),m=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(m).forEach(l),le=o(e),k=r(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-5aorvr"&&(k.textContent=Te),ae=o(e),M(C.$$.fragment,e),ne=o(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),V(p).forEach(l),se=o(e),W=r(e,"P",{"data-svelte-h":!0}),h(W)!=="svelte-1mg6fft"&&(W.innerHTML=je),oe=o(e),M(R.$$.fragment,e),ie=o(e),Y=r(e,"P",{}),V(Y).forEach(l),this.h()},h(){n(u,"name","hf:doc:metadata"),n(u,"content",We),ce(c.src,be="https://course-demos-gpt-j-6B.hf.space")||n(c,"src",be),n(c,"frameborder","0"),n(c,"height","750"),n(c,"title","Gradio app"),n(c,"class","container p-0 flex-grow space-iframe"),n(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"),n(c,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),ce(m.src,we="https://course-demos-remove-bg-original.hf.space")||n(m,"src",we),n(m,"frameborder","0"),n(m,"height","650"),n(m,"title","Gradio app"),n(m,"class","container p-0 flex-grow space-iframe"),n(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"),n(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")||n(p,"src",Ue),n(p,"frameborder","0"),n(p,"height","550"),n(p,"title","Gradio app"),n(p,"class","container p-0 flex-grow space-iframe"),n(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"),n(p,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads")},m(e,t){$e(document.head,u),a(e,Q,t),a(e,S,t),a(e,E,t),y(J,e,t),a(e,N,t),y(w,e,t),a(e,X,t),a(e,T,t),a(e,F,t),y(U,e,t),a(e,_,t),a(e,j,t),a(e,z,t),a(e,I,t),a(e,A,t),y(v,e,t),a(e,q,t),a(e,x,t),a(e,L,t),a(e,c,t),a(e,P,t),a(e,G,t),a(e,D,t),y(Z,e,t),a(e,K,t),a(e,B,t),a(e,O,t),a(e,$,t),a(e,ee,t),y(H,e,t),a(e,te,t),a(e,m,t),a(e,le,t),a(e,k,t),a(e,ae,t),y(C,e,t),a(e,ne,t),a(e,p,t),a(e,se,t),a(e,W,t),a(e,oe,t),y(R,e,t),a(e,ie,t),a(e,Y,t),re=!0},p:ve,i(e){re||(b(J.$$.fragment,e),b(w.$$.fragment,e),b(U.$$.fragment,e),b(v.$$.fragment,e),b(Z.$$.fragment,e),b(H.$$.fragment,e),b(C.$$.fragment,e),b(R.$$.fragment,e),re=!0)},o(e){d(J.$$.fragment,e),d(w.$$.fragment,e),d(U.$$.fragment,e),d(v.$$.fragment,e),d(Z.$$.fragment,e),d(H.$$.fragment,e),d(C.$$.fragment,e),d(R.$$.fragment,e),re=!1},d(e){e&&(l(Q),l(S),l(E),l(N),l(X),l(T),l(F),l(_),l(j),l(z),l(I),l(A),l(q),l(x),l(L),l(c),l(P),l(G),l(D),l(K),l(B),l(O),l($),l(ee),l(te),l(m),l(le),l(k),l(ae),l(ne),l(p),l(se),l(W),l(oe),l(ie),l(Y)),l(u),f(J,e),f(w,e),f(U,e),f(v,e),f(Z,e),f(H,e),f(C,e),f(R,e)}}}const We='{"title":"Tích hợp với Hugging Face Hub","local":"tích-hợp-với-hugging-face-hub","sections":[{"title":"Tải mô hình từ Hugging Face Hub","local":"tải-mô-hình-từ-hugging-face-hub","sections":[],"depth":3},{"title":"Tải từ Hugging Face Spaces","local":"tải-từ-hugging-face-spaces","sections":[],"depth":3}],"depth":1}';function Re(ue){return xe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ne extends Ge{constructor(u){super(),Ze(this,u,Re,Ce,Ie,{})}}export{Ne as component};
