locked
ML.NET Model input structure with Bitmap RRS feed

  • Question

  • Hi Everyone

    I have some  problem about ML.NET Model input type. i want the structure like as following

    public class ModelInput
    {
        public string Label { get; set; }
        public Bitmap ImageSource { get; set; }
    }
     

    But the tutorial in the official site just have the following type

    public class ModelInput
    {
        public string Label { get; set; }
        public string ImagePath { get; set; }
    }

    Does anyone have the tutorial about this question?

    Thanks

    Tutorial
    Monday, July 13, 2020 7:04 AM

All replies

  • You should include the link to where you got the code to start with to see what the API is.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, July 13, 2020 9:50 AM
  • Hi Casper_L,

    Thank you for posting here.

    Even if ModelInput is a class that you cannot modify, you can customize a class that meets your requirements, and then perform a simple conversion to get the structure you want.

        public class ModelInput
        {
            public string Label { get; set; }
            public string ImagePath { get; set; }
        }
    
        public class MyModelInput
        {
            public string Label { get; set; }
            public Bitmap ImageSource { get; set; }
        }


                ModelInput modelInput = new ModelInput() { Label = "test", ImagePath = @"d:\test\1.jpg" };
    
                MyModelInput myModelInput = new MyModelInput();
                myModelInput.Label = modelInput.Label;
                myModelInput.ImageSource = new Bitmap(modelInput.ImagePath);

    Is this what you need? If not, please provide more information so that we can understand the problem.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 14, 2020 2:34 AM
  • Hi

    If stored in physical directory .then should used like bellow
    public string ImagePath { get; set; }
    If stored in database Replace with 
    public byte[] Imagesource { get;set; }

    Thanks and regards

    Wednesday, July 15, 2020 4:14 PM
  • Hi,

    Has your issue been resolved?

    If so, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 30, 2020 6:09 AM