Spaces:
Running
Running
Giao diện đẹp hơn + gộp hiển thị 'Rác' + cache-bust v3
Browse files87 unmodified lines888990919293949596979899100101102103104105106196 unmodified lines30330430530630730830931087 unmodified linesreturn "low";}function analyze(dets){const nFloat = dets.filter(d=>d.cls==="floating_trash").length;const nPile = dets.filter(d=>d.cls==="trash_pile").length;const trashBoxes = dets.filter(d=>d.cls==="floating_trash"||d.cls==="trash_pile").map(d=>d.box);const drains = dets.filter(d=>d.cls==="drain");const hasDrain = drains.length>0;let cov = 0, clog = null;if (hasDrain){ cov = Math.max(...drains.map(dr=>coverage(dr.box, trashBoxes)), 0); clog = clogLevel(cov); }const trashTotal = nFloat + nPile;return { nFloat, nPile, trashTotal, hasDrain, coverage: Math.round(cov*10)/10, clog, flood: floodRisk(clog,trashTotal,hasDrain) };}// vẽ box lên ảnh -> dataURL để hiển thịconst BOX_COLOR = { floating_trash:"#ffa500", trash_pile:"#dc143c", drain:"#1e90ff" };function drawAnnotated(source, dets, w, h){const c = document.createElement("canvas"); c.width=w; c.height=h;const ctx = c.getContext("2d"); ctx.drawImage(source,0,0,w,h);196 unmodified lines// hiện kết quảdocument.getElementById("resultCard").classList.remove("hidden");document.getElementById("resultImg").src=annotated;document.getElementById("rFloat").textContent=a.nFloat;document.getElementById("rPile").textContent=a.nPile;const box=document.getElementById("clogResult");if(a.hasDrain&&a.clog){ const l=CLOG_LABEL[a.clog];box.innerHTML=`<p>Miệng cống: <span class="badge ${l.c}">${l.t}</span></p><p>Rác che <b>${a.coverage}%</b>. ${a.clog==="clear"?"Cống thông thoáng.":"⚠️ Nên dọn sớm."}</p>`;87 unmodified lines888990919293949596979899100101102103104105196 unmodified lines30230330430530630730887 unmodified linesreturn "low";}function analyze(dets){// Gộp mọi loại rác thành "rác" (rác nổi + đống rác) cho nhất quánconst trashBoxes = dets.filter(d=>d.cls==="floating_trash"||d.cls==="trash_pile").map(d=>d.box);const nTrash = trashBoxes.length;const drains = dets.filter(d=>d.cls==="drain");const hasDrain = drains.length>0;let cov = 0, clog = null;if (hasDrain){ cov = Math.max(...drains.map(dr=>coverage(dr.box, trashBoxes)), 0); clog = clogLevel(cov); }return { nTrash, trashTotal: nTrash, hasDrain, coverage: Math.round(cov*10)/10, clog, flood: floodRisk(clog,nTrash,hasDrain) };}// vẽ box lên ảnh -> dataURL để hiển thịconst BOX_COLOR = { floating_trash:"#ffa500", trash_pile:"#ffa500", drain:"#1e90ff" };function drawAnnotated(source, dets, w, h){const c = document.createElement("canvas"); c.width=w; c.height=h;const ctx = c.getContext("2d"); ctx.drawImage(source,0,0,w,h);196 unmodified lines// hiện kết quảdocument.getElementById("resultCard").classList.remove("hidden");document.getElementById("resultImg").src=annotated;document.getElementById("rTrash").textContent=a.nTrash;const box=document.getElementById("clogResult");if(a.hasDrain&&a.clog){ const l=CLOG_LABEL[a.clog];box.innerHTML=`<p>Miệng cống: <span class="badge ${l.c}">${l.t}</span></p><p>Rác che <b>${a.coverage}%</b>. ${a.clog==="clear"?"Cống thông thoáng.":"⚠️ Nên dọn sớm."}</p>`;
app.js+5-7