keras-team / keras-cv

Industry-strength Computer Vision workflows with Keras
Other
999 stars 330 forks source link

YOLOv8 - Use of compute_ciou in task-aligned assignment #2253

Open ctorney opened 9 months ago

ctorney commented 9 months ago

I noticed that the task alignment code in the YOLOV8LabelEncoder calculates the overlaps with compute_ciou in place of compute_iou: https://github.com/keras-team/keras-cv/blob/e360fb7047f4c628359c9b5555e313a75c0f9a77/keras_cv/models/object_detection/yolo_v8/yolo_v8_label_encoder.py#L101

Maybe I'm missing something but this doesn't seem correct. Eqn. 9 from the TAL paper gives the alignment metric as $$t = s^\alpha\times u^\beta$$ where $s$ and $u$ denote a classification score and an IoU value, respectively. In the paper $u$ is always between 0 and 1 as it is the IoU but in the code it is 1-CIoULoss which can take negative values.

If $\beta=6.0$ (the default) then an overlap score of -0.2 would have much higher alignment then a score of 0.1 so doesn't this mean that training is focused on the anchors with low quality localisation? But then you'd have the opposite weighting if $\beta=5.0$ and nan values possible for non-integer $\beta$.

divyashreepathihalli commented 8 months ago

Tagging the author for more clarification - @IMvision12 PR for the code added here

ctorney commented 8 months ago

also tagging the author of the original version that used iou @ianstenbit