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

can't set configuration for create a predictor #56

Closed
GuenKainto opened this issue May 17, 2024 · 4 comments
Closed

can't set configuration for create a predictor #56

GuenKainto opened this issue May 17, 2024 · 4 comments

Comments

@GuenKainto
Copy link

Hi,
image
How can i set Configuration, it's internal so i can't create a model

my code look like :
image

@GuenKainto GuenKainto changed the title can set configuration for can't set configuration for create a model May 17, 2024
@GuenKainto GuenKainto changed the title can't set configuration for create a model can't set configuration for create a predictor May 17, 2024
@aloksharma1
Copy link

here check this

_predictor = YoloV8Predictor.Create("yolov8x.onnx")); //path to model
using var image = Image.Load<Rgb48>(imageData.ToBytes());
var result = _predictor.Detect(image);
if (result != null)
{
    foreach (var box in result.Boxes)
    {
       //draw or do your work here
    }
}

should be easy to setup.

@dme-compunet
Copy link
Owner

@GuenKainto

using var predictor = YoloV8Builder.CreateDefaultBuilder()
                                   .UseOnnxModel("path/to/model.onnx")
                                   .WithConfiguration(configuration => 
                                   {
                                       configuration.Confidence = 3.5f,
                                       configuration.IoU = ...
                                   })
                                   .Build();

@GuenKainto
Copy link
Author

@GuenKainto

using var predictor = YoloV8Builder.CreateDefaultBuilder()
                                   .UseOnnxModel("path/to/model.onnx")
                                   .WithConfiguration(configuration => 
                                   {
                                       configuration.Confidence = 3.5f,
                                       configuration.IoU = ...
                                   })
                                   .Build();

Thankyou for reply ^.^
and i found an another way

private static YoloV8Predictor predictor = YoloV8Predictor.Create(Path.Combine(Environment.CurrentDirectory, "Assets\model\best.onnx"));
public static async Task PredictAsync(Image image, float? iou, float? confidence)
{
YoloV8Configuration config = new YoloV8Configuration();
config.IoU = iou ?? 0.45f;
config.Confidence = confidence ?? 0.3f;
ImageSelector imageSelector = new(image);
var result = await predictor.DetectAsync(imageSelector, config);
return await result.PlotImageAsync(image);
}
Is this okay ?

@dme-compunet
Copy link
Owner

Is this okay ?

Yes, it's only meant to pass configuration for a one prediction.

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