Code Monkey home page Code Monkey logo

Comments (7)

a1600012888 avatar a1600012888 commented on June 26, 2024

Seems wried.

What is the mAP and NDS of your trained model?

from detr3d.

kaixinbear avatar kaixinbear commented on June 26, 2024

Just similar to the official provided model. I don't know why.

Seems wried.

What is the mAP and NDS of your trained model?

from detr3d.

kaixinbear avatar kaixinbear commented on June 26, 2024

可以检查一下pkl里面yaw的定义跟你代码里的一致不一致。 mmdet3d在比较新的版本对坐标系做了一次调整,nuScenes的预处理和以前不一样了。如果你生成PKL的mmdet3d版本和你inference的版本不一致的话会出问题。

from detr3d.

a1600012888 avatar a1600012888 commented on June 26, 2024

Thanks for the update! Got it.
New version of mmdet3d change the paramerization of orientations and some corrdinates. I don't know the details.

from detr3d.

yihongXU avatar yihongXU commented on June 26, 2024

Hi,
Indeed, the code is not adapted to the newly released mmdet3d v1.0. For the compability, you need to update:
Basically, the changes of the new coordinate system are:

 # swap l, w (or dx, dy)
  item['gt_boxes'][:, 3] = boxes[:, 4]
  item['gt_boxes'][:, 4] = boxes[:, 3]
  # change yaw
  item['gt_boxes'][:, 6] = -boxes[:, 6] - np.pi / 2
  item['gt_boxes'][:, 6] = limit_period(
  item['gt_boxes'][:, 6], period=np.pi * 2)  

In the mmdet3d pkl files and the corresponding functions.
(c.f. https://github.com/open-mmlab/mmdetection3d/blob/master/docs/en/compatibility.md#v100rc0)

To adapt to the changes in detr3d (similar changes can be done for DGCNN):

  1. for testing (the code should work for both v0.17 or v1.0 since for evaluation, we do not use pkl generated by mmdet3d):
    insert:
if int(mmdet3d.__version__[0]) >= 1: 
  #### Begin hack adaptation to mmdet3d v1.0 ####
  bboxes[:, [3, 4]] = bboxes[:, [4, 3]] 
  bboxes[:, 6] = -bboxes[:, 6] - np.pi / 2
  #### End hack adaptation to mmdet3d v1.0 ####

right after

bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5

You can reproduce the results as in the table.

  1. For training, (not tested)
    i) You need to re-create the labels using mmdet3d >=v1.0 creat_data.py if your mmdet3d version is >=v1.0
    ii) modify the normalize_bbox function in projects/mmdet3d_plugin/core/bbox/util.py

as

def normalize_bbox(bboxes, pc_range):
    # all_bbox_preds: (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy)
    # gt_bboxes_list: (cx, cy, cz, l, w, h, rot, vx, vy)
    cx = bboxes[..., 0:1]
    cy = bboxes[..., 1:2]
    cz = bboxes[..., 2:3]
    w = bboxes[..., 3:4].log()
    l = bboxes[..., 4:5].log()
    h = bboxes[..., 5:6].log()
    rot = bboxes[..., 6:7]
    
    if bboxes.size(-1) > 7:
        vx = bboxes[..., 7:8] 
        vy = bboxes[..., 8:9]

        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos(), vx, vy), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos(), vx, vy), dim=-1
            )
    else:
        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos()), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos()), dim=-1
            )
    return normalized_bboxes

Have fun!

from detr3d.

tyxsspa avatar tyxsspa commented on June 26, 2024

Hi @yihongXU , for training if I use mmdet3d>=1.0 to create PKL and training, why should I must change normalize_bbox function?

Hi, Indeed, the code is not adapted to the newly released mmdet3d v1.0. For the compability, you need to update: Basically, the changes of the new coordinate system are:

 # swap l, w (or dx, dy)
  item['gt_boxes'][:, 3] = boxes[:, 4]
  item['gt_boxes'][:, 4] = boxes[:, 3]
  # change yaw
  item['gt_boxes'][:, 6] = -boxes[:, 6] - np.pi / 2
  item['gt_boxes'][:, 6] = limit_period(
  item['gt_boxes'][:, 6], period=np.pi * 2)  

In the mmdet3d pkl files and the corresponding functions.

(c.f. https://github.com/open-mmlab/mmdetection3d/blob/master/docs/en/compatibility.md#v100rc0)
To adapt to the changes in detr3d (similar changes can be done for DGCNN):

  1. for testing (the code should work for both v0.17 or v1.0 since for evaluation, we do not use pkl generated by mmdet3d):
    insert:
if int(mmdet3d.__version__[0]) >= 1: 
  #### Begin hack adaptation to mmdet3d v1.0 ####
  bboxes[:, [3, 4]] = bboxes[:, [4, 3]] 
  bboxes[:, 6] = -bboxes[:, 6] - np.pi / 2
  #### End hack adaptation to mmdet3d v1.0 ####

right after

bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5

You can reproduce the results as in the table.

  1. For training, (not tested)
    i) You need to re-create the labels using mmdet3d >=v1.0 creat_data.py if your mmdet3d version is >=v1.0
    ii) modify the normalize_bbox function in projects/mmdet3d_plugin/core/bbox/util.py

as

def normalize_bbox(bboxes, pc_range):
    # all_bbox_preds: (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy)
    # gt_bboxes_list: (cx, cy, cz, l, w, h, rot, vx, vy)
    cx = bboxes[..., 0:1]
    cy = bboxes[..., 1:2]
    cz = bboxes[..., 2:3]
    w = bboxes[..., 3:4].log()
    l = bboxes[..., 4:5].log()
    h = bboxes[..., 5:6].log()
    rot = bboxes[..., 6:7]
    
    if bboxes.size(-1) > 7:
        vx = bboxes[..., 7:8] 
        vy = bboxes[..., 8:9]

        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos(), vx, vy), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos(), vx, vy), dim=-1
            )
    else:
        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos()), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos()), dim=-1
            )
    return normalized_bboxes

Have fun!

from detr3d.

yihongXU avatar yihongXU commented on June 26, 2024

Hi @yihongXU , for training if I use mmdet3d>=1.0 to create PKL and training, why should I must change normalize_bbox function?

Hi, Indeed, the code is not adapted to the newly released mmdet3d v1.0. For the compability, you need to update: Basically, the changes of the new coordinate system are:

 # swap l, w (or dx, dy)
  item['gt_boxes'][:, 3] = boxes[:, 4]
  item['gt_boxes'][:, 4] = boxes[:, 3]
  # change yaw
  item['gt_boxes'][:, 6] = -boxes[:, 6] - np.pi / 2
  item['gt_boxes'][:, 6] = limit_period(
  item['gt_boxes'][:, 6], period=np.pi * 2)  

In the mmdet3d pkl files and the corresponding functions.

(c.f. https://github.com/open-mmlab/mmdetection3d/blob/master/docs/en/compatibility.md#v100rc0)
To adapt to the changes in detr3d (similar changes can be done for DGCNN):

  1. for testing (the code should work for both v0.17 or v1.0 since for evaluation, we do not use pkl generated by mmdet3d):
    insert:
if int(mmdet3d.__version__[0]) >= 1: 
  #### Begin hack adaptation to mmdet3d v1.0 ####
  bboxes[:, [3, 4]] = bboxes[:, [4, 3]] 
  bboxes[:, 6] = -bboxes[:, 6] - np.pi / 2
  #### End hack adaptation to mmdet3d v1.0 ####

right after

bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5

You can reproduce the results as in the table.

  1. For training, (not tested)
    i) You need to re-create the labels using mmdet3d >=v1.0 creat_data.py if your mmdet3d version is >=v1.0
    ii) modify the normalize_bbox function in projects/mmdet3d_plugin/core/bbox/util.py

as

def normalize_bbox(bboxes, pc_range):
    # all_bbox_preds: (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy)
    # gt_bboxes_list: (cx, cy, cz, l, w, h, rot, vx, vy)
    cx = bboxes[..., 0:1]
    cy = bboxes[..., 1:2]
    cz = bboxes[..., 2:3]
    w = bboxes[..., 3:4].log()
    l = bboxes[..., 4:5].log()
    h = bboxes[..., 5:6].log()
    rot = bboxes[..., 6:7]
    
    if bboxes.size(-1) > 7:
        vx = bboxes[..., 7:8] 
        vy = bboxes[..., 8:9]

        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos(), vx, vy), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos(), vx, vy), dim=-1
            )
    else:
        if int(mmdet3d.__version__[0]) >= 1: 
            normalized_bboxes = torch.cat(
                (cx, cy, l, w, cz, h, (- rot - np.pi / 2).sin(), (- rot - np.pi / 2).cos()), dim=-1
                )
        else:
            normalized_bboxes = torch.cat(
                (cx, cy, w, l, cz, h, rot.sin(), rot.cos()), dim=-1
            )
    return normalized_bboxes

Have fun!

Hi,
It depends. Let say we want that the predictions are in the order as before, i.e.
l_bbox_preds: (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy)
Depending the pkl version, the ordering of gt size is either (w, l, h) (v0.17) or (l, w, h) (v1.0). I adjust in the "normalize_bbox" (the function only used for gt bboxes), to keep the predictions ordering same as before. (The rotation is also changed...)

You can surely not to change during training, then the ordering of your predictions will also change, then you do not need to swap I did during inference.

Just be careful, the mmdet3D v1.0 expects .pkl in v1.0 because the data augmentation related to coordinates all suppose that you provide gt in (l, w, h) ordering.

from detr3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.