Das Objekt, das von der "Predictiongine" zurückgegeben wurde. ML.NET ist für das Yolo -Modell, das hier überhaupt nicht zutreffen scheint, da ich viele Dinge ändern musste, um an diesen Punkt zu gelangen. Hier ist, was ich bisher habe: < /p>
Code: Select all
var data = mlContext.Data.LoadFromEnumerable(new List());
// Define scoring pipeline
var pipeline = mlContext.Transforms.LoadImages(outputColumnName: "input_tensor", imageFolder: "", inputColumnName: nameof(ImageNetData.ImagePath))
.Append(mlContext.Transforms.ResizeImages(outputColumnName: "input_tensor", imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: "input_tensor"))
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "input_tensor", outputAsFloatArray: false))
.Append(mlContext.Transforms.ApplyOnnxModel(modelFile: modelLocation,
outputColumnNames: new[] { "detection_boxes", "num_detections", "detection_classes", "detection_scores" },
inputColumnNames: new[] { "input_tensor" }));
// Fit scoring pipeline
var model = pipeline.Fit(data);
var pred = mlContext.Model.CreatePredictionEngine(model);
var prediction = pred.Predict(new ImageNetData()
{
ImagePath = @"usually_contains_full_path_to_img_here.png"
});
// here `prediction` is not null, but all the fields inside it are...
ImageNeTdata und ImageNetPrediction wie folgt: < /p>
public class ImageNetData
{
[LoadColumn(0)]
public string ImagePath;
public static IEnumerable ReadFromFile(string imageFolder)
{
return Directory
.GetFiles(imageFolder)
.Where(filePath => Path.GetExtension(filePath) != ".md")
.Select(filePath => new ImageNetData { ImagePath = filePath });
}
}
public class ImageNetPrediction
{
[ColumnName("detection_boxes:0")]
public float[] DetectionBoxes;
}
durchführen kann
Code: Select all
Length of memory (1228800) must match product of dimensions (3).