Megvii-BaseDetection / YOLOX

YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5 with MegEngine, ONNX, TensorRT, ncnn, and OpenVINO supported. Documentation: https://yolox.readthedocs.io/
Apache License 2.0
9.42k stars 2.21k forks source link

How to change strides of YOLOXHEAD? #1096

Open trongtuyen99 opened 2 years ago

trongtuyen99 commented 2 years ago

It's amazing repo and algorithm. I got good performance with yolox. When optimize model with small object, I just want to change strides head and get the error:

  File "/YOLOX/yolox/models/yolo_head.py", line 619, in dynamic_k_matching
    cost[gt_idx], k=dynamic_ks[gt_idx], largest=False
    │    │          │          └ 0
    │    │          └ [1]
    │    └ 0
    └ tensor([], size=(1, 0))

RuntimeError: selected index k out of range

Please show me how to change stride of head and fix that error. Thanks for your help!

trongtuyen99 commented 2 years ago

@FateScript Please check my issue and help me fix this! Thanks

FateScript commented 2 years ago

It's a matching issue caused by empty gt, and I can't understand why changing stride could solve this issue. However, you could simply modify stride by changing self.strides to the value you want.

trongtuyen99 commented 2 years ago

Thanks @FateScript for your response. I changed self.strides from [8, 16, 32] to [4, 8, 16] and got this error when training. Should I change dataset generator flow something like that?

FateScript commented 2 years ago

please check your cost matrix, it shouldn't be a empty tensor.

trongtuyen99 commented 2 years ago

I can train normally before change stride, why cost matric become empty when I change stride?