예제 #1
0
        public static CustomVisionModel CreateFromFilePath(string path)
        {
            CustomVisionModel learningModel = new CustomVisionModel();

            learningModel.model   = LearningModel.LoadFromFilePath(path);
            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }
예제 #2
0
        public static async Task <CustomVisionModel> CreateFromStorageFile(StorageFile file)
        {
            CustomVisionModel learningModel = new CustomVisionModel();

            learningModel.model = await LearningModel.LoadFromStorageFileAsync(file);

            IReadOnlyList <ILearningModelFeatureDescriptor> input = learningModel.model.InputFeatures.ToList();
            MapFeatureDescriptor imgDesc = input[0] as MapFeatureDescriptor;

            TensorFeatureDescriptor tfDesc = input[0] as TensorFeatureDescriptor;

            learningModel.inputParameterName = input[0].Name;
            learningModel.inputWidth         = (int)tfDesc.Shape[2];
            learningModel.inputHeight        = (int)tfDesc.Shape[3];
            IReadOnlyList <ILearningModelFeatureDescriptor> output = learningModel.model.OutputFeatures.ToList();
            MapFeatureDescriptor    imgDesc1 = output[0] as MapFeatureDescriptor;
            TensorFeatureDescriptor tfDesc1  = output[0] as TensorFeatureDescriptor;

            learningModel.outputParameterName = output[0].Name;
            learningModel.session             = new LearningModelSession(learningModel.model);
            learningModel.binding             = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }