Spaces:
Running
Running
File size: 638 Bytes
d9c675a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import type { FileData } from "@gradio/client";
export interface Box {
left: number,
top: number,
right: number,
bottom: number,
};
export interface Annotation extends Box {
label: string | null,
};
export type AnnotatedImage = {
image: FileData,
annotations: Annotation[]
};
export function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
}
export function encodeToDataURL(data: any, mimeType: string = "application/json", charset: string = "utf-8"): string {
return "data:" + mimeType + ";charset=" + charset + "," + encodeURIComponent(JSON.stringify(data));
} |