GeekAlexis / FastMOT

High-performance multiple object tracking based on YOLO, Deep SORT, and KLT 🚀
MIT License
1.15k stars 255 forks source link

Not able to write anchors of yolov4 tiny #57

Closed aditdoshi333 closed 3 years ago

aditdoshi333 commented 3 years ago

Thank you for sharing such amazing work. I want to use Yolov4 Tiny with FastMot. But I am getting the following error

python3: yolo_layer.cu:118: virtual nvinfer1::Dims nvinfer1::YoloLayerPlugin::getOutputDimensions(int, const nvinfer1::Dims, int): Assertion `inputs[0].d[0] == (mNumClasses + 5) mNumAnchors' failed. Aborted (core dumped)

class YOLOv4(YOLO): ENGINE_PATH = Path(file).parent / 'yolo_drone.trt' MODEL_PATH = Path(file).parent / 'yolo_drone.onnx' NUM_CLASSES = 1 INPUT_SHAPE = (3, 768, 1024) LAYER_FACTORS = [32,16] SCALES = [1.05, 1.05] ANCHORS = 9, 9, 24, 19, 81, 42, 149, 62, 196,103, 650,416

I am passing anchors as two sub-lists each containing 6 elements. I think I am not missing something while writing anchors.

Any help would be appreciated Thank you

GeekAlexis commented 3 years ago

@aditdoshi333 Is your YOLOv4-tiny trained for one class?

aditdoshi333 commented 3 years ago

Yes it is trained for one class.

GeekAlexis commented 3 years ago

@aditdoshi333 Make sure you follow #23 for filling up the anchors.

aditdoshi333 commented 3 years ago

I added this in yolo.py.

class YOLOv4(YOLO): ENGINE_PATH = Path(file).parent / 'yolo_drone.trt' MODEL_PATH = Path(file).parent / 'yolo_drone.onnx' NUM_CLASSES = 1 INPUT_SHAPE = (3, 768, 1024) LAYER_FACTORS = [32, 16] SCALES = [1.05, 1.05] ANCHORS = [[149,62,196,103,650,416], [9,9,24,19,81,42]]

Yes, I saw that explanation but I am not able to understand where I am getting wrong. I have tried reverse order as suggested by you for tiny.

GeekAlexis commented 3 years ago

@aditdoshi333 How did you convert YOLO to ONNX?

aditdoshi333 commented 3 years ago

I used this : https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/demo_darknet2onnx.py

GeekAlexis commented 3 years ago

@aditdoshi333 Can you try this instead https://github.com/jkjung-avt/tensorrt_demos/blob/master/yolo/yolo_to_onnx.py. You may want to rename your weight and config to yolov4-tiny-1024x768.cfg and yolov4-tiny-1024x768.weight

aditdoshi333 commented 3 years ago

Hey, thanks now it is able to create tensorRT engine. But there is a problem I am not able to get any bounding box. I am getting the results when using the same tensorRT engine for inference using (https://github.com/jkjung-avt/tensorrt_demos). But it is not showing any results when using with FastMOT. Are there any processing changes I need to do for yolo 4 tiny?

Thank you for the help

GeekAlexis commented 3 years ago

Make sure class_ids in mot.json is set correctly

On Mon, Feb 22, 2021 at 11:38 PM Adit Doshi notifications@github.com wrote:

Hey, thanks now it is able to create tensorRT engine. But there is a problem I am not able to get any bounding box. I am getting the results when using the same tensorRT engine for inference using ( https://github.com/jkjung-avt/tensorrt_demos). But it is not showing any results when using with FastMOT. Are there any processing changes I need to do for yolo 4 tiny?

Thank you for the help

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/GeekAlexis/FastMOT/issues/57#issuecomment-783976960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNJO5QZX4QLOSIAKLINSADTANLOBANCNFSM4YALIYQQ .

aditdoshi333 commented 3 years ago

Thanks man! It is working. One more doubt in track.py you are getting the center of the bounding box from tlbr variable. That center x,y is with respect to which frame? Input or some other processing

aditdoshi333 commented 3 years ago

I asked this because sometimes I am getting log like

[INFO] Out: drone 4 at [-2658 -955]

I am not able to understand the negative values of x and y. Even I am interested in the range of values of and x and y

GeekAlexis commented 3 years ago

The image size determines the range, which is indicated by size in mot.json. "Out" means the object is out of view. It is normal to have negative coordinates if the object is large and/or moves too fast.

GeekAlexis commented 3 years ago

Closing this now because the issue is resolved