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

YOLOv3 shows ArgumentOutOfRangeException #4578

Open
priyankagupta639 opened this issue Dec 14, 2019 · 2 comments
Open

YOLOv3 shows ArgumentOutOfRangeException #4578

priyankagupta639 opened this issue Dec 14, 2019 · 2 comments
Labels
onnx Exporting ONNX models or loading ONNX models P2 Priority of the issue for triage purpose: Needs to be fixed at some point. question Further information is requested

Comments

@priyankagupta639
Copy link

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?

@mstfbl mstfbl added P2 Priority of the issue for triage purpose: Needs to be fixed at some point. question Further information is requested labels Jan 9, 2020
@gartangh
Copy link

gartangh commented Feb 4, 2020

This might be an answer to your question, or introduce an additional question:
The YOLOv3 model you downloaded, has ONNX version 1.5 and operation set (opset) 10.
From this site, I assume that using that model will not work (yet).
I would also be interested in using YOLOv3 object detection in C#, so if someone knows how to get this to work, please react here.

(By the way, the link in your question points to https://github.com/dotnet/machinelearning/issues/url instead of https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/yolov3.)

@harishsk harishsk added the onnx Exporting ONNX models or loading ONNX models label Apr 29, 2020
@BobLd
Copy link

BobLd commented Oct 30, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
onnx Exporting ONNX models or loading ONNX models P2 Priority of the issue for triage purpose: Needs to be fixed at some point. question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants