import{s as Ue,f as ie,n as je,o as Ie}from"../chunks/scheduler.37c15a92.js";import{S as ve,i as xe,g as i,s,r as B,A as Ge,h as c,f as l,c as o,j as Y,u as H,x as h,k as n,y as Ze,a,v as k,d as C,t as $,w as W}from"../chunks/index.2bf4358c.js";import{C as ce}from"../chunks/CodeBlock.4f5fc1ad.js";import{D as Be}from"../chunks/DocNotebookDropdown.d9dfeb24.js";import{H as re}from"../chunks/Heading.8ada512a.js";function He(me){let u,V,R,Q,g,N,M,X,y,pe="Để 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>.",E,b,F,d,ue='Để 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>.',_,J,he='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:',z,f,A,w,ge="Đoạn mã trên sẽ tạo ra giao diện bên dưới:",q,r,Me,L,T,ye='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.',P,U,D,j,be="Để 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.",K,I,de="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:",O,v,ee,m,Je,te,x,fe="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:",le,G,ae,p,we,ne,Z,Te="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!",se,S,oe;return g=new re({props:{title:"Tích hợp với Hugging Face Hub",local:"tích-hợp-với-hugging-face-hub",headingTag:"h1"}}),M=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/vi/chapter9/section5.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter9/section5.ipynb"}]}}),b=new re({props:{title:"Tải mô hình từ Hugging Face Hub",local:"tải-mô-hình-từ-hugging-face-hub",headingTag:"h3"}}),f=new ce({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQXRpdGxlJTIwJTNEJTIwJTIyR1BULUotNkIlMjIlMEFkZXNjcmlwdGlvbiUyMCUzRCUyMCUyMkdyYWRpbyUyMERlbW8lMjBmb3IlMjBHUFQtSiUyMDZCJTJDJTIwYSUyMHRyYW5zZm9ybWVyJTIwbW9kZWwlMjB0cmFpbmVkJTIwdXNpbmclMjBCZW4lMjBXYW5nJ3MlMjBNZXNoJTIwVHJhbnNmb3JtZXIlMjBKQVguJTIwJ0dQVC1KJyUyMHJlZmVycyUyMHRvJTIwdGhlJTIwY2xhc3MlMjBvZiUyMG1vZGVsJTJDJTIwd2hpbGUlMjAnNkInJTIwcmVwcmVzZW50cyUyMHRoZSUyMG51bWJlciUyMG9mJTIwdHJhaW5hYmxlJTIwcGFyYW1ldGVycy4lMjBUbyUyMHVzZSUyMGl0JTJDJTIwc2ltcGx5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MCUyMCUyMGlucHV0cyUzRGdyLlRleHRib3gobGluZXMlM0Q1JTJDJTIwbGFiZWwlM0QlMjJJbnB1dCUyMFRleHQlMjIpJTJDJTBBJTIwJTIwJTIwJTIwdGl0bGUlM0R0aXRsZSUyQyUwQSUyMCUyMCUyMCUyMGRlc2NyaXB0aW9uJTNEZGVzY3JpcHRpb24lMkMlMEElMjAlMjAlMjAlMjBhcnRpY2xlJTNEYXJ0aWNsZSUyQyUwQSUyMCUyMCUyMCUyMGV4YW1wbGVzJTNEZXhhbXBsZXMlMkMlMEElMjAlMjAlMjAlMjBlbmFibGVfcXVldWUlM0RUcnVlJTJDJTBBKS5sYXVuY2goKQ==",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 re({props:{title:"Tải từ Hugging Face Spaces",local:"tải-từ-hugging-face-spaces",headingTag:"h3"}}),v=new ce({props:{code:"Z3IuSW50ZXJmYWNlLmxvYWQoJTIyc3BhY2VzJTJGYWJpZGxhYnMlMkZyZW1vdmUtYmclMjIpLmxhdW5jaCgp",highlighted:'gr.Interface.load(<span class="hljs-string">&quot;spaces/abidlabs/remove-bg&quot;</span>).launch()',wrap:!1}}),G=new ce({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"),V=s(),R=i("p"),Q=s(),B(g.$$.fragment),N=s(),B(M.$$.fragment),X=s(),y=i("p"),y.innerHTML=pe,E=s(),B(b.$$.fragment),F=s(),d=i("p"),d.innerHTML=ue,_=s(),J=i("p"),J.innerHTML=he,z=s(),B(f.$$.fragment),A=s(),w=i("p"),w.textContent=ge,q=s(),r=i("iframe"),L=s(),T=i("p"),T.innerHTML=ye,P=s(),B(U.$$.fragment),D=s(),j=i("p"),j.innerHTML=be,K=s(),I=i("p"),I.textContent=de,O=s(),B(v.$$.fragment),ee=s(),m=i("iframe"),te=s(),x=i("p"),x.textContent=fe,le=s(),B(G.$$.fragment),ae=s(),p=i("iframe"),ne=s(),Z=i("p"),Z.innerHTML=Te,se=s(),S=i("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);u=c(t,"META",{name:!0,content:!0}),t.forEach(l),V=o(e),R=c(e,"P",{}),Y(R).forEach(l),Q=o(e),H(g.$$.fragment,e),N=o(e),H(M.$$.fragment,e),X=o(e),y=c(e,"P",{"data-svelte-h":!0}),h(y)!=="svelte-1680xok"&&(y.innerHTML=pe),E=o(e),H(b.$$.fragment,e),F=o(e),d=c(e,"P",{"data-svelte-h":!0}),h(d)!=="svelte-1hvmj49"&&(d.innerHTML=ue),_=o(e),J=c(e,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1t5ceka"&&(J.innerHTML=he),z=o(e),H(f.$$.fragment,e),A=o(e),w=c(e,"P",{"data-svelte-h":!0}),h(w)!=="svelte-1mjuzk9"&&(w.textContent=ge),q=o(e),r=c(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),Y(r).forEach(l),L=o(e),T=c(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-limtsn"&&(T.innerHTML=ye),P=o(e),H(U.$$.fragment,e),D=o(e),j=c(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-kb44nt"&&(j.innerHTML=be),K=o(e),I=c(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-x9x8bs"&&(I.textContent=de),O=o(e),H(v.$$.fragment,e),ee=o(e),m=c(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),Y(m).forEach(l),te=o(e),x=c(e,"P",{"data-svelte-h":!0}),h(x)!=="svelte-5aorvr"&&(x.textContent=fe),le=o(e),H(G.$$.fragment,e),ae=o(e),p=c(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),Y(p).forEach(l),ne=o(e),Z=c(e,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-1mg6fft"&&(Z.innerHTML=Te),se=o(e),S=c(e,"P",{}),Y(S).forEach(l),this.h()},h(){n(u,"name","hf:doc:metadata"),n(u,"content",ke),ie(r.src,Me="https://course-demos-gpt-j-6B.hf.space")||n(r,"src",Me),n(r,"frameborder","0"),n(r,"height","750"),n(r,"title","Gradio app"),n(r,"class","container p-0 flex-grow space-iframe"),n(r,"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(r,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),ie(m.src,Je="https://course-demos-remove-bg-original.hf.space")||n(m,"src",Je),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"),ie(p.src,we="https://course-demos-Remove-bg.hf.space")||n(p,"src",we),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){Ze(document.head,u),a(e,V,t),a(e,R,t),a(e,Q,t),k(g,e,t),a(e,N,t),k(M,e,t),a(e,X,t),a(e,y,t),a(e,E,t),k(b,e,t),a(e,F,t),a(e,d,t),a(e,_,t),a(e,J,t),a(e,z,t),k(f,e,t),a(e,A,t),a(e,w,t),a(e,q,t),a(e,r,t),a(e,L,t),a(e,T,t),a(e,P,t),k(U,e,t),a(e,D,t),a(e,j,t),a(e,K,t),a(e,I,t),a(e,O,t),k(v,e,t),a(e,ee,t),a(e,m,t),a(e,te,t),a(e,x,t),a(e,le,t),k(G,e,t),a(e,ae,t),a(e,p,t),a(e,ne,t),a(e,Z,t),a(e,se,t),a(e,S,t),oe=!0},p:je,i(e){oe||(C(g.$$.fragment,e),C(M.$$.fragment,e),C(b.$$.fragment,e),C(f.$$.fragment,e),C(U.$$.fragment,e),C(v.$$.fragment,e),C(G.$$.fragment,e),oe=!0)},o(e){$(g.$$.fragment,e),$(M.$$.fragment,e),$(b.$$.fragment,e),$(f.$$.fragment,e),$(U.$$.fragment,e),$(v.$$.fragment,e),$(G.$$.fragment,e),oe=!1},d(e){e&&(l(V),l(R),l(Q),l(N),l(X),l(y),l(E),l(F),l(d),l(_),l(J),l(z),l(A),l(w),l(q),l(r),l(L),l(T),l(P),l(D),l(j),l(K),l(I),l(O),l(ee),l(m),l(te),l(x),l(le),l(ae),l(p),l(ne),l(Z),l(se),l(S)),l(u),W(g,e),W(M,e),W(b,e),W(f,e),W(U,e),W(v,e),W(G,e)}}}const ke='{"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 Ce(me){return Ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends ve{constructor(u){super(),xe(this,u,Ce,He,Ue,{})}}export{Ve as component};
