@@ -16,6 +16,7 @@ public record NitroConfig : PipelineConfig
1616 /// </summary>
1717 public NitroConfig ( )
1818 {
19+ OutputSize = 512 ;
1920 Tokenizer = new TokenizerConfig
2021 {
2122 BOS = 128000 ,
@@ -50,6 +51,7 @@ public NitroConfig()
5051 public DecoderConfig TextEncoder { get ; init ; }
5152 public TransformerModelConfig Transformer { get ; init ; }
5253 public AutoEncoderModelConfig AutoEncoder { get ; init ; }
54+ public int OutputSize { get ; init ; }
5355
5456
5557 /// <summary>
@@ -82,9 +84,9 @@ public override void Save(string configFile, bool useRelativePaths = true)
8284 /// <param name="modelType">Type of the model.</param>
8385 /// <param name="executionProvider">The execution provider.</param>
8486 /// <returns>NitroConfig.</returns>
85- public static NitroConfig FromDefault ( string name , ModelType modelType , ExecutionProvider executionProvider = default )
87+ public static NitroConfig FromDefault ( string name , int outputSize , ModelType modelType , ExecutionProvider executionProvider = default )
8688 {
87- var config = new NitroConfig { Name = name } ;
89+ var config = new NitroConfig { Name = name , OutputSize = outputSize } ;
8890 config . Transformer . ModelType = modelType ;
8991 config . SetProvider ( executionProvider ) ;
9092 return config ;
@@ -109,12 +111,12 @@ public static NitroConfig FromFile(string configFile, ExecutionProvider executio
109111 /// Create Nitro configuration from folder structure
110112 /// </summary>
111113 /// <param name="modelFolder">The model folder.</param>
114+ /// <param name="outputSize">Size of the output.</param>
112115 /// <param name="modelType">Type of the model.</param>
113116 /// <param name="executionProvider">The execution provider.</param>
114- /// <returns>NitroConfig.</returns>
115- public static NitroConfig FromFolder ( string modelFolder , ModelType modelType , ExecutionProvider executionProvider = default )
117+ public static NitroConfig FromFolder ( string modelFolder , int outputSize , ModelType modelType , ExecutionProvider executionProvider = default )
116118 {
117- var config = FromDefault ( Path . GetFileNameWithoutExtension ( modelFolder ) , modelType , executionProvider ) ;
119+ var config = FromDefault ( Path . GetFileNameWithoutExtension ( modelFolder ) , outputSize , modelType , executionProvider ) ;
118120 config . Tokenizer . Path = Path . Combine ( modelFolder , "tokenizer" ) ;
119121 config . TextEncoder . Path = Path . Combine ( modelFolder , "text_encoder" , "model.onnx" ) ;
120122 config . Transformer . Path = Path . Combine ( modelFolder , "transformer" , "model.onnx" ) ;
@@ -123,5 +125,24 @@ public static NitroConfig FromFolder(string modelFolder, ModelType modelType, Ex
123125 return config ;
124126 }
125127
128+
129+ /// <summary>
130+ /// Create Nitro configuration from folder structure
131+ /// </summary>
132+ /// <param name="modelFolder">The model folder.</param>
133+ /// <param name="modelType">Type of the model.</param>
134+ /// <param name="executionProvider">The execution provider.</param>
135+ public static NitroConfig FromFolder ( string modelFolder , string variant , ExecutionProvider executionProvider = default )
136+ {
137+ var outputSize = variant . Contains ( "1024" ) ? 1024 : 512 ;
138+ var modelType = variant . Contains ( "Turbo" , System . StringComparison . OrdinalIgnoreCase ) ? ModelType . Turbo : ModelType . Base ;
139+ var config = FromDefault ( Path . GetFileNameWithoutExtension ( modelFolder ) , outputSize , modelType , executionProvider ) ;
140+ config . Tokenizer . Path = Path . Combine ( modelFolder , "tokenizer" ) ;
141+ config . TextEncoder . Path = GetVariantPath ( modelFolder , "text_encoder" , "model.onnx" , variant ) ;
142+ config . Transformer . Path = GetVariantPath ( modelFolder , "transformer" , "model.onnx" , variant ) ;
143+ config . AutoEncoder . DecoderModelPath = GetVariantPath ( modelFolder , "vae_decoder" , "model.onnx" , variant ) ;
144+ config . AutoEncoder . EncoderModelPath = GetVariantPath ( modelFolder , "vae_encoder" , "model.onnx" , variant ) ;
145+ return config ;
146+ }
126147 }
127148}
0 commit comments