• Validate model data against known size constraints.

    Checks if the model file size is within expected ranges. This helps detect corrupted downloads or incorrect model files. Returns true if no size constraints are configured for the model.

    Parameters

    • modelName: string

      Name of the model file

    • modelData: ArrayBuffer

      Model data as ArrayBuffer

    Returns boolean

    True if size is within expected range

    Example

    const response = await fetch('/models/u2net.onnx');
    const modelData = await response.arrayBuffer();

    const sizeValid = validateModelSize('u2net.onnx', modelData);
    if (!sizeValid) {
    console.error('Model file size is unexpected - may be corrupted');
    return;
    }

    console.log('Model size validation passed');