【发布时间】: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