compiledSquareInputSide function

int compiledSquareInputSide(
  1. CompiledModel model, {
  2. int channels = 3,
  3. String label = 'model',
})

The square input side (e.g. 192 or 224) of a single-input model, derived from its input byte size.

Throws UnsupportedError if the model does not have exactly one input or the input is not a square [1, S, S, channels] float32 tensor.

Implementation

int compiledSquareInputSide(
  CompiledModel model, {
  int channels = 3,
  String label = 'model',
}) {
  if (model.inputCount != 1) {
    throw UnsupportedError(
      'Compiled $label expects one input tensor; got ${model.inputCount}.',
    );
  }
  final int floats = compiledFloatCount(
    model.inputByteSizes.single,
    label: '$label input',
  );
  return squareSideFromFloats(
    floats,
    channels: channels,
    label: '$label input',
  );
}