ambitious-octopus / model_optimization

Model Compression Toolkit (MCT) is an open source project for neural network model optimization under efficient, constrained hardware. This project provides researchers, developers, and engineers advanced quantization and compression tools for deploying state-of-the-art neural networks.
https://sony.github.io/model_optimization/
Apache License 2.0
0 stars 0 forks source link

Incorrect order of the box coordinates #4

Open Laughing-q opened 3 weeks ago

Laughing-q commented 3 weeks ago

The order of the box coordinates should be xyxy instead of yxyx, the coordinates are split in the yxyx order but then stack the y_bb in xyxy order. https://github.com/sony/model_optimization/blob/173ed446146f62a119d5bf09b09ef6e49d27a138/tutorials/mct_model_garden/models_pytorch/yolov8/yolov8.py#L269-L272 https://github.com/sony/model_optimization/blob/173ed446146f62a119d5bf09b09ef6e49d27a138/tutorials/mct_model_garden/models_pytorch/yolov8/yolov8.py#L273 However with this incorrect order the quantization works well hence I suspect the mct package is also doing job with the incorrect yxyx order. We might need some updates on this point, then we could directly return the bounding boxes by y_bb.transpose(1, 2) instead of splitting first then stack if we could fix the order.

return y_bb.transpose(1, 2), y_cls
Laughing-q commented 3 weeks ago

@Idan-BenAmi Hey, could you also take a look at this issue? is there a way to fix the order of box coordinates to make sure it's consistent to ultralytics package's xyxy? which would help us to simplify the code a lot. Thanks!

Idan-BenAmi commented 3 weeks ago

Hey @Laughing-q, Just to confirm, in our adjusted model, the "Detect" class outputs the bounding box (y_bb) in the yxyx order, and you’re asking it to be in the xyxy order instead?

Laughing-q commented 3 weeks ago

@Idan-BenAmi yes! :) then it'd be consistent with our package.

Idan-BenAmi commented 3 weeks ago

Hi @Laughing-q, For xyxy modification please follow: PR you will also need to update the export code: https://github.com/ambitious-octopus/model_optimization/blob/main/ultralytics-exports/vanilla-yolo.py#L132

output_resize = {'shape': (INPUT_RESOLUTION, INPUT_RESOLUTION), 'aspect_ratio_preservation': True, 'normalized_coords': False, 'xyxy_bbox_format': True}

Laughing-q commented 3 weeks ago

@Idan-BenAmi It works! Thank you! @ambitious-octopus I'll push a update to ultralytics@quan to simplify the code a bit. :)

return y_bb.transpose(1, 2), y_cls