RangiLyu / nanodet

NanoDet-Plus⚡Super fast and lightweight anchor-free object detection model. 🔥Only 980 KB(int8) / 1.8MB (fp16) and run 97FPS on cellphone🔥
Apache License 2.0
5.63k stars 1.03k forks source link

Export onnx model error #559

Closed Arrebol2020 closed 3 months ago

Arrebol2020 commented 3 months ago

When I trained a model on a custom dataset and used export_onnx.py to export the ONNX model, I encountered the following error:r: image The model can load and infer successfully. This is my configuration content:

# nanodet-plus-m-1.5x_416
# COCO mAP(0.5:0.95) = 0.341
#             AP_50  = 0.506
#             AP_75  = 0.357
#           AP_small = 0.143
#               AP_m = 0.363
#               AP_l = 0.539
save_dir: workspace/nanodet-plus-m-1.5x_yolo_taunets_x0.5_occ
model:
  weight_averager:
    name: ExpMovingAverager
    decay: 0.9998
  arch:
    name: NanoDetPlus
    detach_epoch: 10
    backbone:
      name: ShuffleNetV2
      model_size: 1.5x
      out_stages: [2,3,4]
      activation: LeakyReLU
    fpn:
      name: GhostPAN
      in_channels: [176, 352, 704]
      out_channels: 128
      kernel_size: 5
      num_extra_level: 1
      use_depthwise: True
      activation: LeakyReLU
    head:
      name: NanoDetPlusHead
      num_classes: 8
      input_channel: 128
      feat_channels: 128
      stacked_convs: 2
      kernel_size: 5
      strides: [8, 16, 32, 64]
      activation: LeakyReLU
      reg_max: 7
      norm_cfg:
        type: BN
      loss:
        loss_qfl:
          name: QualityFocalLoss
          use_sigmoid: True
          beta: 2.0
          loss_weight: 1.0
        loss_dfl:
          name: DistributionFocalLoss
          loss_weight: 0.25
        loss_bbox:
          name: GIoULoss
          loss_weight: 2.0
    # Auxiliary head, only use in training time.
    aux_head:
      name: SimpleConvHead
      num_classes: 8
      input_channel: 256
      feat_channels: 256
      stacked_convs: 4
      strides: [8, 16, 32, 64]
      activation: LeakyReLU
      reg_max: 7

class_names:  &class_names ['obj1', 'obj2', 'obj3', 'obj4', 'obj5', 'obj6',
              'obj7', 'obj8']

data:
  train:
    name: YoloDataset
    img_path: /home/fan/prjs/surfemb/data/bop/taunets/det_0.5/images/train
    ann_path: /home/fan/prjs/surfemb/data/bop/taunets/det_0.5/labels/train
    class_names: *class_names
    input_size: [320,240] #[w,h]
    keep_ratio: False
    pipeline:
      perspective: 0.0
      scale: [0.6, 1.4]
      stretch: [[0.8, 1.2], [0.8, 1.2]]
      rotation: 0
      shear: 0
      translate: 0.2
      flip: 0.5
      brightness: 0.2
      contrast: [0.6, 1.4]
      saturation: [0.5, 1.2]
      random_occ: True
      max_occ_ratio: 0.5
      normalize: [[103.53, 116.28, 123.675], [57.375, 57.12, 58.395]]
  val:
    name: YoloDataset
    img_path: /home/fan/prjs/surfemb/data/bop/taunets/det_0.5/images/val
    ann_path: /home/fan/prjs/surfemb/data/bop/taunets/det_0.5/labels/val
    class_names: *class_names
    input_size: [320,240] #[w,h]
    keep_ratio: False
    pipeline:
      normalize: [[103.53, 116.28, 123.675], [57.375, 57.12, 58.395]]
device:
  gpu_ids: [2]
  workers_per_gpu: 10
  batchsize_per_gpu: 96
schedule:
#  resume:
#  load_model:
  optimizer:
    name: AdamW
    lr: 0.001
    weight_decay: 0.05
  warmup:
    name: linear
    steps: 500
    ratio: 0.0001
  total_epochs: 100
  lr_schedule:
    name: CosineAnnealingLR
    T_max: 100
    eta_min: 0.00005
  val_intervals: 10
grad_clip: 35
evaluator:
  name: CocoDetectionEvaluator
  save_key: mAP
log:
  interval: 50