0

It is autogenerated code from ml.net, I have only implement the open file dialog code which is on button 1. Here is the code of image detection in windows form application. two buttons and one picture box here. button 1 for browsing image and button 2 for detecting image.

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);
        }
    }
}

when I am clicking on button 2 to detect the image it gives me this exception 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.

1 Answer 1

1

Try installing Microsoft.Ml.Data from NuGet and target x64; but, if it doesn't work, you might consider moving to .NET Core – Bill and his boys are forcing everyone to .NET Core.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.