Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model not supported #22

Closed
uri-el99 opened this issue Oct 4, 2023 · 6 comments
Closed

Model not supported #22

uri-el99 opened this issue Oct 4, 2023 · 6 comments

Comments

@uri-el99
Copy link

uri-el99 commented Oct 4, 2023

Hello author, hope you are doing well.

I am currently trying to use the NuGet Package but I am getting some troubles.
I am starting with programming so I´m a bigginer, I used your code reference but I get this: System.InvalidOperationException: 'The loaded model does not support this task' and I do not why, I´ve searched for some solutions but I´m still stuck.
Can you help me out? I´d highly apreciate.
image

@dme-compunet
Copy link
Owner

Hello @uri-el99, this exception is thrown because you are trying to perform detection from a model whose task is not 'detect'. YOLOv8 has models for several tasks, you must make sure that the inference you make matches to task of the model. (you can see the model task in the Netron tool)

@uri-el99
Copy link
Author

uri-el99 commented Oct 6, 2023

Hello @uri-el99, this exception is thrown because you are trying to perform detection from a model whose task is not 'detect'. YOLOv8 has models for several tasks, you must make sure that the inference you make matches to task of the model. (you can see the model task in the Netron tool)

I greatly appreciate your response and help on this problem, thank you very much for that observation.
Hoping not to take up your time, I would like to know if you can help me with another question.
I want to load an image in WindowsForms through an OpneFileDialog and display the image in another one, but already with the results obtained by the model. Do you know how I can make the conversion from System.Drawing.Image to Compunet.YoloV8.ImageSelector?

@FunJoo
Copy link
Contributor

FunJoo commented Oct 7, 2023

var ofd = new Microsoft.Win32.OpenFileDialog();
if (ofd.ShowDialog() == true)
{
    var image = Compunet.YoloV8.ImageSelector(ofd.FileName)
}

@uri-el99
Copy link
Author

var ofd = new Microsoft.Win32.OpenFileDialog();
if (ofd.ShowDialog() == true)
{
    var image = Compunet.YoloV8.ImageSelector(ofd.FileName)
}

Hi @FunJoo hope I am not disturbing you. Rephrasing my question, how can I display the result in a PictureBox?
I want to open an image that is displayed in a PictureBox, and, subsequently, that selected image is analysed and the result is displayed in another PictureBox. I hope you can help me a bit and sorry for the inconvenience.

@FunJoo
Copy link
Contributor

FunJoo commented Oct 13, 2023

Hi, @uri-el99 I do not use WinForm, but I can provide you with a method given by ChatGPT4.

public static SixLabors.ImageSharp.Image<Rgb24> ConvertToImageSharpImage(System.Drawing.Image systemDrawingImage)
{
    using MemoryStream memoryStream = new MemoryStream();
    systemDrawingImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
    memoryStream.Seek(0, SeekOrigin.Begin);
    return SixLabors.ImageSharp.Image.Load<Rgb24>(memoryStream);
}

public static System.Drawing.Image ConvertToSystemDrawingImage(SixLabors.ImageSharp.Image<Rgb24> imageSharpImage)
{
    using MemoryStream memoryStream = new MemoryStream();
    imageSharpImage.Save(memoryStream, new SixLabors.ImageSharp.Formats.Png.PngEncoder());
    memoryStream.Seek(0, SeekOrigin.Begin);
    return System.Drawing.Image.FromStream(memoryStream);
}

When encountering situations where Compunet.YoloV8.ImageSelector is needed, you can directly use SixLabors.ImageSharp.Image.

@uri-el99
Copy link
Author

@FunJoo Thanks for all your support, using the information you provided, I was able to solve that problem, and, although others came up later, I was able to solve them.
I appreciate the time you took to find a solution, thank you very much. best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants