lusxvr commited on
Commit
b1e5e4d
·
1 Parent(s): 24caa11

upadted comparison

Browse files
app/src/content/embeds/comparison.html CHANGED
@@ -56,9 +56,9 @@
56
 
57
  // Known filenames in /public/data/comparison
58
  const FILES = {
59
- '1': { 1: 'id_1_rank_1_sim_1.000.png', 2: 'id_1_rank_2_sim_0.165.png', 3: 'id_1_rank_3_sim_0.143.png' },
60
- '2': { 1: 'id_2_rank_1_sim_1.000.png', 2: 'id_2_rank_2_sim_0.978.png', 3: 'id_2_rank_3_sim_0.975.png' },
61
- '3': { 1: 'id_3_rank_1_sim_0.936.png', 2: 'id_3_rank_2_sim_0.686.png', 3: 'id_3_rank_3_sim_0.676.png' },
62
  };
63
 
64
  // Images served from [domain]/public/data/comparison/*.png → path is /data/comparison/
@@ -78,7 +78,7 @@
78
  const controls = document.createElement('div'); controls.className = 'controls';
79
  const label = document.createElement('label'); label.textContent = 'Example';
80
  const select = document.createElement('select');
81
- const EXAMPLE_LABELS = { '1': 'photo', '2': 'chart', '3': 'drawing' };
82
  ['1','2','3'].forEach((id)=>{ const o=document.createElement('option'); o.value=id; o.textContent=EXAMPLE_LABELS[id]; select.appendChild(o); });
83
  label.appendChild(select); controls.appendChild(label); container.appendChild(controls);
84
 
@@ -100,29 +100,33 @@
100
 
101
  const render = (id) => {
102
  const files = FILES[id]; if (!files) return;
103
- const ordered = [files[1], files[1], files[2], files[3]]; // rank_1 twice then rank_2 and rank_3
104
  grid.innerHTML = '';
105
  ordered.forEach((fname, idx) => {
106
  const { sim } = parseInfo(fname);
107
- const isFirst = idx === 0;
108
- const isDuplicateOfFirst = idx === 1;
109
  const card = document.createElement('div'); card.className = 'card';
110
  const media = document.createElement('div'); media.className = 'media';
111
- const img = document.createElement('img'); img.alt = `example ${id} image ${idx+1}${isDuplicateOfFirst ? ' identical' : ''}`; img.loading = 'lazy'; img.src = basePath + fname; media.appendChild(img);
112
  const meta = document.createElement('div'); meta.className = 'meta';
113
- const left = document.createElement('span'); left.className = 'label'; left.textContent = isFirst ? 'Query' : 'Similarity';
114
- meta.appendChild(left);
115
- if (!isFirst) {
116
- const right = document.createElement('span'); right.className = 'value'; right.textContent = isDuplicateOfFirst ? '1.000 identical' : formatSim(sim);
117
- meta.appendChild(right);
 
 
 
 
118
  }
 
119
  card.appendChild(media); card.appendChild(meta); grid.appendChild(card);
120
  });
121
  };
122
 
123
  (async () => {
124
  // Resolve a working base then initial render
125
- basePath = await resolveBase(CANDIDATE_BASES, FILES['1'][1]);
126
  render('1');
127
  })();
128
 
 
56
 
57
  // Known filenames in /public/data/comparison
58
  const FILES = {
59
+ '1': { query: 'id_1_query.png', 1: 'id_1_rank_1_sim_1.000.png', 2: 'id_1_rank_2_sim_0.165.png', 3: 'id_1_rank_3_sim_0.143.png' },
60
+ '2': { query: 'id_2_query.png', 1: 'id_2_rank_1_sim_1.000.png', 2: 'id_2_rank_2_sim_0.978.png', 3: 'id_2_rank_3_sim_0.975.png' },
61
+ '3': { query: 'id_3_query.png', 1: 'id_3_rank_1_sim_0.936.png', 2: 'id_3_rank_2_sim_0.686.png', 3: 'id_3_rank_3_sim_0.676.png' },
62
  };
63
 
64
  // Images served from [domain]/public/data/comparison/*.png → path is /data/comparison/
 
78
  const controls = document.createElement('div'); controls.className = 'controls';
79
  const label = document.createElement('label'); label.textContent = 'Example';
80
  const select = document.createElement('select');
81
+ const EXAMPLE_LABELS = { '1': 'Photo', '2': 'Chart', '3': 'Drawing' };
82
  ['1','2','3'].forEach((id)=>{ const o=document.createElement('option'); o.value=id; o.textContent=EXAMPLE_LABELS[id]; select.appendChild(o); });
83
  label.appendChild(select); controls.appendChild(label); container.appendChild(controls);
84
 
 
100
 
101
  const render = (id) => {
102
  const files = FILES[id]; if (!files) return;
103
+ const ordered = [files.query, files[1], files[2], files[3]]; // query, then matches 1, 2, 3
104
  grid.innerHTML = '';
105
  ordered.forEach((fname, idx) => {
106
  const { sim } = parseInfo(fname);
107
+ const isQuery = idx === 0;
 
108
  const card = document.createElement('div'); card.className = 'card';
109
  const media = document.createElement('div'); media.className = 'media';
110
+ const img = document.createElement('img'); img.alt = `example ${id} ${isQuery ? 'query' : `match ${idx}`}`; img.loading = 'lazy'; img.src = basePath + fname; media.appendChild(img);
111
  const meta = document.createElement('div'); meta.className = 'meta';
112
+
113
+ if (isQuery) {
114
+ const label = document.createElement('span'); label.className = 'label'; label.textContent = 'Query';
115
+ meta.appendChild(label);
116
+ } else {
117
+ const label = document.createElement('span'); label.className = 'label'; label.textContent = `Match ${idx}:`;
118
+ const similarity = document.createElement('span'); similarity.className = 'value'; similarity.textContent = `Similarity: ${formatSim(sim)}`;
119
+ meta.appendChild(label);
120
+ meta.appendChild(similarity);
121
  }
122
+
123
  card.appendChild(media); card.appendChild(meta); grid.appendChild(card);
124
  });
125
  };
126
 
127
  (async () => {
128
  // Resolve a working base then initial render
129
+ basePath = await resolveBase(CANDIDATE_BASES, FILES['1'].query);
130
  render('1');
131
  })();
132