Skip to content

YOLOv3 shows ArgumentOutOfRangeException #4578

@priyankagupta639

Description

@priyankagupta639

Hello
I'm working on the latest version of Visual Studio 2019 on Windows 10
I have tried to work on object detection using yolov3 model. The yolov3.onnx file has been downloaded from https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/yolov3

Below is the snippet of the error shown on the console screen.
consoleError

This is the image of the output.
output error

The code is similar as used for object detection using tiny-yolov2. Following are the changes made in the code.

1.) ImageNetPrediction.cs file
public class ImageNetPrediction
{
[ColumnName("yolonms_layer_1/ExpandDims_3:0")]
public float[] PredictedLabels;
}

2.) YoloOutputParser.cs
public const int ROW_COUNT = 13;
public const int COL_COUNT = 13;
public const int CHANNEL_COUNT = 125;
public const int BOXES_PER_CELL = 5;
public const int BOX_INFO_FEATURE_COUNT = 5;
public const int CLASS_COUNT = 80;
public const float CELL_WIDTH = 32;
public const float CELL_HEIGHT = 32;
.
.
.
private string[] labels = new string[]
{
"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog",
"horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite",
"baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
"broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse", "remote", "keyboard",
"cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"
};

3.) OnnxModelScorer.cs
public struct TinyYoloModelSettings
{
public const string ModelInput = "input_1";
public const string ModelOutput = "yolonms_layer_1/ExpandDims_3:0";
}
.
.
.
var pipeline = mlContext.Transforms.LoadImages(outputColumnName: "image", imageFolder: "", inputColumnName: nameof(ImageNetData.ImagePath))
.Append(mlContext.Transforms.ResizeImages(outputColumnName: "image", imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: "input_1"))
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "image"))
.Append(mlContext.Transforms.ApplyOnnxModel(modelFile: modelLocation, outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }, inputColumnNames: new[] { TinyYoloModelSettings.ModelInput }));
.
.
.
public static void Main()
{
var assetsRelativePath = @"../../../assets";
string assetsPath = GetAbsolutePath(assetsRelativePath);
var modelFilePath = Path.Combine(assetsPath, "Model", "yolov3.onnx");
var imagesFolder = Path.Combine(assetsPath, "images");
var outputFolder = Path.Combine(assetsPath, "images", "output");

Also, how should I carry out the Preprocessing and Postprocessing steps?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority of the issue for triage purpose: Needs to be fixed at some point.onnxExporting ONNX models or loading ONNX modelsquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions