Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +68 -127
index.html
CHANGED
|
@@ -2,193 +2,134 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0
|
| 6 |
-
<title>Mesh Reasoner Lab
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
|
| 9 |
<style>
|
| 10 |
-
body { background: #06090e; color: #cbd5e1; font-family: monospace;
|
| 11 |
.glass { background: rgba(15,23,42,0.95); border: 1px solid #334155; }
|
| 12 |
-
|
| 13 |
-
.force-neg { color: #f87171; }
|
| 14 |
-
/* Control Drawer for Mobile */
|
| 15 |
-
#drawer { transition: transform 0.3s ease-in-out; z-index: 50; }
|
| 16 |
.drawer-hidden { transform: translateY(100%); }
|
| 17 |
-
@media (min-width: 1024px) {
|
| 18 |
-
#drawer { transform: none !important; position: static; width: 24rem; height: 100%; }
|
| 19 |
-
#drawer-toggle { display: none; }
|
| 20 |
-
}
|
| 21 |
</style>
|
| 22 |
</head>
|
| 23 |
-
<body class="flex flex-col
|
| 24 |
|
| 25 |
-
<
|
| 26 |
-
|
| 27 |
-
<
|
| 28 |
-
<button onclick="toggleDrawer()" id="drawer-toggle" class="bg-blue-600 px-4 py-1 rounded text-white text-xs font-bold">⚙️ SETTINGS</button>
|
| 29 |
</header>
|
| 30 |
|
| 31 |
-
<
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
<
|
| 35 |
-
<button onclick="toggleDrawer()" class="text-slate-400">CLOSE ✕</button>
|
| 36 |
</div>
|
| 37 |
|
| 38 |
-
<div class="space-y-4
|
| 39 |
<section>
|
| 40 |
-
<label class="text-slate-500
|
| 41 |
-
<select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2
|
| 42 |
-
<option value="
|
| 43 |
-
<option value="
|
| 44 |
</select>
|
| 45 |
</section>
|
| 46 |
|
| 47 |
-
<section>
|
| 48 |
-
<label class="text-
|
| 49 |
-
<
|
| 50 |
-
<
|
| 51 |
-
<
|
| 52 |
-
</
|
| 53 |
</section>
|
| 54 |
|
| 55 |
-
<section class="
|
| 56 |
-
<label class="text-
|
| 57 |
-
<
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
</section>
|
| 60 |
|
| 61 |
-
<
|
| 62 |
-
<label class="text-purple-400 block mb-1">BATCH TEST SETS:</label>
|
| 63 |
-
<input type="number" id="b_count" value="10" class="w-full bg-black border border-slate-700 p-2 mb-1">
|
| 64 |
-
<button onclick="triggerBatch(); toggleDrawer()" class="w-full bg-purple-700 py-3 lg:py-1 font-bold rounded">START BATCH RUN</button>
|
| 65 |
-
</section>
|
| 66 |
-
|
| 67 |
-
<button onclick="triggerHalt(); toggleDrawer()" class="w-full border border-red-500 text-red-500 py-2 hover:bg-red-900 rounded">RESET ENGINE</button>
|
| 68 |
-
</div>
|
| 69 |
-
|
| 70 |
-
<div class="mt-auto border-t border-slate-800 pt-4 pb-6 lg:pb-0">
|
| 71 |
-
<h3 class="text-xs text-orange-400 uppercase tracking-widest">Live Error</h3>
|
| 72 |
-
<div id="error-meter" class="text-3xl lg:text-2xl font-bold">0.000</div>
|
| 73 |
-
<div class="w-full bg-slate-800 h-3 mt-1 rounded-full overflow-hidden">
|
| 74 |
-
<div id="error-bar" class="bg-red-500 h-full transition-all" style="width: 0%"></div>
|
| 75 |
-
</div>
|
| 76 |
</div>
|
| 77 |
</aside>
|
| 78 |
|
| 79 |
-
<!-- Main Viewport -->
|
| 80 |
<main class="flex-grow flex flex-col min-h-0">
|
| 81 |
-
<
|
| 82 |
-
<div id="plot" class="flex-grow min-h-[40vh]"></div>
|
| 83 |
|
| 84 |
-
<
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
<h4 class="text-blue-300 mb-1 sticky top-0 bg-black/80">NODE FORCES (ADOPTION)</h4>
|
| 89 |
-
<div id="node-details" class="space-y-1">Waiting...</div>
|
| 90 |
-
</div>
|
| 91 |
-
<!-- Event Log -->
|
| 92 |
-
<div id="logger" class="hidden lg:block lg:w-1/2 p-3 text-[10px] text-slate-500 overflow-y-auto">
|
| 93 |
-
<h4 class="text-slate-400 mb-1">EVENT LOG</h4>
|
| 94 |
-
<div id="log-content">...</div>
|
| 95 |
</div>
|
|
|
|
|
|
|
| 96 |
</div>
|
| 97 |
</main>
|
| 98 |
|
| 99 |
<script>
|
| 100 |
-
let
|
| 101 |
-
function toggleDrawer() {
|
| 102 |
-
const drawer = document.getElementById('drawer');
|
| 103 |
-
drawerOpen = !drawerOpen;
|
| 104 |
-
if (drawerOpen) drawer.classList.remove('drawer-hidden');
|
| 105 |
-
else drawer.classList.add('drawer-hidden');
|
| 106 |
-
}
|
| 107 |
|
| 108 |
async function sendConfig() {
|
| 109 |
-
await fetch('/
|
| 110 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 111 |
-
body: JSON.stringify({
|
| 112 |
-
mode: document.getElementById('mode').value,
|
| 113 |
-
distribution: 'individual',
|
| 114 |
-
problem_type: document.getElementById('probType').value,
|
| 115 |
-
asymmetric: false
|
| 116 |
-
})
|
| 117 |
});
|
| 118 |
}
|
| 119 |
|
| 120 |
-
async function
|
| 121 |
-
|
| 122 |
-
await fetch('/
|
| 123 |
method: 'POST', headers: {'Content-Type':'application/json'},
|
| 124 |
-
body: JSON.stringify({
|
| 125 |
});
|
| 126 |
}
|
| 127 |
|
| 128 |
-
async function
|
| 129 |
-
|
|
|
|
| 130 |
method: 'POST', headers: {'Content-Type':'application/json'},
|
| 131 |
-
body: JSON.stringify({
|
| 132 |
-
batch_size: document.getElementById('b_count').value,
|
| 133 |
-
val_min: 10, val_max: 100
|
| 134 |
-
})
|
| 135 |
});
|
| 136 |
}
|
| 137 |
|
| 138 |
-
async function triggerHalt() { await fetch('/halt', {method: 'POST'}); }
|
| 139 |
|
| 140 |
setInterval(async () => {
|
| 141 |
try {
|
| 142 |
-
const
|
| 143 |
-
const d = await
|
| 144 |
-
|
| 145 |
-
// 1. Error Logic
|
| 146 |
-
const err = Math.abs(d.error);
|
| 147 |
-
document.getElementById('error-meter').innerText = d.error.toFixed(4);
|
| 148 |
-
document.getElementById('error-bar').style.width = Math.min(100, err * 2) + "%";
|
| 149 |
-
document.getElementById('error-meter').className = err < 0.1 ? "text-green-400 text-3xl font-bold" : "text-red-400 text-3xl font-bold";
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
|
|
|
| 153 |
let px=[], py=[], pz=[], ids=[];
|
| 154 |
Object.keys(d.nodes).forEach(id => {
|
| 155 |
const n = d.nodes[id];
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
px.push(n.x); py.push(n.y); pz.push(n.z); ids.push(id);
|
| 159 |
});
|
| 160 |
-
document.getElementById('
|
| 161 |
-
document.getElementById('
|
| 162 |
|
| 163 |
-
// 3. Optimized Plotly Logic
|
| 164 |
const trace = {
|
| 165 |
type: 'scatter3d', mode: 'lines+markers+text',
|
| 166 |
x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
|
| 167 |
-
text: ids.concat(['']),
|
| 168 |
-
marker: {size: 8, color: ['#fb923c','#c084fc','#38bdf8']},
|
| 169 |
-
line: {color: '#334155', width: 2}
|
| 170 |
};
|
| 171 |
const layout = {
|
| 172 |
-
margin:
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
xaxis: {range: [-5, 105], color: '#475569'},
|
| 177 |
-
yaxis: {range: [-3, 3], color: '#475569'},
|
| 178 |
-
zaxis: {range: [-3, 3], color: '#475569'},
|
| 179 |
-
camera: { eye: {x: 1.2, y: 1.2, z: 1.2} }
|
| 180 |
}
|
| 181 |
};
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
Plotly.newPlot('plot', [trace], layout, config);
|
| 186 |
-
window.plotted=true;
|
| 187 |
-
} else {
|
| 188 |
-
Plotly.react('plot', [trace], layout, config);
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
} catch(e) {}
|
| 192 |
}, 200);
|
| 193 |
</script>
|
| 194 |
</body>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Mesh Reasoner Lab</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
|
| 9 |
<style>
|
| 10 |
+
body { background: #06090e; color: #cbd5e1; font-family: monospace; }
|
| 11 |
.glass { background: rgba(15,23,42,0.95); border: 1px solid #334155; }
|
| 12 |
+
#drawer { transition: transform 0.3s ease-in-out; }
|
|
|
|
|
|
|
|
|
|
| 13 |
.drawer-hidden { transform: translateY(100%); }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</style>
|
| 15 |
</head>
|
| 16 |
+
<body class="flex flex-col h-screen overflow-hidden">
|
| 17 |
|
| 18 |
+
<header class="glass p-3 flex justify-between items-center z-10">
|
| 19 |
+
<h1 class="text-blue-400 font-bold text-xs uppercase tracking-tighter">Topological Model</h1>
|
| 20 |
+
<button onclick="toggleDrawer()" class="bg-blue-600 px-4 py-1 rounded text-white text-xs font-bold">SETTINGS / TOOLS</button>
|
|
|
|
| 21 |
</header>
|
| 22 |
|
| 23 |
+
<aside id="drawer" class="fixed inset-x-0 bottom-0 drawer-hidden glass p-4 flex flex-col gap-4 z-50 max-h-[90vh] overflow-y-auto">
|
| 24 |
+
<div class="flex justify-between items-center border-b border-slate-700 pb-2">
|
| 25 |
+
<span class="text-orange-400 font-bold">CONTROLS</span>
|
| 26 |
+
<button onclick="toggleDrawer()" class="text-slate-400 text-xl">✕</button>
|
|
|
|
| 27 |
</div>
|
| 28 |
|
| 29 |
+
<div class="space-y-4">
|
| 30 |
<section>
|
| 31 |
+
<label class="text-slate-500 text-[10px]">MODE</label>
|
| 32 |
+
<select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 text-white">
|
| 33 |
+
<option value="training">TRAINING (A,B,C Locked -> Learn K)</option>
|
| 34 |
+
<option value="inference">INFERENCE (A,B Locked -> C Drifts)</option>
|
| 35 |
</select>
|
| 36 |
</section>
|
| 37 |
|
| 38 |
+
<section class="bg-purple-900/20 p-3 rounded border border-purple-800">
|
| 39 |
+
<label class="text-purple-400 font-bold text-xs">FACTORIZATION DATASET</label>
|
| 40 |
+
<div class="flex gap-2 mt-2">
|
| 41 |
+
<input type="number" id="batch_count" value="10" class="w-1/2 bg-black text-center p-2 border border-slate-700">
|
| 42 |
+
<button onclick="genFactors()" class="w-1/2 bg-purple-700 font-bold text-xs rounded">START SET</button>
|
| 43 |
+
</div>
|
| 44 |
</section>
|
| 45 |
|
| 46 |
+
<section class="bg-blue-900/20 p-3 rounded border border-blue-800">
|
| 47 |
+
<label class="text-blue-400 font-bold text-xs">CUSTOM TEST (FORWARD PASS)</label>
|
| 48 |
+
<div class="grid grid-cols-2 gap-2 mt-2">
|
| 49 |
+
<input type="number" id="custom_a" placeholder="A" class="bg-black text-center p-2 border border-slate-700">
|
| 50 |
+
<input type="number" id="custom_b" placeholder="B" class="bg-black text-center p-2 border border-slate-700">
|
| 51 |
+
</div>
|
| 52 |
+
<button onclick="testCustom()" class="w-full bg-blue-700 mt-2 py-2 font-bold text-xs rounded uppercase">Predict C</button>
|
| 53 |
</section>
|
| 54 |
|
| 55 |
+
<button onclick="triggerHalt()" class="w-full border border-red-500 text-red-500 py-3 rounded font-bold">RESET ENGINE</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
</div>
|
| 57 |
</aside>
|
| 58 |
|
|
|
|
| 59 |
<main class="flex-grow flex flex-col min-h-0">
|
| 60 |
+
<div id="plot" class="flex-grow"></div>
|
|
|
|
| 61 |
|
| 62 |
+
<div class="h-56 glass border-t border-slate-700 p-4 flex flex-col overflow-y-auto">
|
| 63 |
+
<div class="flex justify-between items-center mb-2">
|
| 64 |
+
<h4 class="text-blue-300 text-[10px] font-bold">MODEL STATE</h4>
|
| 65 |
+
<div id="error-val" class="text-xs font-bold">ERR: 0.000</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
| 67 |
+
<div id="nodes-ui" class="space-y-1 text-[11px]"></div>
|
| 68 |
+
<div id="logs" class="mt-3 pt-2 border-t border-slate-800 text-[9px] text-slate-500 space-y-1"></div>
|
| 69 |
</div>
|
| 70 |
</main>
|
| 71 |
|
| 72 |
<script>
|
| 73 |
+
let drawer = document.getElementById('drawer');
|
| 74 |
+
function toggleDrawer() { drawer.classList.toggle('drawer-hidden'); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
async function sendConfig() {
|
| 77 |
+
await fetch('/config', {
|
| 78 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 79 |
+
body: JSON.stringify({ mode: document.getElementById('mode').value })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
});
|
| 81 |
}
|
| 82 |
|
| 83 |
+
async function genFactors() {
|
| 84 |
+
toggleDrawer();
|
| 85 |
+
await fetch('/generate_factors', {
|
| 86 |
method: 'POST', headers: {'Content-Type':'application/json'},
|
| 87 |
+
body: JSON.stringify({ count: document.getElementById('batch_count').value })
|
| 88 |
});
|
| 89 |
}
|
| 90 |
|
| 91 |
+
async function testCustom() {
|
| 92 |
+
toggleDrawer();
|
| 93 |
+
await fetch('/test_custom', {
|
| 94 |
method: 'POST', headers: {'Content-Type':'application/json'},
|
| 95 |
+
body: JSON.stringify({ a: document.getElementById('custom_a').value, b: document.getElementById('custom_b').value })
|
|
|
|
|
|
|
|
|
|
| 96 |
});
|
| 97 |
}
|
| 98 |
|
| 99 |
+
async function triggerHalt() { toggleDrawer(); await fetch('/halt', {method: 'POST'}); }
|
| 100 |
|
| 101 |
setInterval(async () => {
|
| 102 |
try {
|
| 103 |
+
const res = await fetch('/state');
|
| 104 |
+
const d = await res.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
+
document.getElementById('error-val').innerText = "ERR: " + d.error.toFixed(4);
|
| 107 |
+
|
| 108 |
+
let ui = "";
|
| 109 |
let px=[], py=[], pz=[], ids=[];
|
| 110 |
Object.keys(d.nodes).forEach(id => {
|
| 111 |
const n = d.nodes[id];
|
| 112 |
+
ui += `<div class="flex justify-between"><span>NODE ${id}: <b class="text-white">${n.x.toFixed(2)}</b></span> <span class="text-slate-500">K: ${n.k.toFixed(4)} | F: ${n.f.toFixed(3)}</span></div>`;
|
| 113 |
+
px.push(n.x); py.push(id==='A'?1:id==='B'?-1:0); pz.push(0); ids.push(id);
|
|
|
|
| 114 |
});
|
| 115 |
+
document.getElementById('nodes-ui').innerHTML = ui;
|
| 116 |
+
document.getElementById('logs').innerHTML = d.logs.map(l => `<div>${l}</div>`).join('');
|
| 117 |
|
|
|
|
| 118 |
const trace = {
|
| 119 |
type: 'scatter3d', mode: 'lines+markers+text',
|
| 120 |
x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
|
| 121 |
+
text: ids.concat(['']), marker: {size: 10, color:['#fb923c','#c084fc','#38bdf8']}
|
|
|
|
|
|
|
| 122 |
};
|
| 123 |
const layout = {
|
| 124 |
+
margin:{l:0,r:0,t:0,b:0}, paper_bgcolor:'transparent',
|
| 125 |
+
scene:{
|
| 126 |
+
xaxis:{color:'#475569'}, yaxis:{range:[-3,3], color:'#475569'}, zaxis:{range:[-3,3], color:'#475569'},
|
| 127 |
+
camera: {eye:{x:1.5, y:1.5, z:1.5}}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
};
|
| 130 |
+
if(!window.plotted){ Plotly.newPlot('plot', [trace], layout, {displayModeBar:false}); window.plotted=true; }
|
| 131 |
+
else { Plotly.react('plot', [trace], layout); }
|
| 132 |
+
} catch(e){}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
}, 200);
|
| 134 |
</script>
|
| 135 |
</body>
|