Spaces:
Paused
Paused
Download frontend/lib/utils.ts from akagtag/deepdetection: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/akagtag/deepdetection/resolve/main/frontend/lib/utils.ts
- Command line
-
hf download hf://spaces/akagtag/deepdetection/frontend/lib/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/akagtag/deepdetection/resolve/main/frontend/lib/utils.ts
811 Bytes
| // frontend/lib/utils.ts | |
| import { type ClassValue, clsx } from 'clsx' | |
| import { twMerge } from 'tailwind-merge' | |
| export function cn(...inputs: ClassValue[]) { | |
| return twMerge(clsx(inputs)) | |
| } | |
| export function formatBytes(bytes: number): string { | |
| if (bytes === 0) return '0 B' | |
| const k = 1024 | |
| const sizes = ['B', 'KB', 'MB', 'GB'] | |
| const i = Math.floor(Math.log(bytes) / Math.log(k)) | |
| return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}` | |
| } | |
| export function formatMs(ms: number): string { | |
| if (ms < 1000) return `${Math.round(ms)}ms` | |
| return `${(ms / 1000).toFixed(1)}s` | |
| } | |
| export function formatConfidence(confidence: number): string { | |
| return `${(confidence * 100).toFixed(1)}%` | |
| } | |
| export function clampConfidence(v: number): number { | |
| return Math.max(0, Math.min(1, v)) | |
| } | |