DonutConfig.fromJson constructor
Create from JSON map (for loading from config.json).
Implementation
factory DonutConfig.fromJson(Map<String, dynamic> json) {
return DonutConfig(
inputSize: (json['input_size'] as List?)?.cast<int>() ?? [2560, 1920],
alignLongAxis: json['align_long_axis'] as bool? ?? false,
windowSize: json['window_size'] as int? ?? 10,
encoderLayer:
(json['encoder_layer'] as List?)?.cast<int>() ?? [2, 2, 14, 2],
decoderLayer: json['decoder_layer'] as int? ?? 4,
maxPositionEmbeddings: json['max_position_embeddings'] as int? ?? 1536,
maxLength: json['max_length'] as int? ?? 1536,
encoderEmbedDim: json['encoder_embed_dim'] as int? ?? 128,
encoderNumHeads:
(json['encoder_num_heads'] as List?)?.cast<int>() ?? [4, 8, 16, 32],
patchSize: json['patch_size'] as int? ?? 4,
decoderEmbedDim: json['decoder_embed_dim'] as int? ?? 1024,
decoderFfnDim: json['decoder_ffn_dim'] as int? ?? 4096,
decoderNumHeads: json['decoder_num_heads'] as int? ?? 16,
vocabSize: json['vocab_size'] as int? ?? 57522,
nameOrPath: json['name_or_path'] as String? ?? '',
);
}