Spaces:
Sleeping

File size: 22,119 Bytes
8738edc
 
 
 
 
 
dc24afc
8738edc
 
 
 
 
e24fbd1
dc24afc
8738edc
dc24afc
e24fbd1
8738edc
 
 
e24fbd1
dc24afc
e24fbd1
 
61b25c5
 
 
 
 
 
 
 
 
e24fbd1
8738edc
 
e24fbd1
 
 
8738edc
 
dc24afc
8738edc
dc24afc
8738edc
e24fbd1
61b25c5
 
 
 
 
 
e24fbd1
 
dc24afc
61b25c5
dc24afc
61b25c5
 
 
e24fbd1
 
61b25c5
 
 
 
 
e24fbd1
8738edc
 
 
 
 
61b25c5
8738edc
e24fbd1
61b25c5
8738edc
 
 
61b25c5
e24fbd1
61b25c5
8738edc
 
61b25c5
8738edc
dc24afc
8738edc
e24fbd1
 
8738edc
 
 
e24fbd1
dc24afc
e24fbd1
 
61b25c5
 
 
e24fbd1
 
8738edc
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!doctype html>
<html lang="en">
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Comparative Evaluation of Image Editing</title>
<style>
:root{--ink:#243750;--muted:#66768b;--accent:#407a9e;--line:#dce5ee;--surface:#f3f7fa;--pink:#f8edf2}*{box-sizing:border-box}body{margin:0;background:var(--surface);color:var(--ink);font:14px/1.6 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}button{font:inherit;cursor:pointer}button:focus-visible,img:focus-visible,a:focus-visible{outline:3px solid #61a5cb;outline-offset:3px}header{min-height:74px;padding:18px max(24px,calc((100vw - 1380px)/2));background:white;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:24px}.brand{font-size:16px;font-weight:650;letter-spacing:.1px}.caption{font-size:12px;color:var(--muted);font-weight:400;margin-top:2px}.badge{font-size:12px;color:var(--muted);white-space:nowrap}.shell{max-width:1380px;margin:32px auto 48px;padding:0 24px}.intro{display:flex;justify-content:space-between;align-items:flex-start;gap:30px;margin-bottom:22px}h1{font-size:28px;line-height:1.3;letter-spacing:-.6px;margin:0 0 9px}h2{font-size:20px;line-height:1.4;margin:0 0 10px}h3{font-size:16px;margin:0 0 8px}.sub{color:var(--muted);margin:0;max-width:850px}.progress{min-width:140px;font-size:12px;color:var(--muted);padding-top:4px}.track{height:5px;background:#dce6ee;margin-top:10px;border-radius:5px}.track span{display:block;height:100%;background:#76b4d6;border-radius:5px}.workspace{display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:24px}.source{background:white;border:1px solid var(--line);border-radius:12px;padding:16px;display:flex;gap:22px;align-items:center;margin-bottom:18px}.source img{width:360px;height:270px;flex-shrink:0;object-fit:contain;background:#eef1f4;border-radius:6px;cursor:zoom-in}.kicker{font-size:11px;color:#617b93;font-weight:650;letter-spacing:.8px;text-transform:uppercase}.instruction{font-size:17px;font-weight:550;line-height:1.6;margin:7px 0}.tiny{font-size:12px;color:var(--muted)}.sectionline{display:flex;justify-content:space-between;align-items:center;gap:14px;font-size:13px;margin:18px 0 10px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.card{background:white;border:1px solid var(--line);border-radius:10px;overflow:hidden}.cardtop{display:flex;justify-content:space-between;align-items:center;padding:9px 13px}.letter{background:#eaf3f9;border-radius:5px;padding:2px 10px;font-weight:650}.zoom,.textbutton{border:0;background:transparent;color:var(--accent);font-size:12px;padding:4px}.card img{display:block;width:100%;height:300px;object-fit:contain;object-position:center;background:#eef1f4;cursor:zoom-in}.panel{align-self:start;border:1px solid var(--line);background:white;border-radius:12px;padding:22px;position:sticky;top:20px}.panel h2{font-size:18px}.question{padding:19px 0;border-bottom:1px solid #e9eef3}.qtitle{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:650}.num{font-size:11px;color:#7390a9}.question p{font-size:12px;line-height:1.65;color:var(--muted);margin:9px 0 13px}.choices{display:flex;gap:8px}.choice{flex:1;border:1px solid #dce5ee;border-radius:6px;background:white;height:38px;color:var(--ink);font-weight:650}.choice:hover{background:#edf6fb}.choice[aria-pressed=true]{border-color:#a36983;background:var(--pink);color:#81465f;box-shadow:0 0 0 1px #a36983}.submit{border:0;border-radius:7px;background:var(--ink);color:white;padding:13px 22px;font-weight:600}.panel .submit{width:100%;margin-top:20px}.submit:disabled{background:#dce5ee;color:#8191a4;cursor:default}.status{font-size:12px;line-height:1.6;min-height:38px;color:var(--muted);margin-top:10px}.footer{display:flex;justify-content:space-between;gap:20px;color:var(--muted);font-size:11px;margin-top:26px}.demo{background:#e7f2f8;color:#4b6c84;font-size:12px;padding:10px 14px;border-radius:7px;margin-bottom:20px}.done{text-align:center;padding:70px 20px;background:white;border:1px solid var(--line);border-radius:12px}.done h2{font-size:26px}.guide{background:white;border:1px solid var(--line);border-radius:12px;padding:28px;margin-bottom:20px}.guide p{max-width:1000px}.criteria{display:grid;grid-template-columns:repeat(3,1fr);gap:22px;margin:25px 0}.criterion{border-top:3px solid #abcddd;padding-top:14px}.criterion p{color:var(--muted);font-size:13px;margin:0}.notice{padding:12px 15px;background:#f2f6f9;border-left:3px solid #94b8cf;font-size:13px}.example{border-top:1px solid var(--line);padding-top:22px;margin-top:24px}.example-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.example figure{margin:0}.example img{width:100%;height:230px;object-fit:contain;background:#eef1f4;display:block;cursor:zoom-in;border-radius:5px}.example figcaption{font-size:12px;color:var(--muted);margin-top:7px}.example figcaption strong{display:block;color:var(--ink);font-size:13px;margin-bottom:3px}.guide-actions{display:flex;justify-content:space-between;align-items:center;gap:24px;margin-top:26px}.guide-actions p{font-size:12px;color:var(--muted);margin:0}.guide-actions .submit{white-space:nowrap}dialog{border:0;border-radius:10px;padding:14px;max-width:96vw;background:white}dialog::backdrop{background:#182b42d6}dialog img{display:block;max-width:90vw;max-height:82vh;object-fit:contain}dialog button{display:block;margin:0 0 10px auto;border:0;background:#eaf2f7;border-radius:5px;padding:7px 13px}.example-instruction{font-weight:550;margin-bottom:15px}.example-note{font-size:12px;color:var(--muted)}[hidden]{display:none!important}@media(max-width:1050px){.card img{height:250px}}@media(max-width:900px){.workspace{grid-template-columns:1fr}.panel{position:static}.criteria{grid-template-columns:1fr}.card img{height:280px}.example img{height:180px}}@media(max-width:600px){header{padding:14px 18px}.badge{display:none}.shell{padding:0 14px;margin-top:23px}h1{font-size:24px}.intro{gap:16px}.progress{min-width:80px}.source{gap:14px;padding:12px;align-items:flex-start}.source{flex-direction:column}.source img{width:100%;height:260px}.instruction{font-size:14px}.grid{gap:10px}.card img{height:190px}.guide{padding:20px}.example-grid{grid-template-columns:1fr}.example img{height:240px}.guide-actions{align-items:stretch;flex-direction:column}.footer{flex-direction:column;gap:4px}.sectionline{align-items:flex-start}.brand{font-size:14px}}
.guide-toggle{margin:0;grid-column:1/-1}.guide-toggle>summary{cursor:pointer;color:var(--accent);font-weight:650}.guide-toggle[open]>summary{margin-bottom:10px}.score-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin:5px 0 14px}.score-grid label{min-width:0;text-align:center;font-weight:650}.score-grid select{display:block;width:100%;min-height:36px;padding:3px;border:1px solid var(--line);border-radius:6px;background:white;color:var(--ink);font:inherit}.rubric{width:100%;border-collapse:collapse;margin:12px 0}.rubric th,.rubric td{padding:7px;text-align:left;vertical-align:top;border-bottom:1px solid var(--line)}.rubric th:first-child{white-space:nowrap}.score-examples{margin:14px 0;border:1px solid var(--line);border-radius:8px;padding:10px 14px}.score-examples>summary{cursor:pointer;font-weight:650}.score-anchor{background:#eaf2f7;padding:3px 8px;border-radius:6px;display:inline-block;margin-bottom:4px}</style>
<header><div class="brand">Comparative Evaluation of Image Editing<div class="caption">Human preference study</div></div><span class="badge">Anonymous model comparison</span></header>
<main class="shell"><div class="intro"><div><h1 id="heading">Evaluation Guidelines</h1><p class="sub" id="subtitle">Please review the evaluation criteria and examples before starting.</p></div><div class="progress" id="progress" hidden><span id="count"></span><div class="track"><span id="bar"></span></div></div></div><div id="demo" class="demo" hidden>Preview mode. Responses are not saved to the server.</div><div id="content"></div><footer class="footer"><span>No names or email addresses are requested.</span><span>Model identities are concealed during evaluation.</span></footer></main>
<dialog id="lightbox"><button id="close">Close</button><img alt="Enlarged image" id="large"></dialog>
<script src="/static/outbox.js"></script>
<script>
const $=s=>document.querySelector(s), KEYS=['instruction','physics'], LETTERS=[...'ABCD'];
const questions=[['Instruction Following','Score each result by how well they implement the requested edit and preserve unrelated content.'],['Physical Plausibility','Score each result by how well they reflect real-world physical behavior and the consequences of the edit.']];
let pid=localStorage.getItem('study_pid')||crypto.randomUUID();localStorage.setItem('study_pid',pid);
let config,state,storageKey,scores={},busy=false,tutorials=[],outbox,legacyOutboxes=[];
function media(slot){return `/api/media/${config.version}/${pid}/${config.samples[state.index].id}/${slot}`}
function enlarge(src){$('#large').src=src;$('#lightbox').showModal()}$('#close').onclick=()=>$('#lightbox').close();
function persist(){localStorage.setItem(storageKey,JSON.stringify(state))}
function bindZoom(){document.querySelectorAll('img[data-zoom]').forEach(el=>{el.onclick=()=>enlarge(el.src);el.onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();enlarge(el.src)}}})}
function guideMarkup(){
 return `<section class="guide"><h2>Study procedure</h2><p>For each of the ${config.samples.length} items, compare the source image and editing instruction with four edited results. Score each result independently from 1 (lowest) to 5 (highest), separately for each criterion. Scores may tie. No ordering of the results is required.</p><div class="criteria"><section class="criterion"><h3>1. Instruction Following</h3><p>Assess whether the requested change has been made correctly. Content unrelated to the instruction should be preserved unless a change is a necessary consequence of the edit.</p></section><section class="criterion"><h3>2. Physical Plausibility</h3><p>Assess whether the edited scene is physically coherent. Consider effects such as gravity, support, contact, liquid behavior, shadows, and reflections where relevant. Photorealistic appearance alone does not guarantee physical plausibility.</p></section></div><div class="notice">The labels A–D are assigned independently for each item and participant. They do not identify a particular model or indicate a correct answer. Assign scores based on the images, not the labels.</div><h2>Scoring rubric</h2><table class="rubric"><thead><tr><th scope="col">Score</th><th scope="col">Instruction Following</th><th scope="col">Physical Plausibility</th></tr></thead><tbody><tr><th scope="row">1</th><td>The requested change is missing or contradicted.</td><td>A central physical relationship is clearly impossible.</td></tr><tr><th scope="row">2</th><td>The edit attempts the request, but a major requirement is wrong or missing.</td><td>A major physical consequence is missing or inconsistent.</td></tr><tr><th scope="row">3</th><td>The main edit is recognizable, but a noticeable requirement or preservation error remains.</td><td>The scene is broadly coherent, but a noticeable physical inconsistency remains.</td></tr><tr><th scope="row">4</th><td>The request is essentially satisfied, with a small local mismatch.</td><td>Relevant physical effects are mostly consistent, with a minor mismatch.</td></tr><tr><th scope="row">5</th><td>The request is fully satisfied and unrelated content is preserved.</td><td>The scene and all visible, relevant consequences are physically coherent.</td></tr></tbody></table><div class="tutorials"></div><div class="guide-actions"><p>Click any image to inspect it at a larger size. The examples illustrate how to use each scale. They are not part of the questionnaire and do not prescribe a correct score for any survey item.</p></div></section>`;
}
function fillTutorials(holder){
const groups={};
const criteria={instruction:'Instruction Following: score examples',physics:'Physical Plausibility: score examples'};
for(const key of Object.keys(criteria)){
 if(!tutorials.some(t=>t.criterion===key))continue;
 const group=document.createElement('details');group.className='score-examples';
 const title=document.createElement('summary');title.textContent=criteria[key];group.append(title);
 holder.append(group);groups[key]=group;
}
tutorials.forEach(t=>{const section=document.createElement('section');section.className='example';const title=document.createElement('h3');title.textContent=t.title;section.append(title);const instruction=document.createElement('p');instruction.className='example-instruction';instruction.textContent=`Instruction: “${t.instruction}”`;section.append(instruction);const grid=document.createElement('div');grid.className='example-grid';t.images.forEach(i=>{const f=document.createElement('figure'),im=document.createElement('img'),cap=document.createElement('figcaption'),label=document.createElement('strong');im.loading='lazy';im.src=i.src;im.alt=i.label;im.dataset.zoom='1';im.tabIndex=0;label.textContent=i.label;if(i.score)label.className='score-anchor';cap.append(label,document.createTextNode(i.caption||''));f.append(im,cap);grid.append(f)});section.append(grid);const note=document.createElement('p');note.className='example-note';note.textContent=t.note||'';section.append(note);(groups[t.criterion]||holder).append(section)});bindZoom();
}
function showGuidelines(){
 $('#heading').textContent='Evaluation Guidelines';$('#subtitle').textContent='Please review the criteria and examples before starting.';$('#progress').hidden=true;$('#demo').hidden=!config.demo;
 $('#content').innerHTML=guideMarkup()+`<button id="start" class="submit">${state.index>0?'Continue Evaluation':'Start Evaluation'}</button>`;
 fillTutorials($('#content .tutorials'));
 $('#start').onclick=()=>{state.guidelinesReviewed=true;persist();render();window.scrollTo(0,0)};
}
function render(){
 if(!state.guidelinesReviewed){showGuidelines();return}const draft=state.draft?.sampleId===config.samples[state.index]?.id?state.draft:null;scores=state.pending?.scores||draft?.scores||{};let n=config.samples.length;$('#heading').textContent='Image Editing Evaluation';$('#subtitle').textContent='Score the four results independently for each evaluation criterion.';$('#progress').hidden=false;$('#count').textContent=`Item ${Math.min(state.index+1,n)} of ${n}`;$('#bar').style.width=`${state.index/n*100}%`;$('#demo').hidden=!config.demo;
 if(state.index>=n){$('#bar').style.width='100%';renderCompletion();return}
 $('#content').innerHTML=`<div class="workspace"><details class="guide-toggle"><summary>Evaluation guidelines and examples</summary>${guideMarkup()}</details><section><div class="source"><img id="sourceimg" alt="Source image" tabindex="0"><div><div class="kicker">Editing instruction</div><div class="instruction" id="instruction"></div><span class="tiny">Source image shown on the left.</span></div></div><div class="sectionline"><b>Edited results</b><span class="tiny">Click an image to enlarge. Images are shown without cropping.</span></div><div class="grid">${[...'ABCD'].map(l=>`<article class="card"><div class="cardtop"><span class="letter">${l}</span><button class="zoom" data-slot="${l}" aria-label="Enlarge result ${l}">Enlarge</button></div><img data-slot="${l}" alt="Edited result ${l}" tabindex="0"></article>`).join('')}</div></section><aside class="panel"><h2>Evaluation</h2><p class="tiny">Give each result an independent score from 1 to 5. Equal scores are allowed.</p>${questions.map((q,i)=>`<div class="question"><div class="qtitle"><span class="num">${i+1}.</span>${q[0]}</div><p>${q[1]}</p><div class="score-grid" role="group" aria-label="${q[0]} scores">${LETTERS.map(l=>`<label>${l}<select class="score" data-key="${KEYS[i]}" data-slot-letter="${l}" aria-label="${q[0]}: score for result ${l}"><option value="">–</option>${[1,2,3,4,5].map(n=>`<option value="${n}">${n}</option>`).join('')}</select></label>`).join('')}</div></div>`).join('')}<button id="submit" class="submit" disabled>Continue</button><div id="status" class="status" role="status">Enter all eight scores to continue.</div></aside></div>`;
 $('#instruction').textContent=config.samples[state.index].instruction;$('#sourceimg').src=media('input');$('#sourceimg').onclick=()=>enlarge(media('input'));$('#sourceimg').onkeydown=e=>{if(e.key==='Enter')enlarge(media('input'))};document.querySelectorAll('[data-slot]').forEach(el=>{let src=media(el.dataset.slot);if(el.tagName==='IMG')el.src=src;el.onclick=()=>enlarge(src);el.onkeydown=e=>{if(e.key==='Enter')enlarge(src)}});
 fillTutorials($('.guide-toggle .tutorials'));
 document.querySelectorAll('.score').forEach(el=>el.onchange=()=>{
  if(busy||state.pending)return;
  const key=el.dataset.key, slot=el.dataset.slotLetter;
  scores={...scores,[key]:{...scores[key],[slot]:Number(el.value)||null}};
  saveDraft();
 });
 $('#submit').onclick=submit;update();
}
function saveDraft(){state.draft={sampleId:config.samples[state.index].id,scores};persist();update()}
function completeEvaluation(){
 return KEYS.every(k=>LETTERS.every(l=>{
  const v=scores[k]?.[l];return Number.isInteger(v)&&v>=1&&v<=5;
 }));
}
function update(){
 const locked=busy||!!state.pending;
 document.querySelectorAll('.score').forEach(el=>{
  el.value=scores[el.dataset.key]?.[el.dataset.slotLetter]??'';
  el.disabled=locked;
 });
 $('#submit').disabled=busy||!completeEvaluation();
 if(state.pending)$('#status').textContent='This response has not been confirmed. Select Continue to retry.';
}
function renderSyncStatus(){
 if(!outbox||!config)return;
 let el=$('#syncstatus');if(!el){el=document.createElement('div');el.id='syncstatus';el.className='notice';el.setAttribute('role','status');$('#demo').after(el)}
 const q=outbox.summary();
 const previous=legacyOutboxes.reduce((sum,queue)=>sum+queue.summary().pending,0);
 el.textContent=config.demo?'Preview mode: responses are not stored on the server.':q.pending?`${q.acknowledged} response(s) confirmed on the server; ${q.pending} saved on this browser and awaiting upload. You may continue evaluating. Keep this page open until all responses are confirmed.`:`${q.acknowledged} response(s) confirmed on the server.`;
 if(previous)el.append(document.createTextNode(` ${previous} response(s) from the previous survey version are also awaiting upload. Keep this page open.`));
 if(!config.demo&&(q.pending||previous)){const retry=document.createElement('button');retry.className='textbutton';retry.textContent='Retry upload';retry.onclick=()=>{outbox.retryNow();legacyOutboxes.forEach(queue=>queue.retryNow())};el.append(document.createTextNode(' '),retry)}
 if(state&&state.guidelinesReviewed&&state.index>=config.samples.length)renderCompletion();
}
function renderCompletion(){
 const q=outbox.summary();const pending=q.pending+(legacyOutboxes.reduce((sum,queue)=>sum+queue.summary().pending,0));const complete=pending===0;
 $('#content').innerHTML=`<div class="done"><h2>${complete?'Evaluation Complete':'Finalizing Responses'}</h2><p class="sub" style="margin:auto">${config.demo?'The preview is complete. No responses were saved to the server.':complete?'All responses have been confirmed on the server. Thank you for participating. You may now close this window.':`${pending} response(s) are stored on this browser but have not yet been confirmed on the server. Please keep this page open. Uploads are retried automatically; do not clear browser data.`}</p>${!complete?'<button class="submit" style="margin-top:24px" id="retryfinal">Retry upload</button>':''}</div>`;
 if(!complete)$('#retryfinal').onclick=()=>{outbox.retryNow();legacyOutboxes.forEach(queue=>queue.retryNow())};
}
async function submit(){
 if(busy||!completeEvaluation())return;busy=true;update();
 try{
  const body=state.pending||{participant_id:pid,sample_id:config.samples[state.index].id,version:config.version,scores:{...scores},submitted_at:new Date().toISOString()};
  await outbox.enqueue(body); // synchronous persistent browser write, not remote acknowledgement
  state.index++;delete state.draft;delete state.pending;persist();busy=false;render();renderSyncStatus();window.scrollTo(0,0);
 }catch(e){busy=false;update();if(e.code==='ALREADY_RECORDED'){$('#status').textContent=e.message;$('#submit').textContent='Continue with the recorded response';$('#submit').onclick=()=>{state.index++;delete state.draft;persist();render();renderSyncStatus()};return}$('#status').textContent='The response could not be saved on this browser. Please do not close this page or clear browser data. Check storage availability and try again.';}
}
async function init(){try{let r=await fetch(`/api/study?pid=${pid}`);if(!r.ok)throw Error();config=await r.json();const tr=await fetch('/api/tutorials');if(tr.ok)tutorials=await tr.json()}catch(e){$('#content').textContent='The questionnaire could not be loaded. Please refresh the page and try again.';return}storageKey=`study_${config.version}_${config.demo?'demo':'live'}_${pid}`;try{state=JSON.parse(localStorage.getItem(storageKey))||{index:0}}catch(e){state={index:0}}try{
 outbox=new StudyOutbox({version:config.version,participantId:pid,demo:config.demo,onChange:renderSyncStatus});
 if(!config.demo){
  for(const legacyVersion of ['curated30-v1','curated30-rank-v2','curated30-rank-score-v3']){
  const prefix=`study-outbox-v1:${legacyVersion}:${pid}:`;
  if(Object.keys(localStorage).some(key=>key.startsWith(prefix))){
   const queue=new StudyOutbox({version:legacyVersion,participantId:pid,onChange:renderSyncStatus});
   legacyOutboxes.push(queue);queue.kick();
  }
  }
 }
 if(state.pending){await outbox.enqueue(state.pending);delete state.pending;}
 while(state.index<config.samples.length&&outbox.read(config.samples[state.index].id))state.index++;
 persist();render();renderSyncStatus();outbox.kick();
 }catch(e){$('#content').textContent='Browser storage is unavailable or unreadable. Please keep your existing browser data and contact the researcher.'}
}init();
</script>
</html>