SpriteMisaka / YOLOv3-DL4J

A JAVA application using DL4J to load keras YOLOv3 model to detect objects on VisDrone dataset.
0 stars 0 forks source link

Index out of bounds #1

Closed danielsalinasv closed 2 years ago

danielsalinasv commented 2 years ago

Hi, i was trying to run this example, but it was not working at first because it was not finding opencv, so i update the dl4j version to latest and remove the line System.loadLibrary(Core.NATIVE_LIBRARY_NAME); so now is running but it is throwing an index out of bounds exception

Do you know a solution for this?

SpriteMisaka commented 2 years ago

Hi, danielsalinasv.

I have no idea because index out of bounds exception is very common. Give me some details about the problem and make sure you have your own YOLOv3 keras model.

danielsalinasv commented 2 years ago

Hi SpriteMisaka, i use this project to generate the yolov3 model https://github.com/susnato/keras-yolo3 and put the model.h5 file in the resources folder, to run your project i only update the paths changing \ by / because i'm using ubuntu 20.04, also update the dl4j version from 1.0.0-M1.1 to 1.0.0-M2.1, the project was not finding opencv lib so i change System.loadLibrary(Core.NATIVE_LIBRARY_NAME); to Loader.load(opencv_java.class);, finally when i run the project throws the index out of bounds exception in line: newValue = Math.exp(oldValue) * Config.ANCHORS[scale][box][isHeight] / (32 / Math.pow(2, scale)); because box is greater than 3.

SpriteMisaka commented 2 years ago

I trained the model with a specific dataset. The variable box is related with the number of classes, so check the classes file in the resources folder if you do not use VisDrone2019 dataset.

danielsalinasv commented 2 years ago

Oh now is working, thank you very much, i updated classes with person bicycle car motorcycle airplane 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 couch potted plant bed dining table toilet tv laptop mouse remote keyboard cell phone microwave oven toaster sink refrigerator book clock vase scissors teddy bear hair drier toothbrush