【问题标题】:Exception in Ml.net in image classification图像分类中 Ml.net 中的异常
【发布时间】:2020-12-27 17:01:06
【问题描述】:

它是来自 ml.net 的自动生成代码,我只实现了按钮 1 上的打开文件对话框代码。这是 Windows 窗体应用程序中图像检测的代码。这里有两个按钮和一个图片框。按钮 1 用于浏览图像,按钮 2 用于检测图像。

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();
            ofd.Filter = "Image Files|*.jpg;*.png";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = Image.FromFile(ofd.FileName);

            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            // Add input data
            var input = new ModelInput();

            // Load model and predict output of sample data
            ModelOutput result = ConsumeModel.Predict(input);
            MessageBox.Show(result.Prediction);
        }
    }
}

当我单击按钮 2 来检测图像时,它给了我这个异常 System.TypeInitializationException: 'The type initializer for 'WindowsFormsApp3ML.Model.ConsumeModel' threw an exception. FileNotFoundException: Could not load file or assembly 'Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.' I have tried to train my model 2 times but gives me same exception.

【问题讨论】:

    标签: c# visual-studio winforms machine-learning ml.net


    【解决方案1】:

    尝试从 NuGet 安装 Microsoft.Ml.Data 并以 x64 为目标;但是,如果它不起作用,您可能会考虑迁移到 .NET Core - Bill 和他的手下正在强迫每个人都使用 .NET Core。

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 2020-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      相关资源
      最近更新 更多