function renderBox({ box, label, score }) {
const { xmax, xmin, ymax, ymin } = box;
const color =
"#" +
Math.floor(Math.random() * 0xffffff)
.toString(16)
.padStart(6, 0);
const boxElement = document.createElement("div");
Object.assign(boxElement.style, {
borderWidth: "2px",
borderStyle: "solid",
borderColor: color,
left: 100 * xmin + "%",
top: 100 * ymin + "%",
width: 100 * (xmax - xmin) + "%",
height: 100 * (ymax - ymin) + "%",
position: "absolute"
});
const labelElement = document.createElement("span");
labelElement.textContent = label + " " + (score * 100).toFixed(2) + "%";
labelElement.style.backgroundColor = color;
labelElement.style.color = "white";
boxElement.appendChild(labelElement);
return boxElement.outerHTML;
}