ML.NET无法加载TensorFlow模型h5

时间:2020-06-04 08:27:11

标签: tensorflow ml.net

您好,无法加载TensorFlow模型,请帮助我。 模型网址:https://nomeroff.net.ua/models/ocr/ua/anpr_ocr_ua_17-cpu.h5 代码:

            string patch = basedirectory+ "\\anpr_ocr_ua_17-cpu.h5";
        if (System.IO.File.Exists(patch))
        {

            MLContext mLContext = new MLContext(seed: 1);
            TensorFlowModel tensorFlowModel = mLContext.Model.LoadTensorFlowModel(patch);
            //DataViewSchema schema1;
            //var model = mLContext.Model.Load(patch, out schema1);
            var scheme = tensorFlowModel.GetInputSchema();
            DataViewSchema schema = tensorFlowModel.GetModelSchema();
            Console.WriteLine(" =============== TensorFlow Model Schema =============== ");
            var featuresType = (VectorDataViewType)schema["Features"].Type;
            Console.WriteLine($"Name: Features, Type: {featuresType.ItemType.RawType}, Size: ({featuresType.Dimensions[0]})");
            var predictionType = (VectorDataViewType)schema["Prediction/Softmax"].Type;
            Console.WriteLine($"Name: Prediction/Softmax, Type: {predictionType.ItemType.RawType}, Size: ({predictionType.Dimensions[0]})");
            var modelYTesflow = tensorFlowModel.GetModelSchema();
        }

0 个答案:

没有答案