memoscan
← all memos

Memo 0x5a73e1e7…0ba881 on Ethereum

// Sofia Crespo - 2023 - 'Time after vessels' const ganResolution=512,tileSize=64,gridSize=32,hashPairs=[];for(let t=0;t<32;t++)hashPairs.push(tokenData.hash.slice(2+2*t,4+2*t));const dcP=hashPairs.map((t=>parseInt(t,16))),inputPointsSeeds=[];for(let t=27;t<32;t++)inputPointsSeeds.push(parseInt(hashPairs[t],16));const createCanvas=document.createElement("canvas"),default_size=1024;createCanvas.id="canvas",createCanvas.width=1024,createCanvas.height=1024;let body=document.getElementsByTagName("body")[0];body.appendChild(createCanvas);const canvasStyles="\n padding-left: 0;\n padding-right: 0;\n margin-left: auto;\n margin-right: auto;\n display: block;\n width: auto;\n height: 100vh;\n",element=document.querySelector("#canvas");element.style.cssText=canvasStyles;const canvas=document.getElementById("canvas");(async()=>{console.log("Dependencies loading...");let t="QmT1M2gyGfXuwYsRosdQaVFV3P9VoD4CdmtBbiPzGUDXFH";async function e(t,e,n,a,o){const s=document.createElement("canvas"),i=s.getContext("2d");s.width=e,s.height=n,i.putImageData(new ImageData(t,e,n),0,0);const r=document.createElement("canvas");r.width=a,r.height=o;const c=r.getContext("2d");c.drawImage(s,0,0,e,n,0,0,a,o);return c.getImageData(0,0,a,o).data}function n(t){const e=Math.sqrt(t.reduce(((t,e)=>t+e*e),0));return t.map((t=>t/e))}function a(t,e){return t.map(((t,n)=>t+e[n]))}function o(t,e){return t.map((t=>t*e))}function s(t,e){const n=Math.floor(16),a=Math.floor(16),o=new Uint8ClampedArray(1048576);for(let s=0;s<a;s++)for(let i=0;i<n;i++){const r=32*i,c=32*s;let l=[0,0,0];for(let e=0;e<64;e++)for(let n=0;n<64;n++){const a=4*(512*(c+e)+(r+n));l[0]+=t[a],l[1]+=t[a+1],l[2]+=t[a+2]}l=l.map((t=>t/4096));let m=1/0,h=0,d=0;for(let t=0;t<a;t++)for(let a=0;a<n;a++){const n=64*a,o=64*t;let s=0;for(let t=0;t<64;t++)for(let a=0;a<64;a++){const i=4*(512*(o+t)+(n+a));s+=Math.abs(e[i]-l[0]),s+=Math.abs(e[i+1]-l[1]),s+=Math.abs(e[i+2]-l[2])}s<m&&(m=s,h=n,d=o)}const u=2;for(let t=0;t<32;t++)for(let n=0;n<32;n++){const a=4*(512*(c+t)+(r+n)),s=4*(Math.floor(512*(d+t*u))+Math.floor(h+n*u));o[a]=e[s],o[a+1]=e[s+1],o[a+2]=e[s+2],o[a+3]=255}}return o}async function i(t,i,r,c,l,m,h,d,u,f,g,p){const w=function(t,e,s){const i=n(e),r=n(s),c=Math.acos((l=r,i.reduce(((t,e,n)=>t+e*l[n]),0)));var l;const m=Math.sin(c);return a(o(e,Math.sin((1-t)*c)/m),o(s,Math.sin(t*c)/m))}(i/r,c,l),v=new ort.Tensor("float32",Float32Array.from(w),[1,256]),y=(await m.run({[h]:v}))[d].data,M=new Uint8ClampedArray(1048576);for(let t=0;t<3;t++)for(let e=0;e<512;e++)for(let n=0;n<512;n++){const a=512*t*512+512*e+n;M[4*(512*e+n)+t]=Math.min(255,Math.max(0,255*y[a]))}for(let t=3;t<M.length;t+=4)M[t]=255;const P=p?s(M,p):M,b=await e(P,512,512,1024,1024),I=new ImageData(b,1024,1024);return u.putImageData(I,0,0),f.push(new Promise((t=>{canvas.toBlob((e=>{t(e)}))}))),M}function r(t){return new Promise((e=>setTimeout(e,t)))}await import(`https://pinata.brightmoments.io/ipfs/${t}/seedrandom.min.js`),await import(`https://pinata.brightmoments.io/ipfs/${t}/ort.min.js`),ort.env.wasm.wasmPaths=`https://pinata.brightmoments.io/ipfs/${t}/`,console.log("Dependencies loaded."),async function(){const n=canvas.getContext("2d");console.log("Model loading...");const a=await ort.InferenceSession.create(`https://pinata.brightmoments.io/ipfs/${t}/sc-model.onnx`),o=a.inputNames[0],c=a.outputNames[0];console.log("Model loaded. Running inference...");const l=240,m=inputPointsSeeds.map((t=>function(t){const e=new Math.seedrandom(t);return Array.from({length:256},(()=>2*e()-1))}(t)));m.push(m[0]);const h=l/inputPointsSeeds.length,d=Math.round(h),u=[],f=inputPointsSeeds.length;let g=null,p=null;function w(t){const e=t/l*100;e%10==0&&console.log(`${e}% complete`)}for(let t=0;t<f;t++){const e=m[t],s=m[t+1];for(let l=0;l<d;l++){w(t*d+l),g=await i(0,l,d,e,s,a,o,c,n,u,0,g),0===t&&0===l&&(p=g),await r(10)}}console.log("inference complete!");const v=s(p,g),y=await e(v,512,512,1024,1024),M=new ImageData(y,1024,1024);n.putImageData(M,0,0);const P=await new Promise((t=>{canvas.toBlob((e=>{t(e)}))}));u.unshift(P),u.splice(1,1);const b=await Promise.all(u),I=t=>{const e=new Image;e.src=URL.createObjectURL(t),e.onload=()=>{n.drawImage(e,0,0,canvas.width,canvas.height)}},C=async()=>{for(let t=0;t<b.length;t++)I(b[t]),await new Promise((t=>setTimeout(t,41.666666666666664)));C()};C()}()})();