linoyts's picture
linoyts HF Staff
Qwen-Image 2.1 on WebGPU: 2-step int4 ONNX, diffusers.js pipeline
8f9eb25 verified
Raw History Blame Contribute Delete
860 Bytes
export function formatBytes(size) {
const i = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;
return `${(size / 1024 ** i).toFixed(i > 1 ? 1 : 0)} ${["B", "kB", "MB", "GB", "TB"][i]}`;
}
export default function Progress({ text, loaded, total }) {
const pct = total > 0 ? Math.min(100, (loaded / total) * 100) : 0;
return (
<div className="w-full min-w-0">
<div className="flex justify-between gap-2 text-xs text-zinc-400 mb-1">
<span className="truncate min-w-0">{text}</span>
<span className="shrink-0 tabular-nums">{formatBytes(loaded)} / {formatBytes(total)} ({pct.toFixed(0)}%)</span>
</div>
<div className="h-2 w-full rounded bg-zinc-800 overflow-hidden">
<div className="h-full bg-amber-400 transition-[width] duration-150" style={{ width: `${pct}%` }} />
</div>
</div>
);
}