Spaces:
Running
Running
Show ground truth and recorded outcome on the left
Browse files- world-models.html +2 -3
world-models.html
CHANGED
|
@@ -32,9 +32,8 @@ header label{display:grid;grid-template-columns:minmax(0,1fr);gap:6px;font-size:
|
|
| 32 |
<p id="empty" class="meta" hidden>No matching attempts.</p>
|
| 33 |
<section id="viewer">
|
| 34 |
<h2 id="task"></h2><p class="meta" id="meta"></p>
|
| 35 |
-
<p class="meta" id="generated-review" hidden></p>
|
| 36 |
<div class="cameras" aria-label="Camera"><button data-camera="0" aria-pressed="true">Top</button><button data-camera="1" aria-pressed="false">Left wrist</button><button data-camera="2" aria-pressed="false">Right wrist</button></div>
|
| 37 |
-
<div class="comparison"><figure><figcaption>
|
| 38 |
<div class="timeline"><input id="scrub" type="range" min="0" max="1" value="0" step="1" aria-label="Frame"><output id="position"></output></div>
|
| 39 |
<div class="controls">
|
| 40 |
<button id="previous" title="Previous frame" aria-label="Previous frame"><svg viewBox="0 0 24 24"><path d="M6 4v16M19 5l-11 7 11 7z"/></svg></button>
|
|
@@ -76,7 +75,7 @@ function seek(v,t){return new Promise((resolve,reject)=>{if(Math.abs(v.currentTi
|
|
| 76 |
async function show(n){if(busy)return;busy=true;const token=version;try{const target=Math.max(0,Math.min(row.frames-1,n));await Promise.all(videos.map(v=>seek(v,target===0?0:(target+.1)/row.fps)));if(token===version){frame=target;draw()}}catch(e){if(token===version){pause();$('status').textContent=e.message}}finally{if(token===version)busy=false}}
|
| 77 |
async function tick(){if(!playing)return;const token=version;await show(frame+1<row.frames?frame+1:0);if(!playing||token!==version)return;if(frame===row.frames-1&&!$('loop').checked){pause();return}timer=setTimeout(tick,1000/row.fps/Number($('speed').value))}
|
| 78 |
async function load(v,src){let url=src;if(location.protocol.startsWith('http')){const response=await fetch(src);if(!response.ok)throw Error('Could not load '+src);url=URL.createObjectURL(await response.blob())}return new Promise((resolve,reject)=>{v.onloadeddata=()=>{if(v.readyState>=2){if(url.startsWith('blob:'))URL.revokeObjectURL(url);resolve()}};v.onerror=()=>{if(url.startsWith('blob:'))URL.revokeObjectURL(url);reject(Error('Could not load '+src))};v.src=url;v.load()})}
|
| 79 |
-
async function select(){pause();const token=++version;busy=false;videos.forEach((v,i)=>{const fresh=v.cloneNode(false);fresh.removeAttribute('src');v.replaceWith(fresh);videos[i]=fresh});row=$('attempt').selectedIndex<0?null:rows[Number($('attempt').value)];controls.forEach(c=>c.disabled=true);$('viewer').hidden=!row;$('empty').hidden=!!row;if(!row)return;camera=row.side==='left'?1:2;document.querySelectorAll('[data-camera]').forEach(b=>b.setAttribute('aria-pressed',String(Number(b.dataset.camera)===camera)));frame=0;showReview();$('task').textContent=row.task.replaceAll('_',' ');$('meta').textContent=`
|
| 80 |
$('attempt').onchange=select;
|
| 81 |
$('generated-filter').onchange=()=>filterAttempts();$('recorded-filter').onchange=()=>filterAttempts();
|
| 82 |
$('play').onclick=()=>{if(playing){pause();return}playing=true;$('playIcon').setAttribute('d','M8 4v16M16 4v16');$('play').title='Pause';$('play').setAttribute('aria-label','Pause');tick()};
|
|
|
|
| 32 |
<p id="empty" class="meta" hidden>No matching attempts.</p>
|
| 33 |
<section id="viewer">
|
| 34 |
<h2 id="task"></h2><p class="meta" id="meta"></p>
|
|
|
|
| 35 |
<div class="cameras" aria-label="Camera"><button data-camera="0" aria-pressed="true">Top</button><button data-camera="1" aria-pressed="false">Left wrist</button><button data-camera="2" aria-pressed="false">Right wrist</button></div>
|
| 36 |
+
<div class="comparison"><figure><figcaption>Ground truth</figcaption><p class="meta" id="recorded-review"></p><canvas id="truth" width="640" height="480"></canvas></figure><figure><figcaption>World model</figcaption><p class="meta" id="generated-review" hidden></p><canvas id="pred" width="640" height="480"></canvas></figure></div>
|
| 37 |
<div class="timeline"><input id="scrub" type="range" min="0" max="1" value="0" step="1" aria-label="Frame"><output id="position"></output></div>
|
| 38 |
<div class="controls">
|
| 39 |
<button id="previous" title="Previous frame" aria-label="Previous frame"><svg viewBox="0 0 24 24"><path d="M6 4v16M19 5l-11 7 11 7z"/></svg></button>
|
|
|
|
| 75 |
async function show(n){if(busy)return;busy=true;const token=version;try{const target=Math.max(0,Math.min(row.frames-1,n));await Promise.all(videos.map(v=>seek(v,target===0?0:(target+.1)/row.fps)));if(token===version){frame=target;draw()}}catch(e){if(token===version){pause();$('status').textContent=e.message}}finally{if(token===version)busy=false}}
|
| 76 |
async function tick(){if(!playing)return;const token=version;await show(frame+1<row.frames?frame+1:0);if(!playing||token!==version)return;if(frame===row.frames-1&&!$('loop').checked){pause();return}timer=setTimeout(tick,1000/row.fps/Number($('speed').value))}
|
| 77 |
async function load(v,src){let url=src;if(location.protocol.startsWith('http')){const response=await fetch(src);if(!response.ok)throw Error('Could not load '+src);url=URL.createObjectURL(await response.blob())}return new Promise((resolve,reject)=>{v.onloadeddata=()=>{if(v.readyState>=2){if(url.startsWith('blob:'))URL.revokeObjectURL(url);resolve()}};v.onerror=()=>{if(url.startsWith('blob:'))URL.revokeObjectURL(url);reject(Error('Could not load '+src))};v.src=url;v.load()})}
|
| 78 |
+
async function select(){pause();const token=++version;busy=false;videos.forEach((v,i)=>{const fresh=v.cloneNode(false);fresh.removeAttribute('src');v.replaceWith(fresh);videos[i]=fresh});row=$('attempt').selectedIndex<0?null:rows[Number($('attempt').value)];controls.forEach(c=>c.disabled=true);$('viewer').hidden=!row;$('empty').hidden=!!row;if(!row)return;camera=row.side==='left'?1:2;document.querySelectorAll('[data-camera]').forEach(b=>b.setAttribute('aria-pressed',String(Number(b.dataset.camera)===camera)));frame=0;showReview();$('task').textContent=row.task.replaceAll('_',' ');$('meta').textContent=`${row.side} arm · ${row.id}`;$('recorded-review').textContent=`Recorded outcome: ${row.label}`;$('scrub').max=row.frames-1;$('scrub').value=0;$('status').textContent='Loading…';try{await Promise.all([load(videos[0],row.prediction),load(videos[1],row.ground_truth)]);if(token!==version)return;await show(0);if(token!==version)return;controls.forEach(c=>c.disabled=false);$('status').textContent=''}catch(e){if(token===version)$('status').textContent=e.message}}
|
| 79 |
$('attempt').onchange=select;
|
| 80 |
$('generated-filter').onchange=()=>filterAttempts();$('recorded-filter').onchange=()=>filterAttempts();
|
| 81 |
$('play').onclick=()=>{if(playing){pause();return}playing=true;$('playIcon').setAttribute('d','M8 4v16M16 4v16');$('play').title='Pause';$('play').setAttribute('aria-label','Pause');tick()};
|