示例#1
0
        public void Initialize(string pathModel, string pathConfig, string pathLabels, BackendEnums backend = BackendEnums.Default, TargetEnums target = TargetEnums.Cpu)
        {
            if (!File.Exists(pathLabels))
            {
                throw new FileNotFoundException("The file of labels not foud", pathLabels);
            }

            Initialize(pathModel, pathConfig, File.ReadAllLines(pathLabels), backend, target);
        }
示例#2
0
        public void Initialize(string pathModel, string pathConfig, string[] labels, BackendEnums backend = BackendEnums.Default, TargetEnums target = TargetEnums.Cpu)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            if (!File.Exists(pathModel))
            {
                throw new FileNotFoundException("The file model has not found", pathModel);
            }
            if (!File.Exists(pathConfig))
            {
                throw new FileNotFoundException("The file config has not found", pathConfig);
            }

            InitializeModel(pathModel, pathConfig);
            if (network == null || network.Empty())
            {
                throw new Exception("The model has not yet initialized or is empty.");
            }
            network.SetPreferableBackend((int)backend);
            network.SetPreferableTarget((int)target);

            this.Labels      = labels;
            this.Initialized = true;

            watch.Stop();

            Debug.WriteLine($"Load time of the model {this.GetType().Name} has taken {watch.ElapsedMilliseconds} milliseconds");
        }