preprocessBytes static method

Tensor preprocessBytes(
  1. List<int> imageBytes,
  2. DonutConfig config
)

Preprocess raw image bytes for Donut inference.

imageBytes: raw image file bytes (PNG, JPEG, BMP, etc.) config: Donut configuration containing input size and align settings

Returns a tensor of shape (1, 3, height, width).

Implementation

static Tensor preprocessBytes(List<int> imageBytes, DonutConfig config) {
  final decoded = img.decodeImage(Uint8List.fromList(imageBytes));
  if (decoded == null) {
    throw ArgumentError('Failed to decode image');
  }
  return preprocessImage(decoded, config);
}