DN-DETR debug record

During the DINO experiment, the blogger found that the detection performance of DINO-DETR for car and truck was not ideal in the COCO data set extracted from three categories. After experimenting with his own data set, he found that the AP value was not much different and It is more in line with expectations, so I guess whether it is because of the negative sample constraints added to DINO that the background is difficult to learn and the effect is poor, so DN-DETR is used for experiments. The figure below is the frame diagram of the DN-DETR model.

insert image description here

Next, introduce your own experimental process.
Since DN-DETR is also part of the DETR model, we don't need to configure the conda environment any more, just use the original detr conda environment.
The next thing to do is to select the model we need, and modify the data set directory and data set path configuration.
modelname is the model we need to choose for training. In DN-DETR, it provides four options. Since we want to compare with the results of DINO, we directly choose the one that is closest to the results of the DINO model.dn_dab_deformable_detr

parser.add_argument('--modelname', 
default="dn_dab_deformable_detr", type=str,  
choices=[
 'dn_dab_detr',
 'dn_dab_deformable_detr',                                                                         'dn_dab_deformable_detr_deformable_encoder_only',
 'dn_dab_dino_deformable_detr'
 ])

coco-path is the address of the dataset file.

parser.add_argument('--coco_path', default="/home/ubuntu/datasets/",type=str, )

Then we modify datasets/coco.pythe dataset configuration path in .

PATHS = {
    
    
        "train": (root / "images/train2017", root / "annotations" / f'{
      
      mode}_train2017.json'),
        "val": (root / "images/val2017", root / "annotations" / f'{
      
      mode}_val2017.json'),
    }

In fact, an example has been given in the readme, and we can follow its requirements.

python main.py -m dn_dab_detr \
  --output_dir logs/dn_DABDETR/R50 \
  --batch_size 1 \
  --epochs 50 \
  --lr_drop 40 \
  --coco_path /path/to/your/COCODIR  # replace the args to your COCO path
  --use_dn

The blogger's epoch is set to 50, batch-size=2. After modifying these parameters, just run main.py.
Like all DETR models, it takes up a lot of video memory during training.

insert image description here

category names: ['truck', 'car', 'bus']

report error

The blogger could run successfully in Terminal before, but reported the following error in pycharm. In the final analysis, the corresponding link file was missing.

OSError:
/home/ubuntu/.conda/envs/detr/lib/python3.7/site-packages/nvidia/cublas/lib/libcublas.so.11:
cannot open shared object file: No such file or directory

First we switch to /usr/localthe directory to view our cuda environment, then ls view

ubuntu@VM-16-3-ubuntu:~$ cd /usr/local
ubuntu@VM-16-3-ubuntu:/usr/local$ ls
bin  cuda  cuda-11.2  etc  games  include  lib  man  miniconda3  qcloud  sbin  share  src

cuda-11.2 is our cuda environment file directory. Just execute the code below.

sudo ldconfig /usr/local/cuda-11.2/lib64

Run it again, problem solved.

Guess you like

Origin blog.csdn.net/pengxiang1998/article/details/129907288