Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with QAT Implementation for YOLO Detection Model #1058

Open
4 tasks done
hamedgorji opened this issue Jul 2, 2024 · 0 comments
Open
4 tasks done

Issues with QAT Implementation for YOLO Detection Model #1058

hamedgorji opened this issue Jul 2, 2024 · 0 comments
Labels
question Further information is requested

Comments

@hamedgorji
Copy link

hamedgorji commented Jul 2, 2024

Before Asking

  • I have read the README carefully. 我已经仔细阅读了README上的操作指引。

  • I want to train my custom dataset, and I have read the tutorials for training your custom data carefully and organize my dataset correctly; (FYI: We recommand you to apply the config files of xx_finetune.py.) 我想训练自定义数据集,我已经仔细阅读了训练自定义数据的教程,以及按照正确的目录结构存放数据集。(FYI: 我们推荐使用xx_finetune.py等配置文件训练自定义数据集。)

  • I have pulled the latest code of main branch to run again and the problem still existed. 我已经拉取了主分支上最新的代码,重新运行之后,问题仍不能解决。

Search before asking

  • I have searched the YOLOv6 issues and found no similar questions.

Question

Hi,

I tried to use QAT for the detection model as described in the following link.

https://github.com/meituan/YOLOv6/blob/main/tools/qat/README.md

I downloaded the checkpoint and scale and followed the instructions. When I tried to do PTQ with the final version of YOLOv6, I got the following error:

Loading state_dict from ./assets/yolov6s_v2_reopt.pt for fine-tuning...
Traceback (most recent call last):
  File "C:\Users\Hamed\YOLOv6-det\tools\train.py", line 143, in <module>
    main(args)
  File "C:\Users\Hamed\YOLOv6-det\tools\train.py", line 128, in main
    trainer = Trainer(args, cfg, device)
  File "C:\Users\Hamed\YOLOv6-det\yolov6\core\engine.py", line 58, in __init__
    model = self.get_model(args, cfg, self.num_classes, device)
  File "C:\Users\Hamed\YOLOv6-det\yolov6\core\engine.py", line 424, in get_model
    model = load_state_dict(weights, model, map_location=device)
  File "C:\Users\Hamed\YOLOv6-det\yolov6\utils\checkpoint.py", line 13, in load_state_dict
    ckpt = torch.load(weights, map_location=map_location)
  File "C:\Users\Hamed\miniconda3\envs\yolov6\lib\site-packages\torch\serialization.py", line 809, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "C:\Users\Hamed\miniconda3\envs\yolov6\lib\site-packages\torch\serialization.py", line 1172, in _load
    result = unpickler.load()
  File "C:\Users\Hamed\miniconda3\envs\yolov6\lib\site-packages\torch\serialization.py", line 1165, in find_class
    return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SimConv' on <module 'yolov6.layers.common' from 'C:\\Users\\Hamed\\YOLOv6-det\\yolov6\\layers\\common.py'>

Then, I used version 3 of YOLOv6 and the PTQ worked, but when I tried to do QAT, it gave me a new error. I tried different solutions, but none of them worked. In between I got anchors_init error that I figured it out.
Do you have any suggestions or solutions? Why don't the instructions provided by the authors work?

(yolov6) C:\Users\Hamed\YOLOv6-3>python tools/train.py --data data/data.yaml --name QAT --conf configs/repopt/yolov6n_opt_qat.py --quant --distill --distill_feat --batch 16 --epochs 5 --workers 8 --teacher_model_path "./assets/v6n.pt" --device 0
Using 1 GPU for training...
training args are: Namespace(data_path='data/data.yaml', conf_file='configs/repopt/yolov6n_opt_qat.py', img_size=640, batch_size=16, epochs=5, workers=8, device='0', eval_interval=20, eval_final_only=False, heavy_eval_range=50, check_images=False, check_labels=False, output_dir='./runs/train', name='QAT', dist_url='env://', gpu_count=0, local_rank=-1, resume=False, write_trainbatch_tb=False, stop_aug_last_n_epoch=15, save_ckpt_on_last_n_epoch=-1, distill=True, distill_feat=True, quant=True, calib=False, teacher_model_path='./assets/v6n.pt', temperature=20, fuse_ab=False, bs_per_gpu=32, rank=-1, world_size=1, save_dir='runs\\train\\QAT4')

Train: Final numbers of valid images: 7030/ labels: 7030.
0.5s for dataset initialization.
Convert to COCO format
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3517/3517 [00:00<00:00, 72096.81it/s]
Convert to COCO format finished. Resutls saved in ./data\annotations\instances_val.json
Val: Final numbers of valid images: 3517/ labels: 3517.
0.7s for dataset initialization.
Loading state_dict from ./assets/v6n.pt for fine-tuning...
Model: Model(
  (backbone): EfficientRep(
    (stem): RealVGGBlock(
      (relu): ReLU(inplace=True)
      (conv): Conv2d(3, 16, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(16, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (se): Identity()
    )
    (ERBlock_2): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(16, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_3): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (1): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (2): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_4): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (1): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (2): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (3): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (4): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_5): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
      (2): SimSPPF(
        (cv1): SimConv(
          (conv): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (act): ReLU(inplace=True)
        )
        (cv2): SimConv(
          (conv): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (act): ReLU(inplace=True)
        )
        (m): MaxPool2d(kernel_size=5, stride=1, padding=2, dilation=1, ceil_mode=False)
      )
    )
  )
  (neck): RepPANNeck(
    (Rep_p4): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(192, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_p3): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(96, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_n3): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_n4): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (reduce_layer0): SimConv(
      (conv): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (upsample0): Transpose(
      (upsample_transpose): ConvTranspose2d(64, 64, kernel_size=(2, 2), stride=(2, 2))
    )
    (reduce_layer1): SimConv(
      (conv): Conv2d(64, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (upsample1): Transpose(
      (upsample_transpose): ConvTranspose2d(32, 32, kernel_size=(2, 2), stride=(2, 2))
    )
    (downsample2): SimConv(
      (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (downsample1): SimConv(
      (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
  )
  (detect): Detect(
    (proj_conv): Conv2d(17, 1, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (stems): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (cls_convs): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (reg_convs): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (cls_preds): ModuleList(
      (0): Conv2d(32, 2, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 2, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 2, kernel_size=(1, 1), stride=(1, 1))
    )
    (reg_preds): ModuleList(
      (0): Conv2d(32, 4, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 4, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 4, kernel_size=(1, 1), stride=(1, 1))
    )
    (reg_preds_lrtb): ModuleList(
      (0): Conv2d(32, 4, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 4, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 4, kernel_size=(1, 1), stride=(1, 1))
    )
  )
)
Loading state_dict from ./assets/v6n.pt for teacher
Model: Model(
  (backbone): EfficientRep(
    (stem): RealVGGBlock(
      (relu): ReLU(inplace=True)
      (conv): Conv2d(3, 16, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(16, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (se): Identity()
    )
    (ERBlock_2): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(16, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_3): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (1): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (2): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_4): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (1): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (2): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (3): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
          (4): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
    )
    (ERBlock_5): Sequential(
      (0): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (1): RepBlock(
        (conv1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (block): Sequential(
          (0): RealVGGBlock(
            (relu): ReLU(inplace=True)
            (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
            (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
            (se): Identity()
          )
        )
      )
      (2): SimSPPF(
        (cv1): SimConv(
          (conv): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (act): ReLU(inplace=True)
        )
        (cv2): SimConv(
          (conv): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (bn): BatchNorm2d(256, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (act): ReLU(inplace=True)
        )
        (m): MaxPool2d(kernel_size=5, stride=1, padding=2, dilation=1, ceil_mode=False)
      )
    )
  )
  (neck): RepPANNeck(
    (Rep_p4): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(192, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_p3): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(96, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_n3): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (Rep_n4): RepBlock(
      (conv1): RealVGGBlock(
        (relu): ReLU(inplace=True)
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (se): Identity()
      )
      (block): Sequential(
        (0): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (1): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
        (2): RealVGGBlock(
          (relu): ReLU(inplace=True)
          (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
          (se): Identity()
        )
      )
    )
    (reduce_layer0): SimConv(
      (conv): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (upsample0): Transpose(
      (upsample_transpose): ConvTranspose2d(64, 64, kernel_size=(2, 2), stride=(2, 2))
    )
    (reduce_layer1): SimConv(
      (conv): Conv2d(64, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (upsample1): Transpose(
      (upsample_transpose): ConvTranspose2d(32, 32, kernel_size=(2, 2), stride=(2, 2))
    )
    (downsample2): SimConv(
      (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
    (downsample1): SimConv(
      (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
      (act): ReLU(inplace=True)
    )
  )
  (detect): Detect(
    (proj_conv): Conv2d(17, 1, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (stems): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (cls_convs): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (reg_convs): ModuleList(
      (0): Conv(
        (conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(32, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (1): Conv(
        (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(64, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
      (2): Conv(
        (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn): BatchNorm2d(128, eps=0.001, momentum=0.03, affine=True, track_running_stats=True)
        (act): SiLU(inplace=True)
      )
    )
    (cls_preds_af): ModuleList(
      (0): Conv2d(32, 2, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 2, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 2, kernel_size=(1, 1), stride=(1, 1))
    )
    (reg_preds_af): ModuleList(
      (0): Conv2d(32, 4, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 4, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 4, kernel_size=(1, 1), stride=(1, 1))
    )
    (cls_preds_ab): ModuleList(
      (0): Conv2d(32, 6, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 6, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 6, kernel_size=(1, 1), stride=(1, 1))
    )
    (reg_preds_ab): ModuleList(
      (0): Conv2d(32, 12, kernel_size=(1, 1), stride=(1, 1))
      (1): Conv2d(64, 12, kernel_size=(1, 1), stride=(1, 1))
      (2): Conv2d(128, 12, kernel_size=(1, 1), stride=(1, 1))
    )
  )
)
Skip Layer detect.proj_conv
Insert fakequant after upsample
Traceback (most recent call last):
  File "C:\Users\Hamed\YOLOv6-3\tools\train.py", line 128, in <module>
    main(args)
  File "C:\Users\Hamed\YOLOv6-3\tools\train.py", line 113, in main
    trainer = Trainer(args, cfg, device)
  File "C:\Users\Hamed\YOLOv6-3\yolov6\core\engine.py", line 64, in __init__
    self.quant_setup(model, cfg, device)
  File "C:\Users\Hamed\YOLOv6-3\yolov6\core\engine.py", line 566, in quant_setup
    model.load_state_dict(torch.load(cfg.qat.calib_pt)['model'].float().state_dict())
  File "C:\Users\Hamed\miniconda3\envs\yolov6\lib\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Model:
        Missing key(s) in state_dict: "detect.reg_preds_lrtb.0.weight", "detect.reg_preds_lrtb.0.bias", "detect.reg_preds_lrtb.1.weight", "detect.reg_preds_lrtb.1.bias", "detect.reg_preds_lrtb.2.weight", "detect.reg_preds_lrtb.2.bias".

Additional

No response

@hamedgorji hamedgorji added the question Further information is requested label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant