model-pulse / assets /Wrapped-CpoCw_9A.js
tardellirs's picture
Update site
cad84dd verified
Raw History Blame Contribute Delete
19.2 kB
import{d as $,A as te,h as U,i as ne,u as e,c as j,s as le,b as y,n as L,f,a as z,L as oe,S as w,j as Y,k as K}from"./index-iljbJvME.js";const b=s=>s.kind==="datasets",S=(s,l=2)=>(b(s)?"dataset":"model")+(l===1?"":"s"),ae=["zero","one","two","three","four","five","six","seven","eight","nine"],N=s=>s.replace(/-/g," "),re=()=>matchMedia("(prefers-reduced-motion: reduce)").matches;function D({to:s,run:l,format:n=f}){const[i,t]=$(0);return U(()=>{if(!l){t(0);return}if(re()){t(s);return}let r=0;const d=performance.now(),k=1300,m=_=>{const o=Math.min(1,(_-d)/k);t(s*(1-Math.pow(1-o,3))),o<1&&(r=requestAnimationFrame(m))};return r=requestAnimationFrame(m),()=>cancelAnimationFrame(r)},[s,l]),e(w,{children:n(Math.round(i))})}const V=s=>{if(s.every_seconds>=1){const l=s.every_seconds;return l<60?`one download every ${l.toFixed(l<10?1:0)} seconds`:l<3600?`one download every ${Math.round(l/60)} minutes`:`one download every ${Math.round(l/3600)} hours`}return s.per_minute>=1e3?`${y(s.per_minute)} downloads every minute`:`${Math.round(s.per_minute)} downloads every minute`},A=s=>s.split("/").slice(1).join("/")||s,X=["#ffd21e","#fbfaf5","#ff8a1f","#3fd08a","#7fb1ff"],ie=s=>{const l=s.tasks;if(!l||!l.top.length||!l.total_30d)return null;const n=l.top.reduce((t,r)=>t+r.downloads_30d,0);return n/l.total_30d<.3?null:{rows:l.top.map((t,r)=>({...t,share:t.downloads_30d/n,color:X[r%X.length]})),untagged:1-n/l.total_30d}},O=s=>s.downloads_all&&s.downloads_all>s.downloads?s.downloads_all:null,I=s=>s.rank<=10?"top 10":s.rank<=100?"top 100":s.rank<=1e3?"top 1,000":s.top_pct==null||s.top_pct>50?null:`top ${s.top_pct<1?s.top_pct.toFixed(1):Math.ceil(s.top_pct)}%`,ee=s=>{const l=new Date(s.period.to.slice(0,7)+"-01T00:00:00Z"),n=new Map(s.months.map(i=>[i.month.slice(0,7),i.downloads]));return Array.from({length:12},(i,t)=>{const d=new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth()-12+t,1)).toISOString().slice(0,7);return{month:d,downloads:n.get(d)??0}})},H=s=>`${Y(s.period.from,{month:"short",year:"numeric"})} – ${Y(s.period.to,{month:"short",year:"numeric"})}`;function J({values:s,highlight:l,light:n}){const i=Math.max(...s,1);return e("div",{class:`w-bars${n?" light":""}`,"aria-hidden":"true",children:s.map((t,r)=>e("span",{class:r===l?"hi":"",style:{height:`${Math.max(3,t/i*100)}%`}},r))})}function Q(s,l){const n=o=>l===o,i=b(s)?ie(s):null,t=["intro","downloads","top",...i?["mix"]:[],"week","ripple","rank"],r=o=>t.indexOf(o),d=t.length,k=s.weeks.map(o=>o.downloads),m=s.best_week?s.weeks.findIndex(o=>o.week_of===s.best_week.week_of):-1;return[{key:"intro",tone:"yellow",body:e(w,{children:[e("div",{class:"w-kicker",children:["Model Pulse Wrapped",b(s)&&e("span",{class:"w-edition",children:"datasets"})]}),e("div",{class:"w-logo",children:e(j,{size:88})}),e("h2",{class:"w-title",children:[e("span",{class:"w-name",style:se(s.author),children:s.author}),e("br",{}),"on the Hub"]}),e("p",{class:"w-sub",children:[b(s)?"Your datasets' last 12 months":"Your last 12 months",", in ",ae[d]??d," cards."]}),e("p",{class:"w-mono",children:H(s)})]})},{key:"downloads",tone:"blue",body:e(w,{children:[e("div",{class:"w-kicker",children:["Your ",S(s)," were downloaded"]}),O(s)?e(w,{children:[e("div",{class:"w-big",children:e(D,{to:O(s),run:n(1)})}),e("p",{class:"w-sub",children:["times in total. ",y(s.downloads)," of them in the last 12 months: ",V(s),"."]})]}):e(w,{children:[e("div",{class:"w-big",children:e(D,{to:s.downloads,run:n(1)})}),e("p",{class:"w-sub",children:["times. That's ",V(s),"."]})]}),e(J,{values:ee(s).map(o=>o.downloads),light:!0}),e("p",{class:"w-mono",children:O(s)?"last 12 months, by month":"downloads by month"})]})},{key:"top",tone:"paper",body:s.top_model?e(w,{children:[e("div",{class:"w-kicker",children:["Your #1 ",S(s,1)," this year"]}),e("h2",{class:"w-model",children:e("span",{children:A(s.top_model.id)})}),e("div",{class:"w-big sm",children:[e(D,{to:s.top_model.downloads,run:n(2),format:y})," ",e("small",{children:"downloads"})]}),e("p",{class:"w-sub",children:[Math.round(s.top_model.share*100),"% of everything you served",s.top_model.task?`, as ${N(s.top_model.task)}`:"","."]}),s.top_models.length>1&&e("ol",{class:"w-list",start:2,children:s.top_models.slice(1,5).map(o=>e("li",{children:[e("span",{children:A(o.id)}),e("b",{children:y(o.downloads)})]},o.id))})]}):e("p",{class:"w-sub",children:["No single ",S(s,1)," stood out this year."]})},...i?[{key:"mix",tone:"purple",body:e(w,{children:[e("div",{class:"w-kicker",children:"What your data is for"}),e("h2",{class:"w-title sm",children:i.rows[0].share>=.5?e(w,{children:["Mostly ",e("span",{class:"w-hl",children:N(i.rows[0].task)})]}):e(w,{children:["A bit of ",e("span",{class:"w-hl",children:"everything"})]})}),e("div",{class:`w-mix${n(3)?" run":""}`,"aria-hidden":"true",children:i.rows.map(o=>e("span",{style:{flexGrow:o.share,background:o.color}},o.task))}),e("ul",{class:"w-legend",children:i.rows.map(o=>e("li",{children:[e("i",{style:{background:o.color}}),e("span",{children:N(o.task)}),e("b",{children:[Math.round(o.share*100)||"<1","%"]}),e("small",{children:[f(o.datasets)," ",o.datasets===1?"dataset":"datasets"]})]},o.task))}),e("p",{class:"w-mono",children:["share of your downloads in the last 30 days, by task category",i.untagged>=.05?`. ${Math.round(i.untagged*100)}% come from datasets with no category`:""]})]})}]:[],{key:"week",tone:"orange",body:s.best_week?e(w,{children:[e("div",{class:"w-kicker",children:"Your biggest week"}),e("h2",{class:"w-title sm",children:["Week of ",Y(s.best_week.week_of,{month:"long",day:"numeric",year:"numeric"})]}),e("div",{class:"w-big",children:e(D,{to:s.best_week.downloads,run:n(r("week"))})}),e("p",{class:"w-sub",children:"downloads in seven days."}),e(J,{values:k,highlight:m})]}):e("p",{class:"w-sub",children:"Not enough weeks of data yet."})},b(s)?{key:"ripple",tone:"green",body:s.ripple.models>0||(s.ripple.spaces??0)>0?e(w,{children:[e("div",{class:"w-kicker",children:"Trained on your data"}),s.ripple.models>0?e(w,{children:[e("div",{class:"w-big",children:e(D,{to:s.ripple.models,run:n(r("ripple"))})}),e("p",{class:"w-sub",children:["model",s.ripple.models===1?"":"s"," by other people list",s.ripple.models===1?"s":""," your datasets as training data.",s.ripple.downloads_30d>0&&e(w,{children:[" ",s.ripple.models===1?"It was":"Together they were"," downloaded ",e("b",{children:y(s.ripple.downloads_30d)})," times last month."]})]}),s.ripple.top&&e("p",{class:"w-mono",children:[s.ripple.models>1?"the biggest: ":"",s.ripple.top.id,", trained on ",A(s.ripple.top.dataset??"")]}),(s.ripple.spaces??0)>0&&e("div",{class:"w-chips",children:e("span",{children:[f(s.ripple.spaces)," Space",s.ripple.spaces===1?"":"s"," use",s.ripple.spaces===1?"s":""," them too"]})})]}):e(w,{children:[e("div",{class:"w-big",children:e(D,{to:s.ripple.spaces,run:n(r("ripple"))})}),e("p",{class:"w-sub",children:["Space",s.ripple.spaces===1?"":"s"," by other people use",s.ripple.spaces===1?"s":""," your datasets. No model lists them as training data yet."]})]})]}):e(w,{children:[e("div",{class:"w-kicker",children:"Trained on your data"}),e("h2",{class:"w-title sm",children:"No models list it yet."}),e("p",{class:"w-sub",children:["When someone names one of your datasets in a model card's ",e("code",{children:"datasets:"})," field, that model shows up here. You published ",e("b",{children:s.models_new})," new dataset",s.models_new===1?"":"s"," this year; one of them could be next."]})]})}:{key:"ripple",tone:"green",body:s.ripple.models>0?e(w,{children:[e("div",{class:"w-kicker",children:"Your ripple effect"}),e("div",{class:"w-big",children:e(D,{to:s.ripple.models,run:n(r("ripple"))})}),e("p",{class:"w-sub",children:["models by other people build on yours. Together they were downloaded ",e("b",{children:y(s.ripple.downloads_30d)})," times last month."]}),s.ripple.top&&e("p",{class:"w-mono",children:["the biggest: ",s.ripple.top.id," (",s.ripple.top.relation,")"]})]}):e(w,{children:[e("div",{class:"w-kicker",children:"Your ripple effect"}),e("h2",{class:"w-title sm",children:"No derivatives yet."}),e("p",{class:"w-sub",children:["When someone quantizes or fine-tunes one of your models, it shows up here. You published ",e("b",{children:s.models_new})," new model",s.models_new===1?"":"s"," this year; one of them could be next."]})]})},{key:"rank",tone:"red",body:e(w,{children:[e("div",{class:"w-kicker",children:["Among ",f(s.authors_ranked)," ",b(s)?"dataset publishers":"publishers"," on the Hub"]}),e("div",{class:"w-big xl",children:["#",e(D,{to:s.rank,run:n(r("rank"))})]}),e("p",{class:"w-sub",children:I(s)?s.rank<=1e3?`A ${I(s)} ${b(s)?"dataset publisher":"publisher"} by downloads this year.`:`That's the ${I(s)} by downloads.`:"by downloads this year."}),e("div",{class:"w-chips",children:[e("span",{children:["+",f(s.likes_gained)," likes"]}),e("span",{children:[f(s.models_new)," new ",S(s,s.models_new)]}),e("span",{children:[f(s.models_total)," ",S(s,s.models_total)," in total"]})]})]})}]}async function ce(s){await Promise.all(["600 80px 'Fredoka'","500 20px 'IBM Plex Mono'","400 20px 'Source Sans 3'"].map(u=>document.fonts.load(u)));const l=1080,n=1350,i=document.createElement("canvas");i.width=l,i.height=n;const t=i.getContext("2d"),r="#1B1B1F",d="#ECE9E2",k="#FBFAF5",m="#FFD21E",_=(u,v,F,M,T)=>{t.fillStyle=r,t.beginPath(),t.roundRect(u+8,v+8,F,M,26),t.fill(),t.fillStyle=T,t.beginPath(),t.roundRect(u,v,F,M,26),t.fill(),t.lineWidth=4,t.strokeStyle=r,t.stroke()},o=(u,v,F,M,T=r,P)=>{if(t.font=M,t.fillStyle=T,P&&t.measureText(u).width>P){for(;u.length>3&&t.measureText(u+"…").width>P;)u=u.slice(0,-1);u+="…"}t.fillText(u,v,F)};t.fillStyle=d,t.fillRect(0,0,l,n),t.fillStyle=r,t.beginPath(),t.roundRect(68,68,76,76,20),t.fill(),t.fillStyle=m,t.beginPath(),t.roundRect(62,62,72,72,18),t.fill(),t.lineWidth=6,t.strokeStyle=r,t.stroke(),t.beginPath(),t.lineWidth=6,t.lineJoin="round",t.lineCap="round",t.moveTo(74,100),t.lineTo(87,100),t.lineTo(94,81),t.lineTo(106,117),t.lineTo(113,100),t.lineTo(124,100),t.stroke(),o("Model Pulse Wrapped",156,116,"600 44px 'Fredoka'"),o(b(s)?`datasets · ${H(s)}`:H(s),62,196,"500 26px 'IBM Plex Mono'","#6E6C66"),t.font="600 92px 'Fredoka'";const x=s.author.length>20?s.author.slice(0,19)+"…":s.author,a=Math.min(l-124,t.measureText(x).width+44);t.fillStyle=m,t.beginPath(),t.roundRect(54,222,a,120,18),t.fill(),o(x,76,314,"600 92px 'Fredoka'",r,l-170),_(62,386,l-124,250,"#3B6FF5"),o(b(s)?"dataset downloads in 12 months":"downloads in 12 months",100,446,"500 28px 'IBM Plex Mono'","#fff"),o(f(s.downloads),96,572,"600 118px 'Fredoka'","#fff",l-200);const p=[[`#1 ${S(s,1)}`,s.top_model?A(s.top_model.id):"–",s.top_model?`${y(s.top_model.downloads)} downloads`:""],["biggest week",s.best_week?y(s.best_week.downloads):"–",s.best_week?`week of ${Y(s.best_week.week_of,{month:"short",day:"numeric"})}`:""],["publisher rank",`#${f(s.rank)}`,I(s)??`of ${y(s.authors_ranked)}`],s.ripple.models>0?[b(s)?"trained on yours":"built on yours",f(s.ripple.models),"models by others"]:["published",f(s.models_new),`new ${S(s,s.models_new)} this year`]],g=(l-124-32)/2,C=230;p.forEach(([u,v,F],M)=>{const T=62+M%2*(g+32),P=676+Math.floor(M/2)*(C+32);_(T,P,g,C,M===0?m:k),o(u,T+30,P+54,"500 24px 'IBM Plex Mono'","#6E6C66"),o(v,T+28,P+136,`600 ${v.length>14?46:70}px 'Fredoka'`,r,g-56),o(F,T+30,P+190,"400 26px 'Source Sans 3'","#3D3D45",g-60)});const E=ee(s).map(u=>u.downloads),R=Math.max(...E,1),B=62,c=1196,h=l-124,W=64,q=6,G=(h-q*(E.length-1))/Math.max(1,E.length);return E.forEach((u,v)=>{const F=Math.max(4,u/R*W),M=B+v*(G+q);t.fillStyle=v===E.indexOf(R)?m:k,t.beginPath(),t.roundRect(M,c+W-F,G,F,4),t.fill(),t.lineWidth=3,t.strokeStyle=r,t.stroke()}),o("modelpulse.ifsp.dev",62,n-40,"500 24px 'IBM Plex Mono'","#6E6C66"),new Promise(u=>i.toBlob(v=>u(v),"image/png"))}function Z({initial:s}){const[l,n]=$(s??""),[i,t]=$([]),[r,d]=$(-1),[k,m]=$(!1);U(()=>{const a=l.trim().replace(/^https?:\/\/huggingface\.co\//,"").split("/")[0];if(a.length<2){t([]);return}let p=!0;const g=setTimeout(()=>K.searchAuthors(a).then(C=>{p&&(t(C),d(-1))}).catch(()=>{}),120);return()=>{p=!1,clearTimeout(g)}},[l]);const[_,o]=$(null);U(()=>{K.leaderboards().then(o).catch(()=>{})},[]);const x=a=>{const p=a.trim().replace(/^https?:\/\/huggingface\.co\//,"").split("/")[0];p&&L({view:"wrapped",author:p})};return e("div",{class:"wrap w-entry",children:[e("h1",{children:[e(j,{size:72}),"Model Pulse ",e("span",{class:"hl",children:"Wrapped"})]}),e("p",{class:"lede",children:"Your last 12 months on the Hugging Face Hub, for your models or your datasets: total downloads, your #1, your biggest week, the models built on yours (or trained on your data), and where you rank."}),e("form",{class:"w-form",onSubmit:a=>{a.preventDefault(),x(r>=0&&i[r]?i[r].author:l)},children:[e("div",{class:"search big",children:[e("input",{value:l,onInput:a=>{n(a.target.value),m(!0)},placeholder:"Username or org, e.g. Qwen","aria-label":"Username or organization",autoFocus:!0,spellcheck:!1,autocomplete:"off",role:"combobox","aria-expanded":k&&i.length>0,"aria-controls":"wrapped-results",onFocus:()=>m(!0),onBlur:()=>setTimeout(()=>m(!1),150),onKeyDown:a=>{a.key==="ArrowDown"?(a.preventDefault(),d(p=>Math.min(p+1,i.length-1))):a.key==="ArrowUp"?(a.preventDefault(),d(p=>Math.max(p-1,-1))):a.key==="Escape"&&m(!1)}}),k&&i.length>0&&e("ul",{class:"results",id:"wrapped-results",role:"listbox",children:i.map((a,p)=>e("li",{role:"option","aria-selected":p===r,onMouseEnter:()=>d(p),onMouseDown:g=>{g.preventDefault(),x(a.author)},children:[e("span",{class:"rid",children:a.author}),e("span",{class:"rmeta",children:[[a.models?`${f(a.models)} model${a.models===1?"":"s"}`:"",a.datasets?`${f(a.datasets)} dataset${a.datasets===1?"":"s"}`:""].filter(Boolean).join(" · ")," · ",y(a.dl30??0),"/mo"]})]},a.author))})]}),e("button",{class:"btn primary",type:"submit",children:"Get my Wrapped"})]}),_&&e("div",{class:"examples",children:[e("span",{class:"muted",children:"or try"}),_.authors_7d.slice(0,10).map(a=>e("a",{class:"chip",href:z({view:"wrapped",author:a.author}),onClick:p=>{p.preventDefault(),x(a.author)},children:a.author},a.author))]})]})}const se=s=>s.length>12?{fontSize:`${Math.max(.5,12/s.length).toFixed(2)}em`}:void 0;function he({author:s,kind:l}){var B;const[n,i]=$(null),[t,r]=$(null),[d,k]=$(0),[m,_]=$(!1),o=te(null);U(()=>{if(document.title=s?`${s}'s ${l==="datasets"?"datasets, the ":""}last 12 months on Hugging Face · Model Pulse Wrapped`:"Model Pulse Wrapped: your last 12 months on Hugging Face",i(null),r(null),k(0),!s)return;let c=!0;return fetch(`${ne}/api/wrapped/${encodeURIComponent(s)}${l?`?kind=${l}`:""}`).then(async h=>{const W=await h.json();if(!h.ok)throw new Error(W.detail||"Something went wrong");return W}).then(h=>{c&&i(h)}).catch(h=>{c&&r(h.message)}),()=>{c=!1}},[s,l]);const x=n?Q(n,d).length+1:0,a=()=>k(c=>Math.min(x-1,c+1)),p=()=>k(c=>Math.max(0,c-1));if(U(()=>{if(!n)return;const c=h=>{(h.key==="ArrowRight"||h.key===" ")&&(h.preventDefault(),a()),h.key==="ArrowLeft"&&p()};return addEventListener("keydown",c),()=>removeEventListener("keydown",c)},[n,x]),!s)return e(Z,{});if(t)return e("div",{class:"wrap w-entry",children:[e("h1",{class:"w-err",children:["No Wrapped for ",s," yet"]}),e("p",{class:"lede",children:t}),e(Z,{initial:""})]});if(!n)return e("div",{class:"wrap w-loading",children:[e(j,{size:64}),e("p",{children:["Crunching 12 months of ",l==="datasets"?"dataset ":"","downloads for ",e("b",{children:s}),"…"]})]});const g=Q(n,d),C=le({view:"wrapped",author:n.author,kind:b(n)?"datasets":void 0}),E=`${b(n)?"My datasets' last 12 months":"My last 12 months"} on the Hugging Face Hub: ${y(n.downloads)} downloads${I(n)&&(n.rank<=1e3||(n.top_pct??100)<=10)?`, ${I(n)} of publishers`:""}. Get your Model Pulse Wrapped:`,R=d===g.length;return e("div",{class:"wrap w-page",children:e("div",{class:"w-stage",ref:o,children:[(((B=n.kinds)==null?void 0:B.length)??0)>1&&e("div",{class:"w-kinds",children:e("div",{class:"seg",role:"group","aria-label":`${n.author}'s Wrapped for`,children:n.kinds.map(c=>e("button",{"aria-pressed":n.kind===c,onClick:()=>{n.kind!==c&&L({view:"wrapped",author:n.author,kind:c==="datasets"?"datasets":void 0})},children:c==="datasets"?"Datasets":"Models"},c))})}),e("div",{class:"w-progress","aria-hidden":"true",children:Array.from({length:x},(c,h)=>e("span",{class:h<d?"done":h===d?"now":""},h))}),R?e("div",{class:"w-card tone-paper w-summary",children:[e("div",{class:"w-kicker",children:H(n)}),e("h2",{class:"w-title sm",children:e("span",{class:"w-name",style:se(n.author),children:n.author})}),e("div",{class:"w-grid",children:[e("div",{class:"t blue",children:[e("span",{children:"downloads"}),e("b",{children:y(n.downloads)})]}),e("div",{class:"t",children:[e("span",{children:["#1 ",S(n,1)]}),e("b",{class:"s",children:n.top_model?A(n.top_model.id):"–"})]}),e("div",{class:"t",children:[e("span",{children:"biggest week"}),e("b",{children:n.best_week?y(n.best_week.downloads):"–"})]}),e("div",{class:"t yellow",children:[e("span",{children:b(n)?"dataset publisher rank":"publisher rank"}),e("b",{children:["#",f(n.rank)]})]}),n.ripple.models>0?e("div",{class:"t",children:[e("span",{children:b(n)?"trained on yours":"built on yours"}),e("b",{children:f(n.ripple.models)})]}):e("div",{class:"t",children:[e("span",{children:["new ",S(n)]}),e("b",{children:f(n.models_new)})]}),e("div",{class:"t",children:[e("span",{children:"likes gained"}),e("b",{children:["+",y(n.likes_gained)]})]})]}),e("div",{class:"w-actions",children:[e("button",{class:"btn primary",disabled:m,onClick:async()=>{_(!0);try{const c=await ce(n),h=document.createElement("a");h.href=URL.createObjectURL(c),h.download=`${n.author}${b(n)?"-datasets":""}-model-pulse-wrapped.png`,h.click(),setTimeout(()=>URL.revokeObjectURL(h.href),2e3)}finally{_(!1)}},children:m?"Drawing…":"Download image"}),e("a",{class:"btn",target:"_blank",rel:"noopener",href:`https://x.com/intent/post?text=${encodeURIComponent(E)}&url=${encodeURIComponent(C)}`,children:"Post on X"}),e("a",{class:"btn",target:"_blank",rel:"noopener",href:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(C)}`,children:"LinkedIn"}),e("button",{class:"btn",onClick:()=>{var c;return(c=navigator.clipboard)==null?void 0:c.writeText(C)},children:"Copy link"})]}),e("div",{class:"w-more",children:[e("a",{href:z({author:n.author}),onClick:c=>{c.preventDefault(),L({author:n.author})},children:["See ",n.author,"'s ",S(n)]}),e("a",{href:z({view:"wrapped"}),onClick:c=>{c.preventDefault(),L({view:"wrapped"})},children:"Try another name"})]}),e("div",{class:"w-like",children:e(oe,{})})]},"summary"):e("div",{class:`w-card tone-${g[d].tone}`,"aria-live":"polite",children:[g[d].body,e("button",{class:"w-tap left","aria-label":"Previous card",onClick:p}),e("button",{class:"w-tap right","aria-label":"Next card",onClick:a})]},g[d].key),e("div",{class:"w-nav",children:[e("button",{class:"btn",onClick:p,disabled:d===0,children:"Back"}),e("span",{class:"w-mono",children:[d+1," / ",x]}),e("button",{class:"btn primary",onClick:a,disabled:R,children:d===g.length-1?"Summary":"Next"})]})]})})}export{he as Wrapped};