public static void Initialize(BundleManfest manifest) { IBundleTransform jstransformer; IBundleTransform csstransformer; #if DEBUG jstransformer = new PassThroughTransform("text/javascript"); csstransformer = new PassThroughTransform("text/css"); #else jstransformer = new JsMinify(); csstransformer = new CssMinify(); #endif foreach (var bs in manifest.JsBundles) { Bundle jsBundle = new Bundle(bs.SpecKey, jstransformer); jsBundle.Include(bs.FilePaths.ToArray()); BundleTable.Bundles.Add(jsBundle); } foreach (var bs in manifest.CssBundles) { Bundle cssBundle = new Bundle(bs.SpecKey, csstransformer); cssBundle.Include(bs.FilePaths.ToArray()); BundleTable.Bundles.Add(cssBundle); } }
/// <summary> /// Loads a pipeline saved in zip format. /// </summary> protected void Load(Stream fs) { var transformPipe = ModelFileUtils.LoadPipeline(_env, fs, new MultiFileSource(null), true); var pred = _env.LoadPredictorOrNull(fs); IDataView root; for (root = transformPipe; root is IDataTransform && !(root is PassThroughTransform); root = ((IDataTransform)root).Source) { ; } if (!(root is PassThroughTransform)) { var tr = new PassThroughTransform(_env, new PassThroughTransform.Arguments(), root); transformPipe = ApplyTransformUtils.ApplyAllTransformsToData(_env, transformPipe, tr, root); } var stack = new List <IDataView>(); for (root = transformPipe; root is IDataTransform; root = ((IDataTransform)root).Source) { stack.Add(root); } stack.Reverse(); _transforms = new StepTransform[stack.Count]; for (int i = 0; i < _transforms.Length; ++i) { _transforms[i] = new StepTransform() { transform = stack[i] as IDataTransform, transformSettings = null } } ; if (pred == null) { _predictor = new StepPredictor() { predictor = null, roleMapData = null, trainer = null, trainerSettings = null } } ; else { #pragma warning disable CS0618 var ipred = pred.GetPredictorObject() as IPredictor; #pragma warning restore CS0618 _roles = ModelFileUtils.LoadRoleMappingsOrNull(_env, fs).ToList(); var data = new RoleMappedData(transformPipe, _roles); _predictor = new StepPredictor() { predictor = ipred, roleMapData = data, trainer = null, trainerSettings = null }; } _fastValueMapper = null; }
/// <summary> /// Loads a pipeline saved in onnx format. /// </summary> protected void LoadOnnx(Stream fs) { var root = new PassThroughTransform(_env, new PassThroughTransform.Arguments(), null); _transforms = new StepTransform[2]; _transforms[0] = new StepTransform() { transform = root as IDataTransform, transformSettings = null }; _transforms[1] = new StepTransform() { transform = ConvertFromOnnx.ReadOnnx(fs, root), transformSettings = null }; _predictor = new StepPredictor() { predictor = null, roleMapData = null, trainer = null, trainerSettings = null }; _fastValueMapper = null; }
static PassThroughTransform() { Instance = new PassThroughTransform(); }