图像分类 Ml.net 异常
Exception in Ml.net in image classification
它是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.
尝试从 NuGet 和目标 x64 安装 Microsoft.Ml.Data
;但是,如果它不起作用,您可能会考虑转向 .NET Core – Bill 和他的手下正在强迫所有人转向 .NET Core。
它是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.
尝试从 NuGet 和目标 x64 安装 Microsoft.Ml.Data
;但是,如果它不起作用,您可能会考虑转向 .NET Core – Bill 和他的手下正在强迫所有人转向 .NET Core。