Darknet: detect_mat returning weird output outside of classes range

Created on 26 Mar 2019  路  4Comments  路  Source: AlexeyAB/darknet

Running on Tesla V100, Ubuntu 18.04, built with latest dependencies.
Using modified Alturos.Yolo.

Important classes that produce the following output:

`public IEnumerable Detect(byte[] imageData)
{
if (!this._imageAnalyzer.IsValidImageFormat(imageData))
{
throw new Exception("Invalid image data, wrong image format");
}

        var container = new BboxContainer();
        var size = Marshal.SizeOf(imageData[0]) * imageData.Length;
        var pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(imageData, 0, pnt, imageData.Length);
            var count = 0;
            switch (this.DetectionSystem)
            {
                case DetectionSystem.CPU:
                    count = DetectImageCpu(pnt, imageData.Length, ref container);
                    break;
                case DetectionSystem.GPU:
                    count = DetectImageGpu(pnt, imageData.Length, ref container);
                    break;
            }

            if (count == -1)
            {
                throw new NotImplementedException("C++ dll compiled incorrectly");
            }
        }
        catch (Exception exception)
        {
            return null;
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }

        return this.Convert(container);
    }

    private IEnumerable<YoloItem> Convert(BboxContainer container)
    {
        var yoloItems = new List<YoloItem>();

        foreach (var item in container.candidates.Where(o => o.h > 0 || o.w > 0))
        {
            Console.WriteLine(item.obj_id);

            //Console.WriteLine(item.track_id);
            //if (!this._objectType.ContainsKey((int)item.obj_id)) continue; 
            var objectType = this._objectType[(int)item.obj_id];
            var yoloItem = new YoloItem() { X = (int)item.x, Y = (int)item.y, Height = (int)item.h, Width = (int)item.w, Confidence = item.prob, Type = objectType };
            yoloItems.Add(yoloItem);
        }

        return yoloItems;
    }`

80 (TOTAL NUMBER OF READ CLASSES)
0 (PERSON)
0 (PERSON)
15 (WITHIN RANGE)
2143289344 (OUTSIDE 0-79 range)

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key '2143289344' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Alturos.Yolo.YoloWrapper.Convert(BboxContainer container)
at Alturos.Yolo.YoloWrapper.Detect(Byte[] imageData)

Most helpful comment

I also did this in the Alturos project.

All 4 comments

Amazing, fast and effective. Was this the relevant change?

public float x_3d, y_3d, z_3d;

Amazing, fast and effective. Was this the relevant change?

Yes.

I also did this in the Alturos project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yumin-Sun-00 picture Yumin-Sun-00  路  3Comments

siddharth2395 picture siddharth2395  路  3Comments

Cipusha picture Cipusha  路  3Comments

qianyunw picture qianyunw  路  3Comments

hemp110 picture hemp110  路  3Comments